source: branches/2.2.5/mindi/rootfs/sbin/init @ 1820

Last change on this file since 1820 was 1820, checked in by bruno, 12 years ago

Attempt to fix the lack of modules loaded at restore time - especially fs device drivers

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