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

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