source: MondoRescue/branches/2.2.5/mindi/rootfs/sbin/init@ 1826

Last change on this file since 1826 was 1826, checked in by Bruno Cornec, 16 years ago

Wait more around the USB CD emulated by iLO as it takes up to 5 seconds to come up

  • Property svn:keywords set to Id
File size: 20.3 KB
Line 
1#!/bin/sh
2#
3# $Id: init 1826 2007-12-01 17:19:28Z bruno $
4#
5# init script launched during the restore process
6#------------------------------------------------------------
7
8
9CaughtSoftReset() {
10 trap SIGTERM
11 reboot
12}
13
14
15ConfigureLoggingDaemons() {
16 echo -en "Running klogd..."
17 klogd -c 2 > /dev/null 2> /dev/null
18 echo -en "Done.\nRunning syslogd..."
19 syslogd > /dev/null 2> /dev/null
20 echo "Done."
21 LogIt "klogd and syslogd have been started."
22}
23
24
25
26CopyBootDevEntry() {
27 local outfile devfile
28 devfile=/dev/boot_device
29 outfile=`cat /BOOTLOADER.DEVICE 2> /dev/null`
30 [ ! "$outfile" ] && return 0
31 echo -en "Copying boot device to $outfile..."
32 if [ -e "$outfile" ] ; then
33 echo "OK."
34 return 0
35 fi
36 mkdir -p $outfile
37 rmdir $outfile
38 cp -pRdf $devfile $outfile
39 if [ "$?" -ne "0" ] ; then
40 echo "Failed."
41 return 1
42 else
43 echo "OK."
44 return 0
45 fi
46}
47
48
49
50Die() {
51 LogIt "Fatal error! $1" 1
52 exit 1
53}
54
55
56
57ExtractDevTarballs() {
58 cd /
59 for fname in ataraid.tgz ida.tgz i2o.tgz rd.tgz raw.tgz cciss.tgz nst.tgz dm.tgz vc.tgz ; do
60 if [ ! -e "/$fname" ] ; then
61 LogIt "/$fname not found; cannot extract to /." 1
62 else
63 echo -en "\rExtracting /$fname... "
64 tar -zxf /$fname || LogIt "Error occurred while extracting /$fname"
65 fi
66 done
67 echo -en "\r"
68 LogIt "Extracted additional /dev entries OK. " 1
69}
70
71
72
73LaunchTerminals() {
74 openvt 2 /bin/sh
75 openvt 3 /bin/sh
76 openvt 4 /bin/sh
77 openvt 5 /bin/sh
78 openvt 6 /bin/sh
79 openvt 7 /bin/sh /sbin/wait-for-petris
80 openvt 8 /usr/bin/tail -f $LOGFILE
81}
82
83
84LoadKeymap() {
85 local fname
86 fname=`cat /tmp/KEYMAP-LIVES-HERE 2> /dev/null`
87 [ "$fname" = "" ] && return
88 if which loadkeys > /dev/null 2> /dev/null ; then
89 loadkeys $fname
90# loadkmap != loadkeys
91# elif which loadkmap > /dev/null 2> /dev/null ; then
92# loadkmap < $fname
93 else
94 LogIt "Using default keyboard map." 1
95 fi
96}
97
98
99UntarTapeStuff() {
100 local old_pwd res
101 old_pwd=`pwd`
102 cd $GROOVY
103 [ "$1" != "" ] && tapedev=$1
104 [ ! "$tapedev" ] && tapedev=`grep media-dev /tmp/mondo-restore.cfg | tr -s ' ' ' ' | cut -d' ' -f2`
105# tar -zxf $tapedev
106 dd if=$tapedev bs=32k count=1024 | tar -zx
107 res=$?
108 if [ "$res" -eq "0" ] ; then
109 grep -v media-dev /tmp/mondo-restore.cfg > /tmp/mr.cfg
110 echo "media-dev $tapedev" >> /tmp/mr.cfg
111 cp -f /tmp/mr.cfg /tmp/mondo-restore.cfg
112 fi
113 cd $old_pwd
114 return $res
115}
116
117HandleTape() {
118 local res tapedev
119 tapedev="" ; # will be set by UntarTapeStuff()
120 cd $GROOVY
121 UntarTapeStuff $tapedev || UntarTapeStuff /dev/st0 || UntarTapeStuff /dev/osst0 || UntarTapeStuff /dev/ht0
122 res=$?
123 while [ "$res" -ne "0" ] ; do
124 LogIt "$tapedev failed to act as extended data disk for booting." 1
125 LogIt "Please specify an alternate tape device," 1
126 LogIt "or hit <Enter> to boot from CD/floppies." 1
127 echo -en "---> "
128 read tapedev
129 if [ "$tapedev" ] ; then
130 LogIt "User specified $tapedev instead"
131 UntarTapeStuff $tapedev
132 res=$?
133 else
134 LogIt "User opted not to specify an alternate tapedev"
135 res=1
136 break
137 fi
138 done
139
140 if [ "$res" -ne "0" ] ; then
141 cd /
142 LogIt "Failed to use tape as extended datadisk. Reverting to floppies." 1
143 HandleCDROMorFloppies
144 res=$?
145 else
146# clear
147 LogIt "Using tape as extended datadisk. Good." 3
148 echo "Using tape as extd ddisk." > /tmp/TAPEDEV-HAS-DATA-DISKS
149 res=0
150 CD_MOUNTED_OK=yes
151 fi
152 return $res
153}
154
155
156
157HandleCDROMorFloppies() {
158 # Just in case we have an iLO ensure we will map it correctly
159 echo "Activating a potential USB Storage device"
160 if [ -e "/tmp/USE-UDEV" ] ; then
161 if [ -f usb-storage.ko ] || [ -f usb-storage.ko.gz ]; then
162 modprobe -q usb-storage
163 fi
164 else
165 if [ -f usb-storage.ko ] || [ -f usb-storage.ko.gz ]; then
166 insmod usb-storage.ko*
167 fi
168 fi
169 for i in 1 2 3 4 5 6 7 8 9 10 ; do
170 sleep 1
171 echo -en "."
172 done
173
174 find-and-mount-cdrom
175 res=$?
176 if [ "$res" -ne "0" ] ; then
177 LogIt "First call to find-and-mount-cdrom failed." 1
178 LogIt "Sleeping for 3 seconds and trying again." 1
179 sleep 3
180 find-and-mount-cdrom
181 res=$?
182 fi
183 if [ "$res" -eq "0" ] ; then
184 LogIt "OK, I am running on a CD-ROM. Good." 3
185 CD_MOUNTED_OK=yes
186 elif [ "$res" -eq "1" ] ; then
187 LogIt "OK, I am running on floppies. Good." 3
188 CD_MOUNTED_OK=""
189 else
190 LogIt "OK, I am falling back to floppy mode." 3
191 LogIt "(You lay not have the right drivers" 3
192 LogIt "to support the hardware on which we are running)" 3
193 LogIt "That means you'll have to copy the data disk images from" 3
194 LogIt "the CD/hard disk/whatever to physical 1.44MB disks and" 3
195 LogIt "insert them, one after the other. Please see the manual." 3
196 LogIt "The images are in /images on the CD, or /root/images/mindi" 3
197 LogIt "on your hard disk. Your archives are probably fine but" 3
198 LogIt "your tape streamer and/or CD-ROM drive are eccentric. :-)" 3
199 CD_MOUNTED_OK=""
200 fi
201 return 0
202}
203
204
205HowMuchFreeSpaceOnRamdisk() {
206 df -m -P | grep /dev/ram | head -n1 | tr -s '\t' ' ' | cut -d' ' -f4
207}
208
209
210
211InsertEssentialModules() {
212# Load the VIA IDE module first thing if it exists (requires ide-core).
213# This is to ensure that DMA is working for VIA chipsets with 2.6 kernels.
214 for module in /ide-core.ko* /via82cxxx.ko*; do
215 [ -f "$module" ] && MyInsmod $module > /dev/null 2> /dev/null
216 done
217# Then load the remaining modules in normal (i.e. arbitrary) order.
218 for j in 1 2 3 4 5 ; do
219 for i in `ls /*.*o* 2> /dev/null` ; do
220 [ -f "$i" ] && MyInsmod $i > /dev/null 2> /dev/null
221 done
222 done
223}
224
225
226
227PauseForRaids() {
228 if [ "`dmesg | grep -i "RAID Controller"`" != "" ] || [ "`dmesg | grep -i "Vendor: 3ware"`" != "" ] ; then
229 LogIt "RAID controller(s) detected. Pausing 10 seconds to let them warm up." 1
230 echo -en "Pausing..."
231 for i in 1 2 3 4 5 6 7 8 9 10 ; do
232 sleep 1
233 echo -en "$(($i*10))%..."
234 done
235 echo "Done."
236 fi
237}
238
239
240# 06/13/2002 --- DuckX's & Hugo's new routine
241# 10/11/2003 --- added a simple devfsd.conf file
242# 01/24/2005 --- cater for arbitrary locations of devfsd.conf by using the
243# config file path compiled into devfsd
244RunDevfsd() {
245 loc=`which devfsd 2> /dev/null`
246 if [ "$loc" != "" ] ; then
247 LogIt "Devfs found. Testing kernel support..."
248 if [ ! -e "/dev/.devfsd" ] ; then
249 mount -t devfs devfs /dev 2>> $LOGFILE
250 if [ "$?" -ne "0" ] ; then
251 LogIt "Error while trying to mount devfs"
252 else
253 LogIt "Devfs mounted OK"
254 fi
255 fi
256 #check if the kernel supports devfs
257 if [ -e "/dev/.devfsd" ] ; then
258 [ -d "/proc/1" ] || mount -n /proc
259 LogIt "Kernel support found. Creating config file and starting devfsd"
260 conffile=`strings $loc | grep -E "devfsd.conf$"`
261 [ "$conffile" ] || conffile="/etc/devfsd.conf"
262 confpath=`echo $conffile | sed "s/\/devfsd\.conf$//"`
263 [ -d "$confpath" ] || mkdir -p $confpath
264 echo -en "REGISTER .* MKOLDCOMPAT\nUNREGISTER .* RMOLDCOMPAT\n" > $conffile
265 devfsd /dev &
266 sleep 5
267 else
268 LogIt "No devfs kernel support."
269 fi
270 fi
271}
272
273# Taken from udev management in Mandriva 2008.0. Kudos guys
274make_extra_nodes () {
275 # there are a few things that sysfs does not export for us.
276 # these things are listed in /etc/udev/links.conf
277 grep '^[^#]' /etc/udev-links.conf | \
278 while read type name arg1; do
279 [ "$type" -a "$name" -a ! -e "/dev/$name" -a ! -L "/dev/$name" ] ||continue
280 case "$type" in
281 L) ln -s $arg1 /dev/$name ;;
282 D) mkdir -p /dev/$name ;;
283 M) mknod /dev/$name $arg1 && chmod 600 /dev/$name;;
284 *) echo "udev-links.conf: unparseable line (%s %s %s)\n" "$type" "$name" "$arg1" ;;
285 esac
286 done
287}
288
289create_dev_makedev() {
290 if [ -e /sbin/MAKEDEV ]; then
291 ln -sf /sbin/MAKEDEV /dev/MAKEDEV
292 else
293 ln -sf /bin/true /dev/MAKEDEV
294 fi
295}
296
297RunUdevd() {
298 # Inspiration from Mandriva 2008.0 startup script
299 echo "Preparing udev environment..."
300 mv /dev /dev.static
301 mkdir /dev
302 mount -n -o size=5M,mode=0755 -t tmpfs none /dev
303 make_extra_nodes
304 mount -n -t devpts -o mode=620 none /dev/pts
305 mount -n -t tmpfs none /dev/shm
306 if [ -e /proc/sys/kernel/hotplug ]; then
307 echo > /proc/sys/kernel/hotplug
308 fi
309 PKLVL=`cut -f1 /proc/sys/kernel/printk`
310 echo 0 > /proc/sys/kernel/printk
311 if [ -x /sbin/startudev ]; then
312 /sbin/startudev
313 fi
314 # Depending on udevd version it gives back the hand or not :-(
315 /sbin/udevd --daemon &
316 sleep 2
317 mkdir -p /dev/.udev/queue/
318 if [ -x /sbin/udevtrigger ]; then
319 /sbin/udevtrigger
320 fi
321 create_dev_makedev
322 # May avoid shell error messages
323 chmod 644 /dev/tty*
324 if [ -x /sbin/udevsettle ]; then
325 /sbin/udevsettle
326 fi
327 # It seems we need to have more static devs on some distro were
328 # udev as some other requirements to be covered later on.
329 # So in the mean time:
330 for d in `ls /dev.static`; do
331 if [ ! -e /dev/$d ]; then
332 mv /dev.static/$d /dev
333 fi
334 done
335 echo $PKLVL > /proc/sys/kernel/printk
336}
337
338RstHW() {
339
340 # Restore the HW configuration if available (NOT by default)
341 answer="NO"
342
343 grep -q nohw /proc/cmdline
344 if [ "$?" -eq 0 ]; then
345 return
346 fi
347 if [ -x ./mindi-rsthw ]; then
348 grep -q RESTORE /proc/cmdline
349 if [ "$?" -ne 0 ]; then
350 #clear
351 echo "*********************************************************************"
352 echo "Do you want to restore the HW configuration of the original machine ?"
353 echo "(This may dammage your hardware so be sure to check twice before saying yes)"
354 echo "*********************************************************************"
355 echo "Please confirm by typing YES exactly as written here (NO by default)"
356 echo -n "--> "
357 read answer
358 else
359 answer="YES"
360 fi
361 if [ "$answer" -eq "YES" ] ; then
362 ./mindi-rsthw
363 fi
364 fi
365}
366
367
368#RunDevfsd() {
369# loc=`which devfsd 2> /dev/null`
370# if [ "$loc" != "" ] ; then
371# LogIt "Starting devfsd"
372# devfsd /dev &
373# sleep 5
374# fi
375#}
376
377
378
379SpaceTests() {
380 [ -e "/tmp/filelist.full" ] && cp /tmp/filelist.full /tmp/FLF
381 if [ "`HowMuchFreeSpaceOnRamdisk`" -le "3" ] ; then
382 LogIt "Ramdisk is a bit smaller than I would like." 1
383 LogIt "Please re-run Mondo/Mindi but edit /usr/local/mindi first" 1
384 LogIt "and set EXTRA_SPACE to something high, e.g. 8000" 1
385 Die "Aborting. Please reboot."
386 fi
387 rm -f /tmp/FLF
388}
389
390StartUSBKbd() {
391# Prepare minimal USB env in case we have USB kbd such as with iLO
392[ -d /proc/bus/usb ] && ! grep -q /proc/bus/usb /proc/mounts && mount -t usbfs none /proc/bus/usb
393if [ -e "/tmp/USE-UDEV" ] ; then
394 if [ -f uhcd_hci.ko ] || [ -f uhcd_hci.ko.gz ]; then
395 modprobe -q uhcd_hci
396 fi
397 if [ -f usbhid.ko ] || [ -f usbhid.ko.gz ]; then
398 modprobe -q usbhid
399 fi
400else
401 if [ -f uhcd_hci.ko ]; then
402 insmod uhcd_hci.ko
403 fi
404 if [ -f usbhid.ko ]; then
405 insmod usbcore.ko
406 insmod usbhid.ko
407 fi
408fi
409}
410
411
412
413StartLvms() {
414 if [ -e "/tmp/i-want-my-lvm" ] ; then
415 LogIt "Scanning LVM's..." 1
416 if which lvm ; then
417 MyInsmod dm-mod
418 MyInsmod dm_mod
419 lvm vgscan --mknodes
420 else
421 vgscan
422 fi
423 grep -E "^#.*vgchange" /tmp/i-want-my-lvm | sed "s/^#[ ]*//" > /tmp/start-lvm
424 chmod +x /tmp/start-lvm
425 echo -en "Starting LVM's..."
426 /tmp/start-lvm &
427 for i in 1 2 3 4 5 ; do
428 echo -en "."
429 sleep 1
430 done
431 echo "Done."
432 fi
433# If necessary, cannibalize 'analyze-my-lvm'; copy some of its code here,
434# pipe vgscan's output, strip it, run 'vgchange' on its output, etc.etc.
435 LogIt "LVM's have been started."
436}
437
438
439StartRaids() {
440 local raid_devices i
441
442 raid_devices=`grep /dev/md /tmp/mountlist.txt | cut -d' ' -f1`
443 if which raidstart > /dev/null 2> /dev/null ; then
444 for i in $raid_devices ; do
445 if grep `basename $i` /proc/mdstat > /dev/null 2> /dev/null ; then
446 LogIt "$i is started already; no need to run 'raidstart $i'" 1
447 else
448 LogIt "Running 'raidstart $i'" 1
449 raidstart $i
450 fi
451 done
452 elif which mdrun > /dev/null 2> /dev/null ; then
453 LogIt "Running 'mdrun'" 1
454 mdrun
455 elif which mdadm > /dev/null 2> /dev/null ; then
456 LogIt "Running 'mdadm'" 1
457 for i in $raid_devices ; do
458 if grep `basename $i` /proc/mdstat > /dev/null 2> /dev/null ; then
459 LogIt "$i is started already; no need to run 'mdadm $i'" 1
460 else
461 if [ -f /etc/mdadm.conf ] ; then
462 LogIt "Running 'mdadm $i' with user supplied /etc/mdadm.conf" 1
463 mdadm -A $i -c /etc/mdadm.conf
464 elif [ -f /etc/mdadm/mdadm.conf ] ; then
465 LogIt "Running 'mdadm $i' with user supplied /etc/mdadm/mdadm.conf" 1
466 mdadm -A $i -c /etc/mdadm/mdadm.conf
467 else
468 LogIt "Running 'mdadm $i'" 1
469 mdadm -Ac partitions -m dev $i
470 fi
471 fi
472 done
473 else
474 LogIt "Warning: Neither 'raidstart' nor 'mdrun''found. RAID devices may not have started." 1
475 fi
476
477}
478
479
480TryAgainToFindCD() {
481 local res
482 mount | grep /mnt/cdrom && return 0
483 [ "`grep "backup_media_type" /tmp/mondo-restore.cfg | grep "cdstream"`" ] && return
484 LogIt "Trying to mount CD-ROM a 2nd time..."
485 find-and-mount-cdrom --second-try
486 res=$?
487 if [ "$res" -eq "0" ] ; then
488 CD_MOUNTED_OK=yes
489 LogIt "CD-ROM drive mounted successfully." 1
490 else
491 LogIt "I still cannot find or mount the CD-ROM drive, by the way."
492 fi
493}
494
495
496
497UseTmpfs()
498{
499 local mount_cmd
500 echo -en "Mounting /tmp/tmpfs..."
501 mkdir -p /tmp/tmpfs
502# For technical reasons, some sets are as large as 16MB.
503# I am allowing 32MB because selective restore occupies a lot of space.
504 for size in 64m 48m 40m 32m ; do
505 mount_cmd="mount /dev/shm -t tmpfs -o size=$size" ; # was 34m until 04/2003
506 LogIt "Trying '$mount_cmd'"
507 $mount_cmd /tmp/tmpfs 2>> $LOGFILE
508 res=$?
509 [ "$res" -eq "0" ] && break
510 done
511 if [ "$res" -ne "0" ] ; then
512 LogIt "Failed. I could not run '$mount_cmd /tmp/tmpfs'. Your kernel is BROKEN or you do not have enough RAM." 1
513 umount /tmp/tmpfs > /dev/null 2> /dev/null
514 rmdir /tmp/tmpfs
515 ln -sf /mnt/RESTORING/tmp /tmp/tmpfs; # used by mondo-restore
516 LogIt "Failed to mount /tmp/tmpfs; using ugly softlink instead"
517 else
518 LogIt "Great. Pivot succeeded w/ size=$size" 1
519 echo -en "Pivoting /tmp..."
520 umount /tmp/tmpfs
521 mkdir -p /tmp.old
522 mv /tmp/* /tmp.old/
523 # Try to Deal with a busybox bug on inexistant links
524 cp /tmp/* /tmp.old/
525 rm -f /tmp/*
526 $mount_cmd /tmp
527 mv /tmp.old/* /tmp/
528 # Try to Deal with a busybox bug on inexistant links
529 cp /tmp.old/* /tmp/
530 rm -rf /tmp.old
531 mkdir -p /tmp/tmpfs
532 mkdir -p $GROOVY
533 echo "Done."
534 LogIt "Successfully mounted dynamic /tmp ramdisk"
535# mkdir -p /tmp/tmpfs/var
536# mv -f /var/log /tmp/tmpfs/var/log
537# ln -sf /tmp/tmpfs/var/log /var/log
538 fi
539}
540
541
542WelcomeMessage()
543{
544 export ARCH=`uname -m`
545
546 echo "********************************************************************"
547 echo "MINDI-LINUX by Mondo Dev Team - web site: http://www.mondorescue.org"
548 echo "Boot disk based on AlfaLinux & Trinux. BusyBox by Erik Andersen."
549which petris > /dev/null 2> /dev/null && echo "Petris was written by Peter Seidler <p.seidler@mail1.stofanet.dk>."
550 echo "Executables and source code are covered by the GNU GPL. No warranty."
551 echo "running on $ARCH"
552 echo "********************************************************************"
553}
554
555
556EnableCcissIfAppropriate() {
557 local i fname
558 for i in 0 1 2 3 ; do
559 fname="/proc/driver/cciss/cciss$i"
560 if [ -e "$fname" ] ; then
561 LogIt "Engaging $fname"
562 echo "engage scsi" > $fname
563 LogIt "...result=$?"
564 fi
565 done
566}
567
568ModprobeAllModules() {
569
570 for m in `find /lib/modules -name '*.ko*'`; do
571 j=`basename $m | sed 's/\.ko.*$//'`
572 modprobe -q $j
573 done
574}
575
576ExtractDataDisksAndLoadModules() {
577 echo "Installing additional tools ..."
578 install-additional-tools
579 # Keep the kernel silent again
580 PKLVL=`cut -f1 /proc/sys/kernel/printk`
581 echo 0 > /proc/sys/kernel/printk
582 if [ ! -e "/tmp/USE-UDEV" ] ; then
583 echo "Inserting modules ..."
584 insert-all-my-modules >> $LOGFILE 2>> $LOGFILE
585 else
586 ModprobeAllModules
587 fi
588 echo $PKLVL > /proc/sys/kernel/printk
589}
590
591# ------------------------ main -----------------------
592
593MINDI_VER=PBVER
594MINDI_REV=PBREV
595trap CaughtSoftReset SIGTERM
596LOGFILE=/var/log/mondorestore.log
597PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/mondo:/usr/games
598GROOVY=/tmp/groovy-stuff
599USER=root
600export PATH GROOVY USER LOGFILE
601
602echo "Welcome to init (from mindi ${MINDI_VER}-r${MINDI_REV})"
603
604mount -o remount rw /
605[ ! "$GROOVY" ] && Die "I'm not groovy!"
606for i in $GROOVY /mnt/floppy /mnt/cdrom /mnt/isodir /var/local/petris /tmp/isodir; do
607 mkdir -p $i
608done
609#/bin/update
610mount /proc/ /proc -v -t proc
611mkdir /sys 2> /dev/null
612mount /sys/ /sys -v -t sysfs 2>> $LOGFILE
613# For ESX 3
614[ -d /proc/vmware ] && ! grep -q /vmfs /proc/mounts && mount -t vmfs /vmfs /vmfs
615rm -f /foozero
616
617echo "Activating a potential USB keyboard/mouse"
618StartUSBKbd
619
620if [ -f /proc/sys/kernel/exec-shield ]; then
621 echo 0 > /proc/sys/kernel/exec-shield 2>> /dev/null
622fi
623
624if [ -f /proc/modules ]; then
625 echo "/sbin/modprobe" > /proc/sys/kernel/modprobe
626fi
627
628if [ -e "/tmp/USE-UDEV" ] ; then
629 RunUdevd
630fi
631ExtractDevTarballs
632LaunchTerminals
633
634# Keeping kernel silent for module insertion
635PKLVL=`cut -f1 /proc/sys/kernel/printk`
636echo 0 > /proc/sys/kernel/printk
637if [ ! -e "/tmp/USE-UDEV" ] ; then
638 InsertEssentialModules
639else
640 ModprobeAllModules
641fi
642echo $PKLVL > /proc/sys/kernel/printk
643
644EnableCcissIfAppropriate
645#-------------------------------
646#WHOLIVESINAPINEAPPLEUNDERTHESEA#;# --- don't touch this :)
647#-------------------------------
648UseTmpfs
649if [ ! -e "/tmp/mondo-restore.cfg" ] ; then
650 LogIt "Warning - /tmp/mondo-restore.cfg not found"
651fi
652
653if [ "`grep -i 'tape ' /tmp/mondo-restore.cfg`" ] || [ "`grep -i udev /tmp/mondo-restore.cfg`" ]; then
654 HandleTape
655 ExtractDataDisksAndLoadModules
656elif [ "`grep -i pxe /proc/cmdline`" ]; then
657 # We need to get here exported variables from start-nfs
658 . /sbin/start-nfs
659
660 # Simulate a local CD
661 echo "/mnt/cdrom" > /tmp/CDROM-LIVES-HERE
662 CD_MOUNTED_OK=yes
663 ExtractDataDisksAndLoadModules
664elif [ "`grep -i usb= /proc/cmdline`" ] || [ "`grep -i usb /tmp/mondo-restore.cfg | grep media-type`" ]; then
665 # We need to get here exported variables from start-nfs
666 . /sbin/start-usb
667
668 # Simulate a local CD
669 echo "/mnt/cdrom" > /tmp/CDROM-LIVES-HERE
670 CD_MOUNTED_OK=yes
671 ExtractDataDisksAndLoadModules
672else
673 HandleCDROMorFloppies
674 ExtractDataDisksAndLoadModules
675 # We need to get here exported variables from start-nfs
676 . /sbin/start-nfs
677fi
678res=$?
679ConfigureLoggingDaemons
680if [ -e "/tmp/USE-DEVFS" ] ; then
681 umount /mnt/cdrom 2> /dev/null
682 mv /dev/cdrom /cdrom.lnk 2> /dev/null
683 CD_MOUNTED_OK=""
684 RunDevfsd
685fi
686LoadKeymap
687WelcomeMessage
688RstHW
689echo "Starting potential Raid/LVMs ..."
690PauseForRaids
691StartRaids
692StartLvms
693CopyBootDevEntry
694mkdir -p /tmp/tmpfs
695sleep 2
696#clear
697if [ -e "/dev/md0" ] && [ ! -e "/dev/md/0" ] && [ "`grep /dev/md/ /tmp/mountlist.txt`" != "" ] ; then
698 LogIt "Creating /dev/md/* softlinks just in case." 1
699 mkdir -p /dev/md
700 cp -af /dev/md0 /dev/md/0 2> /dev/null
701 cp -af /dev/md1 /dev/md/1 2> /dev/null
702 cp -af /dev/md2 /dev/md/2 2> /dev/null
703fi
704# SpaceTests; # Mandrake Linux 8.1 doesn't like this
705[ -e "/tmp/mountlist.txt" ] && cp -f /tmp/mountlist.txt /tmp/mountlist.original
706
707if ! [ "`grep -i "pxe" /proc/cmdline`" ] ; then
708 res="`cat /mnt/cdrom/archives/THIS-CD-NUMBER 2> /dev/null`"
709 [ "$res" != "1" ] && [ "$res" != "" ] && Die "This is CD #$res in the series. Please insert CD #1."
710 [ -e "/cdrom.lnk" ] && mv -f /cdrom.lnk /dev/cdrom && mount /dev/cdrom /mnt/cdrom && CD_MOUNTED_OK=yes
711 [ "$CD_MOUNTED_OK" != "yes" ] && TryAgainToFindCD
712 #mount | grep cdrom > /dev/null 2> /dev/null || mount /dev/cdrom /mnt/cdrom >> $LOGFILE 2>> $LOGFILE
713fi
714hack-cfg-if-necessary || LogIt "Cannot find hack-cfg-if-necessary"
715
716# Log some useful info
717LogIt "init (from mindi v$MINDI_VER-r${MINDI_REV}"
718LogIt "/proc/cmdline is:"
719cat /proc/cmdline >> $LOGFILE
720LogIt "df result:"
721LogIt "----------"
722df >> $LOGFILE
723LogIt "-------------"
724LogIt "mount result:"
725LogIt "-------------"
726mount >> $LOGFILE
727LogIt "-------------"
728LogIt "lsmod result:"
729LogIt "-------------"
730lsmod >> $LOGFILE
731LogIt "-------------"
732LogIt "dmesg result:"
733LogIt "-------------"
734dmesg >> $LOGFILE
735
736#-------------------------------
737#ABSORBENTANDYELLOWANDPOROUSISHE#;# --- don't touch this either :)
738#-------------------------------
739
740#ctrlaltdel soft
741for path in /usr.bin /usr/bin ; do
742 fname=$path/nano
743 [ -e "$fname" ] && ln -sf $fname /usr/bin/pico
744done
745res=`which nano 2> /dev/null`
746[ "$res" ] && ln -sf /usr/bin/
747for i in null stdout stdin stderr ; do
748 cp -af /dev/$i /tmp
749done
750if grep "backup-media-type" /tmp/mondo-restore.cfg > /dev/null 2> /dev/null ; then
751 LogIt "backup-media-type is specified in config file - great."
752 LogIt "Calling post-init $mountlist"
753 post-init
754else
755 LogIt "backup-media-type is not specified in config file."
756 LogIt "I think this CD/floppy has no archives on it."
757fi
758if grep "RESTORE" /proc/cmdline > /dev/null 2> /dev/null ; then
759 echo "Rebooting in 10 seconds automatically as per reboot order"
760 echo -en "Press ^C to interrupt if you have to ..."
761 for i in 1 2 3 4 5 6 7 8 9 10 ; do
762 sleep 1
763 echo -en "."
764 done
765 echo "Boom."
766 sleep 1
767else
768 echo -en "Type 'exit' to reboot the PC\n"
769 umount /mnt/cdrom 2> /dev/null
770 mount / -o rw,remount > /dev/null 2> /dev/null
771 LogIt "Launching Shell"
772 sh
773fi
774CaughtSoftReset
775# reboot
Note: See TracBrowser for help on using the repository browser.