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

Last change on this file since 1815 was 1815, checked in by Bruno Cornec, 13 years ago
  • Increase BOOT_SIZE and EXTRA_SIZE to support features such as HW recovery
  • Handles udev.files files which could be symlinks
  • Improve udev support for distro with compressed modules (mdv e.g.)
  • Fix modules.dep copy
  • /sbin/pam_console_apply is needed by mdv udev conf
  • Adds support for nohw boot option to avoid re-setuping the HW conf
  • Property svn:keywords set to Id
File size: 19.4 KB
Line 
1#!/bin/sh
2#
3# $Id: init 1815 2007-11-19 12:13: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    openvt S0 /bin/sh
82    openvt S1 /bin/sh
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#    tar -zxf $tapedev
108    dd if=$tapedev bs=32k count=1024 | tar -zx
109    res=$?
110    if [ "$res" -eq "0" ] ; then
111        grep -v media-dev /tmp/mondo-restore.cfg > /tmp/mr.cfg
112        echo "media-dev $tapedev" >> /tmp/mr.cfg
113        cp -f /tmp/mr.cfg /tmp/mondo-restore.cfg
114    fi
115    cd $old_pwd
116    return $res
117}
118
119HandleTape() {
120    local res tapedev
121    tapedev="" ; # will be set by UntarTapeStuff()
122    cd $GROOVY
123    UntarTapeStuff $tapedev || UntarTapeStuff /dev/st0 || UntarTapeStuff /dev/osst0 || UntarTapeStuff /dev/ht0
124    res=$?
125    while [ "$res" -ne "0" ] ; do
126        LogIt "$tapedev failed to act as extended data disk for booting." 1
127        LogIt "Please specify an alternate tape device," 1
128        LogIt "or hit <Enter> to boot from CD/floppies." 1
129        echo -en "---> "
130        read tapedev
131        if [ "$tapedev" ] ; then
132            LogIt "User specified $tapedev instead"
133            UntarTapeStuff $tapedev
134            res=$?
135        else
136            LogIt "User opted not to specify an alternate tapedev"
137            res=1
138        break
139        fi
140    done
141
142    if [ "$res" -ne "0" ] ; then
143        cd /
144        LogIt "Failed to use tape as extended datadisk. Reverting to floppies." 1
145        HandleCDROMorFloppies
146        res=$?
147    else
148#       clear
149        LogIt "Using tape as extended datadisk. Good." 3
150        echo "Using tape as extd ddisk." > /tmp/TAPEDEV-HAS-DATA-DISKS
151        res=0
152        CD_MOUNTED_OK=yes
153    fi
154    return $res
155}
156
157
158
159HandleCDROMorFloppies() {
160    find-and-mount-cdrom
161    res=$?
162    if [ "$res" -ne "0" ] ; then
163        LogIt "First call to find-and-mount-cdrom failed." 1
164        LogIt "Sleeping for 3 seconds and trying again." 1
165        sleep 3
166        find-and-mount-cdrom
167        res=$?
168    fi
169    if [ "$res" -eq "0" ] ; then
170        LogIt "OK, I am running on a CD-ROM. Good." 3
171        CD_MOUNTED_OK=yes
172    elif [ "$res" -eq "1" ] ; then
173        LogIt "OK, I am running on floppies. Good." 3
174        CD_MOUNTED_OK=""
175    else
176        LogIt "OK, I am falling back to floppy mode." 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    echo $PKLVL > /proc/sys/kernel/printk
307    # May avoid shell error messages
308    chmod 644 /dev/tty*
309    udevsettle
310}
311
312RstHW() {
313
314    # Restore the HW configuration if available (NOT by default)
315    answer="NO"
316
317    grep -q nohw /proc/cmdline
318    if [ "$?" -eq 0 ]; then
319        return
320    fi
321    if [ -x ./mindi-rsthw ]; then
322        grep -q RESTORE /proc/cmdline
323        if [ "$?" -ne 0 ]; then
324            #clear
325            echo "*********************************************************************"
326            echo "Do you want to restore the HW configuration of the original machine ?"
327            echo "(This may dammage your hardware so be sure to check twice before saying yes)"
328            echo "*********************************************************************"
329            echo "Please confirm by typing YES exactly as written here (NO by default)"
330            echo -n "--> "
331            read answer
332        else
333            answer="YES"
334        fi
335        if [ "$answer" -eq "YES" ] ; then
336            ./mindi-rsthw
337        fi
338    fi
339}
340
341
342#RunDevfsd() {
343#    loc=`which devfsd 2> /dev/null`
344#    if [ "$loc" != "" ] ; then
345#        LogIt "Starting devfsd"
346#        devfsd /dev &
347#        sleep 5
348#    fi
349#}
350
351
352
353SpaceTests() {
354    [ -e "/tmp/filelist.full" ] && cp /tmp/filelist.full /tmp/FLF
355    if [ "`HowMuchFreeSpaceOnRamdisk`" -le "3" ] ; then
356        LogIt "Ramdisk is a bit smaller than I would like." 1
357        LogIt "Please re-run Mondo/Mindi but edit /usr/local/mindi first" 1
358        LogIt "and set EXTRA_SPACE to something high, e.g. 8000" 1
359        Die "Aborting. Please reboot."
360    fi
361    rm -f /tmp/FLF
362}
363
364StartUSBKbd() {
365# Prepare minimal USB env in case we have USB kbd such as with iLO
366[ -d /proc/bus/usb ] && ! grep -q /proc/bus/usb /proc/mounts && mount -t usbfs none /proc/bus/usb
367if [ -e "/tmp/USE-UDEV" ] ; then
368    if [ -f usbhid.ko || -f usbhid.ko.gz ]; then
369        modprobe -q usbhid
370    fi
371    if [ -f uhcd_hci.ko || -f uhcd_hci.ko.gz ]; then
372        modprobe -q uhcd_hci
373    fi
374else
375    if [ -f uhcd_hci.ko ]; then
376        insmod uhcd_hci.ko*
377    fi
378    if [ -f usbhid.ko ]; then
379        insmod usbcore.ko*
380        insmod usbhid.ko*
381    fi
382fi
383}
384
385
386
387StartLvms() {
388    if [ -e "/tmp/i-want-my-lvm" ] ; then
389        LogIt "Scanning LVM's..." 1
390        if which lvm ; then
391            MyInsmod dm-mod
392            MyInsmod dm_mod
393            lvm vgscan --mknodes
394        else
395            vgscan
396        fi
397        grep -E "^#.*vgchange" /tmp/i-want-my-lvm | sed "s/^#[ ]*//" > /tmp/start-lvm
398        chmod +x /tmp/start-lvm
399        echo -en "Starting LVM's..."
400        /tmp/start-lvm &
401        for i in 1 2 3 4 5 ; do
402            echo -en "."
403            sleep 1
404        done
405        echo "Done."
406    fi
407# If necessary, cannibalize 'analyze-my-lvm'; copy some of its code here,
408# pipe vgscan's output, strip it, run 'vgchange' on its output, etc.etc.
409    LogIt "LVM's have been started."
410}
411
412
413StartRaids() {
414    local raid_devices i
415
416    raid_devices=`grep /dev/md /tmp/mountlist.txt | cut -d' ' -f1`
417    if which raidstart > /dev/null 2> /dev/null ; then
418        for i in $raid_devices ; do
419            if grep `basename $i` /proc/mdstat > /dev/null 2> /dev/null ; then
420                LogIt "$i is started already; no need to run 'raidstart $i'" 1
421            else
422                LogIt "Running 'raidstart $i'" 1
423                raidstart $i
424            fi
425        done
426    elif which mdrun > /dev/null 2> /dev/null ; then
427        LogIt "Running 'mdrun'" 1
428        mdrun
429    elif which mdadm > /dev/null 2> /dev/null ; then
430        LogIt "Running 'mdadm'" 1
431        for i in $raid_devices ; do
432            if grep `basename $i` /proc/mdstat > /dev/null 2> /dev/null ; then
433                LogIt "$i is started already; no need to run 'mdadm $i'" 1
434            else
435                if [ -f /etc/mdadm.conf ] ; then
436                    LogIt "Running 'mdadm $i' with user supplied /etc/mdadm.conf" 1
437                    mdadm -A $i -c /etc/mdadm.conf
438                elif [ -f /etc/mdadm/mdadm.conf ] ; then
439                    LogIt "Running 'mdadm $i' with user supplied /etc/mdadm/mdadm.conf" 1
440                    mdadm -A $i -c /etc/mdadm/mdadm.conf
441                else
442                    LogIt "Running 'mdadm $i'" 1
443                    mdadm -Ac partitions -m dev $i
444                fi
445            fi
446        done
447    else
448        LogIt "Warning: Neither 'raidstart' nor 'mdrun''found. RAID devices may not have started." 1
449    fi
450
451}
452
453
454TryAgainToFindCD() {
455    local res
456    mount | grep /mnt/cdrom && return 0
457    [ "`grep "backup_media_type" /tmp/mondo-restore.cfg | grep "cdstream"`" ] && return
458    LogIt "Trying to mount CD-ROM a 2nd time..."
459    find-and-mount-cdrom --second-try
460    res=$?
461    if [ "$res" -eq "0" ] ; then
462        CD_MOUNTED_OK=yes
463        LogIt "CD-ROM drive mounted successfully." 1
464    else
465        LogIt "I still cannot find or mount the CD-ROM drive, by the way."
466    fi
467}
468
469
470
471UseTmpfs()
472{
473    local mount_cmd
474    echo -en "Mounting /tmp/tmpfs..."
475    mkdir -p /tmp/tmpfs
476# For technical reasons, some sets are as large as 16MB.
477# I am allowing 32MB because selective restore occupies a lot of space.
478    for size in 64m 48m 40m 32m ; do
479        mount_cmd="mount /dev/shm -t tmpfs -o size=$size" ; # was 34m until 04/2003
480        LogIt "Trying '$mount_cmd'"
481        $mount_cmd /tmp/tmpfs 2>> $LOGFILE
482        res=$?
483        [ "$res" -eq "0" ] && break
484    done
485    if [ "$res" -ne "0" ] ; then
486        LogIt "Failed. I could not run '$mount_cmd /tmp/tmpfs'. Your kernel is BROKEN or you do not have enough RAM." 1
487        umount /tmp/tmpfs > /dev/null 2> /dev/null
488        rmdir /tmp/tmpfs
489        ln -sf /mnt/RESTORING/tmp /tmp/tmpfs; # used by mondo-restore
490        LogIt "Failed to mount /tmp/tmpfs; using ugly softlink instead"
491    else
492        LogIt "Great. Pivot succeeded w/ size=$size" 1
493        echo -en "Pivoting /tmp..."
494        umount /tmp/tmpfs
495        mkdir -p /tmp.old
496        mv /tmp/* /tmp.old/
497        # Try to Deal with a busybox bug on inexistant links
498        cp /tmp/* /tmp.old/
499        rm -f /tmp/*
500        $mount_cmd /tmp
501        mv /tmp.old/* /tmp/
502        # Try to Deal with a busybox bug on inexistant links
503        cp /tmp.old/* /tmp/
504        rm -rf /tmp.old
505        mkdir -p /tmp/tmpfs
506        mkdir -p $GROOVY
507    echo "Done."
508    LogIt "Successfully mounted dynamic /tmp ramdisk"
509#   mkdir -p /tmp/tmpfs/var
510#        mv -f /var/log /tmp/tmpfs/var/log
511#        ln -sf /tmp/tmpfs/var/log /var/log
512    fi
513}
514
515
516WelcomeMessage()
517{
518    export ARCH=`uname -m`
519
520    echo "********************************************************************"
521    echo "MINDI-LINUX by Mondo Dev Team - web site: http://www.mondorescue.org"
522    echo "Boot disk based on AlfaLinux & Trinux. BusyBox by Erik Andersen."
523which petris > /dev/null 2> /dev/null && echo "Petris was written by Peter Seidler <p.seidler@mail1.stofanet.dk>."
524    echo "Executables and source code are covered by the GNU GPL. No warranty."
525    echo "running on $ARCH"
526    echo "********************************************************************"
527}
528
529
530EnableCcissIfAppropriate() {
531    local i fname
532    for i in 0 1 2 3 ; do
533        fname="/proc/driver/cciss/cciss$i"
534        if [ -e "$fname" ] ; then
535            LogIt "Engaging $fname"
536            echo "engage scsi" > $fname
537            LogIt "...result=$?"
538        fi
539    done
540}
541
542ModprobeAllModules() {
543
544    for m in *.ko*; do
545        j=`echo $m | sed 's/\.ko.*$//'`
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    if [ ! -e "/tmp/USE-UDEV" ] ; then
557        echo "Inserting modules ..."
558        insert-all-my-modules >> $LOGFILE 2>> $LOGFILE
559    else
560        ModprobeAllModules
561    fi
562    echo $PKLVL > /proc/sys/kernel/printk
563}
564
565# ------------------------ main -----------------------
566
567MINDI_VER=PBVER
568MINDI_REV=PBREV
569trap CaughtSoftReset SIGTERM
570LOGFILE=/var/log/mondorestore.log
571PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/mondo:/usr/games
572GROOVY=/tmp/groovy-stuff
573USER=root
574export PATH GROOVY USER LOGFILE
575
576echo "Welcome to init (from mindi ${MINDI_VER}-r${MINDI_REV})"
577
578mount -o remount rw /
579[ ! "$GROOVY" ] && Die "I'm not groovy!"
580for i in $GROOVY /mnt/floppy /mnt/cdrom /mnt/isodir /var/local/petris /tmp/isodir; do
581    mkdir -p $i
582done
583#/bin/update
584mount /proc/ /proc -v -t proc
585mkdir /sys 2> /dev/null
586mount /sys/ /sys -v -t sysfs 2>> $LOGFILE
587rm -f /foozero
588
589StartUSBKbd
590
591if [ -f /proc/sys/kernel/exec-shield ]; then
592    echo 0 > /proc/sys/kernel/exec-shield 2>> /dev/null
593fi
594
595if [ -f /proc/modules ]; then
596    echo "/sbin/modprobe" > /proc/sys/kernel/modprobe
597fi
598
599if [ -e "/tmp/USE-UDEV" ] ; then
600    RunUdevd
601fi
602ExtractDevTarballs
603LaunchTerminals
604
605# Keeping kernel silent  for module insertion
606PKLVL=`cut -f1 /proc/sys/kernel/printk`
607echo 0 > /proc/sys/kernel/printk
608if [ ! -e "/tmp/USE-UDEV" ] ; then
609    InsertEssentialModules
610else
611    ModprobeAllModules
612fi
613echo $PKLVL > /proc/sys/kernel/printk
614
615EnableCcissIfAppropriate
616#-------------------------------
617#WHOLIVESINAPINEAPPLEUNDERTHESEA#;# --- don't touch this :)
618#-------------------------------
619UseTmpfs
620if [ ! -e "/tmp/mondo-restore.cfg" ] ; then
621    LogIt "Warning - /tmp/mondo-restore.cfg not found"
622fi
623
624if [ "`grep -i 'tape ' /tmp/mondo-restore.cfg`" ] || [ "`grep -i udev /tmp/mondo-restore.cfg`" ]; then
625    HandleTape
626    ExtractDataDisksAndLoadModules
627elif [ "`grep -i pxe /proc/cmdline`" ]; then
628    # We need to get here exported variables from start-nfs
629    . /sbin/start-nfs
630
631    # Simulate a local CD
632    echo "/mnt/cdrom" > /tmp/CDROM-LIVES-HERE
633    CD_MOUNTED_OK=yes
634    ExtractDataDisksAndLoadModules
635elif [ "`grep -i usb= /proc/cmdline`" ] || [ "`grep -i usb /tmp/mondo-restore.cfg | grep media-type`" ]; then
636    # We need to get here exported variables from start-nfs
637    . /sbin/start-usb
638
639    # Simulate a local CD
640    echo "/mnt/cdrom" > /tmp/CDROM-LIVES-HERE
641    CD_MOUNTED_OK=yes
642    ExtractDataDisksAndLoadModules
643else
644    HandleCDROMorFloppies
645    ExtractDataDisksAndLoadModules
646    # We need to get here exported variables from start-nfs
647    . /sbin/start-nfs
648fi
649res=$?
650ConfigureLoggingDaemons
651if [ -e "/tmp/USE-DEVFS" ] ; then
652    umount /mnt/cdrom 2> /dev/null
653    mv /dev/cdrom /cdrom.lnk 2> /dev/null
654    CD_MOUNTED_OK=""
655    RunDevfsd
656fi
657LoadKeymap
658WelcomeMessage
659RstHW
660echo "Starting potential Raid/LVMs ..."
661PauseForRaids
662StartRaids
663StartLvms
664CopyBootDevEntry
665mkdir -p /tmp/tmpfs
666sleep 2
667#clear
668if [ -e "/dev/md0" ] && [ ! -e "/dev/md/0" ] && [ "`grep /dev/md/ /tmp/mountlist.txt`" != "" ] ; then
669    LogIt "Creating /dev/md/* softlinks just in case." 1
670    mkdir -p /dev/md
671    cp -af /dev/md0 /dev/md/0 2> /dev/null
672    cp -af /dev/md1 /dev/md/1 2> /dev/null
673    cp -af /dev/md2 /dev/md/2 2> /dev/null
674fi
675# SpaceTests; # Mandrake Linux 8.1 doesn't like this
676[ -e "/tmp/mountlist.txt" ] && cp -f /tmp/mountlist.txt /tmp/mountlist.original
677
678if ! [ "`grep -i "pxe" /proc/cmdline`" ] ; then
679    res="`cat /mnt/cdrom/archives/THIS-CD-NUMBER 2> /dev/null`"
680    [ "$res" != "1" ] && [ "$res" != "" ] && Die "This is CD #$res in the series. Please insert CD #1."
681    [ -e "/cdrom.lnk" ] && mv -f /cdrom.lnk /dev/cdrom && mount /dev/cdrom /mnt/cdrom && CD_MOUNTED_OK=yes
682    [ "$CD_MOUNTED_OK" != "yes" ] && TryAgainToFindCD
683    #mount | grep cdrom > /dev/null 2> /dev/null || mount /dev/cdrom /mnt/cdrom >> $LOGFILE 2>> $LOGFILE
684fi
685hack-cfg-if-necessary || LogIt "Cannot find hack-cfg-if-necessary"
686
687# Log some useful info
688LogIt "init (from mindi v$MINDI_VER-r${MINDI_REV}"
689LogIt "/proc/cmdline is:"
690cat /proc/cmdline  >> $LOGFILE
691LogIt "df result:"
692LogIt "----------"
693df >> $LOGFILE
694LogIt "-------------"
695LogIt "mount result:"
696LogIt "-------------"
697mount >> $LOGFILE
698LogIt "-------------"
699LogIt "lsmod result:"
700LogIt "-------------"
701lsmod >> $LOGFILE
702LogIt "-------------"
703LogIt "dmesg result:"
704LogIt "-------------"
705dmesg >> $LOGFILE
706
707#-------------------------------
708#ABSORBENTANDYELLOWANDPOROUSISHE#;# --- don't touch this either :)
709#-------------------------------
710
711#ctrlaltdel soft
712for path in /usr.bin /usr/bin ; do
713    fname=$path/nano
714    [ -e "$fname" ] && ln -sf $fname /usr/bin/pico
715done
716res=`which nano 2> /dev/null`
717[ "$res" ] && ln -sf /usr/bin/
718for i in null stdout stdin stderr ; do
719    cp -af /dev/$i /tmp
720done
721if grep "backup-media-type" /tmp/mondo-restore.cfg > /dev/null 2> /dev/null ; then
722    LogIt "backup-media-type is specified in config file - great."
723    LogIt "Calling post-init $mountlist"
724    post-init
725else
726    LogIt "backup-media-type is not specified in config file."
727    LogIt "I think this CD/floppy has no archives on it."
728fi
729if grep "RESTORE" /proc/cmdline > /dev/null 2> /dev/null ; then
730    echo "Rebooting in 10 seconds automatically as per reboot order"
731    echo -en "Press ^C to interrupt if you have to ..."
732    for i in 1 2 3 4 5 6 7 8 9 10 ; do
733        sleep 1
734        echo -en "."
735    done
736    echo "Boom."
737    sleep 1
738else
739    echo -en "Type 'exit' to reboot the PC\n"
740    umount /mnt/cdrom 2> /dev/null
741    mount / -o rw,remount > /dev/null 2> /dev/null
742    LogIt "Launching Shell"
743    sh
744fi
745CaughtSoftReset
746# reboot
Note: See TracBrowser for help on using the repository browser.