1 | #!/bin/sh
|
---|
2 | #
|
---|
3 | #
|
---|
4 | # 07/14/04
|
---|
5 | # - if interactive then not expert :)
|
---|
6 | #
|
---|
7 | # 06/12/04
|
---|
8 | # - tell user to call mondorestore --mbr after nuking
|
---|
9 | #
|
---|
10 | # 08/02/03
|
---|
11 | # - don't call multifunc cd, even if it is one
|
---|
12 | #
|
---|
13 | # 05/30/03
|
---|
14 | # - added hooks for multi-function CD
|
---|
15 | #
|
---|
16 | # 05/04/03
|
---|
17 | # - better handling of mondorestore softlinks
|
---|
18 | # - no more 'mondo-restore' --- it's 'mondorestore'
|
---|
19 | #
|
---|
20 | # 03/26/03
|
---|
21 | # - report if mount-me, unmount-me, mondorestore missing
|
---|
22 | # - call mondorestore instead of mondo-restore
|
---|
23 | #
|
---|
24 | # 07/15/02
|
---|
25 | # - copy mountlist.txt to logfile at start
|
---|
26 | #
|
---|
27 | # 07/11/02
|
---|
28 | # - exit w/o calling mondorestore, if non-mondo CD/floppy
|
---|
29 | #
|
---|
30 | # 06/28/02
|
---|
31 | # - RESTORE == nuke_mode
|
---|
32 | #
|
---|
33 | # 06/24/02
|
---|
34 | # - disabled isonuke
|
---|
35 | #
|
---|
36 | # 06/13/02
|
---|
37 | # - added isonuke
|
---|
38 | #
|
---|
39 | # 02/03/02
|
---|
40 | # - softlink mondo-restore -> mondorestore if mondorestore exists but m-r not
|
---|
41 | #
|
---|
42 | # 12/10/01
|
---|
43 | # - removed the 'clear' from the start of the script
|
---|
44 | #
|
---|
45 | # 12/09/01
|
---|
46 | # - broke up spaghetti code; made lots of subroutines
|
---|
47 | # - moved some subroutines to /sbin/init, where they belong
|
---|
48 | #------------------------------------------------------------
|
---|
49 |
|
---|
50 |
|
---|
51 | call_multifunc_cd() {
|
---|
52 | echo "Hooray! I'm a multi-function CD. Oo! Oo!"
|
---|
53 | mount | grep cdrom > /dev/null 2> /dev/null || mount /dev/cdrom /mnt/cdrom >> $LOGFILE 2>> $LOGFILE
|
---|
54 | for i in bin lib usr sbin ; do
|
---|
55 | echo -en "\rNormalizing $i ... "
|
---|
56 | if [ -d "/mnt/cdrom/$i" ] ; then
|
---|
57 | for j in `find /mnt/cdrom/$i` ; do
|
---|
58 | k=`echo "$j" | awk -F '/' '{for(i=4; i<=NF;i++) {printf("/%s",$i);};printf "\n"; }'`
|
---|
59 | mkdir -p $k
|
---|
60 | rmdir $k 2> /dev/null
|
---|
61 | ln -sf $j $k
|
---|
62 | done
|
---|
63 | fi
|
---|
64 | done
|
---|
65 | echo -en "\rNormalized softlinks OK.\n"
|
---|
66 | echo -en "Shall I run a CPU burn-in test in the background (y/n) ?"
|
---|
67 | read line
|
---|
68 | if [ "$line" = "y" ] || [ "$line" = "Y" ] || [ "$line" = "yes" ] || [ "$line" = "YES" ] ; then
|
---|
69 | for i in `find /usr/local/sbin/burn*` ; do basename $i ; done
|
---|
70 | echo -en "...Which one ?"
|
---|
71 | read line
|
---|
72 | $i || echo $? &
|
---|
73 | fi
|
---|
74 | for i in lucifer mprime ; do
|
---|
75 | # tiobench ide-smart
|
---|
76 | if which $i > /dev/null > /dev/null ; then
|
---|
77 | echo -en "Shall I run $i (y/n) ?"
|
---|
78 | read line
|
---|
79 | if [ "$line" = "y" ] || [ "$line" = "Y" ] || [ "$line" = "yes" ] || [ "$line" = "YES" ] ; then
|
---|
80 | echo "Running $i ..."
|
---|
81 | $i || echo "Warning - $i returned an error"
|
---|
82 | fi
|
---|
83 | fi
|
---|
84 | done
|
---|
85 |
|
---|
86 | # echo "Running bash."
|
---|
87 | # busybox sh
|
---|
88 | echo "Exiting multi-function CD thingy. Please reboot immediately."
|
---|
89 | exit 0
|
---|
90 | }
|
---|
91 |
|
---|
92 |
|
---|
93 | # ---------------------------- main ----------------------------
|
---|
94 |
|
---|
95 | sleep 1
|
---|
96 |
|
---|
97 | if [ -e "/MULTIFUNC" ] ; then
|
---|
98 | LogIt "I think this is a multifunc CD but I'm not going there today."
|
---|
99 | # call_multifunc_cd
|
---|
100 | fi
|
---|
101 |
|
---|
102 | cat /tmp/mountlist.txt >> /tmp/mondo-restore.log
|
---|
103 |
|
---|
104 | iso=`cat /proc/cmdline | grep "iso"`
|
---|
105 | nuke=`cat /proc/cmdline | grep "nuke"`
|
---|
106 | if [ "$nuke" = "" ] ; then
|
---|
107 | nuke=`cat /proc/cmdline | grep "RESTORE "`
|
---|
108 | fi
|
---|
109 | expert=`cat /proc/cmdline | grep "expert"`
|
---|
110 | compare=`cat /proc/cmdline | grep "compare"`
|
---|
111 | interactive=`cat /proc/cmdline | grep "interactive"`
|
---|
112 | [ "$interactive" ] && expert=""; # in case 'expert' crops up somewhere
|
---|
113 | if which mondorestore > /dev/null 2> /dev/null ; then
|
---|
114 | LogIt "mondorestore found; cool..."
|
---|
115 | else
|
---|
116 | if [ "$iso$nuke$compare$interactive" != "" ] ; then
|
---|
117 | LogIt "FYI, this CD was made by Mindi, not Mondo." 1
|
---|
118 | exit 0
|
---|
119 |
|
---|
120 | else
|
---|
121 | LogIt "Mindi-Linux has finished booting."
|
---|
122 | fi
|
---|
123 | fi
|
---|
124 |
|
---|
125 | if [ -h "`which mondorestore`" ] ; then
|
---|
126 | LogIt "Turning mondorestore from a hyperlink into an executable"
|
---|
127 | cat `which mondorestore` > /usr/bin/MR
|
---|
128 | # in case there's more than one instance :)
|
---|
129 | rm -f `which mondorestore 2> /dev/null`
|
---|
130 | rm -f `which mondorestore 2> /dev/null`
|
---|
131 | rm -f `which mondorestore 2> /dev/null`
|
---|
132 | rm -f `which mondorestore 2> /dev/null`
|
---|
133 | mv /usr/bin/MR /usr/bin/mondorestore
|
---|
134 | chmod +x /usr/bin/mondorestore
|
---|
135 | fi
|
---|
136 |
|
---|
137 | if which bootstrap > /dev/null 2> /dev/null ; then
|
---|
138 | LogIt "Calling bootstrap script" 1
|
---|
139 | bootstrap
|
---|
140 | fi
|
---|
141 |
|
---|
142 | for i in mount-me unmount-me mondorestore ; do
|
---|
143 | if which $i > /dev/null 2> /dev/null ; then
|
---|
144 | LogIt "$i found"
|
---|
145 | else
|
---|
146 | LogIt "Warning - $i not found on ramdisk."
|
---|
147 | fi
|
---|
148 | done
|
---|
149 |
|
---|
150 | #if [ "$iso" ] && [ "$nuke" ] ; then
|
---|
151 | # LogIt "------------------ISONUKE MODE-----------------" 1
|
---|
152 | # mondorestore --isonuke
|
---|
153 | #el
|
---|
154 | #if [ "$iso" ] ; then
|
---|
155 | # LogIt "--------------------ISO MODE-------------------" 1
|
---|
156 | # mondorestore --iso
|
---|
157 | #el
|
---|
158 | if [ "$compare" ] ; then
|
---|
159 | LogIt "------------------COMPARE MODE-----------------" 1
|
---|
160 | mondorestore --compare
|
---|
161 | elif [ "$nuke" ] ; then
|
---|
162 | LogIt "-------------------NUKE MODE-------------------" 1
|
---|
163 | mondorestore --nuke
|
---|
164 | elif [ "$expert" ] ; then
|
---|
165 | if [ "`cat /tmp/mondo-restore.cfg | grep tapedev`" ] ; then
|
---|
166 | LogIt "-------------------TAPE MODE-------------------" 1
|
---|
167 | loc=`which mondorestore 2> /dev/null`
|
---|
168 | if [ "$loc" = "" ] ; then
|
---|
169 | LogIt "I presume you backed up with Mindi, not Mondo." 1
|
---|
170 | else
|
---|
171 | LogIt "Tape Mode -- calling mondorestore..."
|
---|
172 | if [ "$nuke" ] ; then
|
---|
173 | mondorestore --nuke
|
---|
174 | else
|
---|
175 | mondorestore; # MR will detect & access the tape
|
---|
176 | fi
|
---|
177 | fi
|
---|
178 | elif [ "`cat /tmp/mondo-restore.cfg | grep using-cdstream`" ] ; then
|
---|
179 | LogIt "------------------CDSTREAM MODE------------------" 1
|
---|
180 | loc=`which mondorestore 2> /dev/null`
|
---|
181 | if [ "$loc" = "" ] ; then
|
---|
182 | LogIt "I presume you backed up with Mindi, not Mondo." 1
|
---|
183 | else
|
---|
184 | LogIt "Cdstream Mode -- calling mondorestore..."
|
---|
185 | if [ "$nuke" ] ; then
|
---|
186 | mondorestore --nuke
|
---|
187 | else
|
---|
188 | mondorestore; # MR will detect & access the cdstream
|
---|
189 | fi
|
---|
190 | fi
|
---|
191 | else
|
---|
192 | LogIt "------------------EXPERT MODE------------------" 1
|
---|
193 | LogIt "You do all the work. :-)" 1
|
---|
194 | if which mondorestore > /dev/null 2> /dev/null ; then
|
---|
195 | LogIt "Type 'mondorestore' to begin the restore/compare process." 1
|
---|
196 | loc=`which ISO 2> /dev/null`
|
---|
197 | fi
|
---|
198 | fi
|
---|
199 | else
|
---|
200 | LogIt "------------------INTERACTIVE------------------" 1
|
---|
201 | mondorestore --interactive
|
---|
202 | fi
|
---|
203 |
|
---|
204 | [ -e "/tmp/DO-MBR-PLEASE" ] && LogIt "PLEASE RUN 'mondorestore --mbr' NOW TO INITIALIZE YOUR BOOT SECTOR." 1
|
---|
205 |
|
---|
206 | exit 0
|
---|