source: MondoRescue/branches/2.0.8/mondo/mondo/post-nuke.sample/usr/bin/post-nuke@ 576

Last change on this file since 576 was 576, checked in by bcornec, 18 years ago

2.08 synced with stable as of r575
VERSION files updated

  • Property svn:keywords set to Id
  • Property svn:unix-mode set to 755
File size: 1.9 KB
Line 
1#!/bin/sh
2#
3#
4# Sample post-nuke script by Hugo Rabson <hugorabson@msn.com>
5#
6#
7# 04/23
8# - more distro-nonspecific file list, thanks to find/grep
9#
10# 04/22/2003
11# - first created
12#
13###############################################################################
14
15Die() {
16 echo "$1" >> /dev/stderr
17 exit 1
18}
19
20
21AskMe() {
22 sz=""
23 while [ ! "$sz" ] ; do
24 echo -en "$1"
25 read sz
26 done
27}
28
29
30AddOrReplaceLine() {
31 local oldfile newfile sz_exclude sz_add
32 oldfile=$1.orig
33 mv -f $1 $oldfile
34 newfile=$1
35 sz_exclude="$2"
36 sz_add="$3"
37 > $newfile
38 grep -v "$sz_exclude.*" $oldfile >> $newfile
39 echo "$sz_add" >> $newfile
40}
41
42
43ListOfEth0Files() {
44 local i
45 for i in `find $1/etc | grep eth0` ; do
46 grep "IPADDR=" $i > /dev/null 2> /dev/null && echo $i
47 done
48}
49
50
51# ---------------------------------------------------------------------
52
53
54[ "$#" -ne "2" ] && Die "post-nuke <base dir> <mondorestore res code>"
55basedir=$1
56
57echo -en " Welcome to my post-nuke configuration script\n\n"
58done=""
59while [ ! "$done" ] ; do
60 AskMe " What would you like your IP address to be? "
61 ipaddr=$sz
62 AskMe " What would you like your netmask address to be? "
63 netmask=$sz
64 echo " IP address: $ipaddr Netmask: $netmask"
65 AskMe " Is that okay (y/n)? "
66 if [ "$sz" = "y" ] || [ "$sz" = "Y" ] ; then
67 done="yes"
68 fi
69done
70
71ip_wildcard="[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*"
72files_changed=0
73for path in `ListOfEth0Files $basedir` ; do
74 filename=$path
75 [ ! -e "$filename" ] && continue
76 echo "Processing $filename"
77 AddOrReplaceLine $filename "IPADDR=$ip_wildcard" "IPADDR=$ipaddr"
78 AddOrReplaceLine $filename "NETMASK=$ip_wildard" "NETMASK=$netmask"
79 files_changed=$(($files_changed+1))
80done
81echo "Done. $files_changed files changed. Post-nuke script is exiting now."
82echo -en "Press ENTER to continue."
83read line
84exit 0
85
Note: See TracBrowser for help on using the repository browser.