source: branches/2.2.7/mindi/rootfs/sbin/init @ 2015

Last change on this file since 2015 was 2015, checked in by Bruno Cornec, 12 years ago

Improve logging by adding some /proc content both at backup and restore time

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