source: branches/2.2.6/mindi/rootfs/sbin/init @ 1962

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