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

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

RstHW should be called after driver initialization

  • Property svn:keywords set to Id
File size: 19.3 KB
Line 
1#!/bin/sh
2#
3# $Id: init 1813 2007-11-17 15:28:42Z 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    if [ -x ./mindi-rsthw ]; then
318        grep -q RESTORE /proc/cmdline
319        if [ "$?" -ne 0 ]; then
320            clear
321            echo "*********************************************************************"
322            echo "Do you want to restore the HW configuration of the original machine ?"
323            echo "(This may dammage your hardware so be sure to check twice before saying yes)"
324            echo "*********************************************************************"
325            echo "Please confirm by typing YES exactly as written here (NO by default)"
326            echo -n "--> "
327            read answer
328        else
329            answer="YES"
330        fi
331        if [ "$answer" -eq "YES" ] ; then
332            ./mindi-rsthw
333        fi
334    fi
335}
336
337
338#RunDevfsd() {
339#    loc=`which devfsd 2> /dev/null`
340#    if [ "$loc" != "" ] ; then
341#        LogIt "Starting devfsd"
342#        devfsd /dev &
343#        sleep 5
344#    fi
345#}
346
347
348
349SpaceTests() {
350    [ -e "/tmp/filelist.full" ] && cp /tmp/filelist.full /tmp/FLF
351    if [ "`HowMuchFreeSpaceOnRamdisk`" -le "3" ] ; then
352        LogIt "Ramdisk is a bit smaller than I would like." 1
353        LogIt "Please re-run Mondo/Mindi but edit /usr/local/mindi first" 1
354        LogIt "and set EXTRA_SPACE to something high, e.g. 8000" 1
355        Die "Aborting. Please reboot."
356    fi
357    rm -f /tmp/FLF
358}
359
360StartUSBKbd() {
361# Prepare minimal USB env in case we have USB kbd such as with iLO
362[ -d /proc/bus/usb ] && ! grep -q /proc/bus/usb /proc/mounts && mount -t usbfs none /proc/bus/usb
363if [ -e "/tmp/USE-UDEV" ] ; then
364    if [ -f usbhid.ko ]; then
365        modprobe -q usbhid
366    fi
367    if [ -f uhcd_hci.ko ]; then
368        modprobe -q uhcd_hci
369    fi
370else
371    if [ -f uhcd_hci.ko ]; then
372        insmod uhcd_hci.ko
373    fi
374    if [ -f usbhid.ko ]; then
375        insmod usbcore.ko
376        insmod usbhid.ko
377    fi
378fi
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            MyInsmod dm-mod
388            MyInsmod 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 | 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 *.ko; do
541        j=`echo $m | sed 's/\.ko$//'`
542        if [ -e $j ]; then
543            modprobe -q $j
544        fi
545    done
546}
547
548ExtractDataDisksAndLoadModules() {
549    echo "Installing additional tools ..."
550    install-additional-tools
551    # Keep the kernel silent again
552    PKLVL=`cut -f1 /proc/sys/kernel/printk`
553    echo 0 > /proc/sys/kernel/printk
554    if [ ! -e "/tmp/USE-UDEV" ] ; then
555        echo "Inserting modules ..."
556        insert-all-my-modules >> $LOGFILE 2>> $LOGFILE
557    else
558        ModprobeAllModules
559    fi
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/floppy /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
585rm -f /foozero
586
587StartUSBKbd
588
589if [ -f /proc/sys/kernel/exec-shield ]; then
590    echo 0 > /proc/sys/kernel/exec-shield 2>> /dev/null
591fi
592
593if [ -f /proc/modules ]; then
594    echo "/sbin/modprobe" > /proc/sys/kernel/modprobe
595fi
596
597if [ -e "/tmp/USE-UDEV" ] ; then
598    RunUdevd
599fi
600ExtractDevTarballs
601LaunchTerminals
602
603# Keeping kernel silent  for module insertion
604PKLVL=`cut -f1 /proc/sys/kernel/printk`
605echo 0 > /proc/sys/kernel/printk
606if [ ! -e "/tmp/USE-UDEV" ] ; then
607    InsertEssentialModules
608else
609    ModprobeAllModules
610fi
611echo $PKLVL > /proc/sys/kernel/printk
612
613EnableCcissIfAppropriate
614#-------------------------------
615#WHOLIVESINAPINEAPPLEUNDERTHESEA#;# --- don't touch this :)
616#-------------------------------
617UseTmpfs
618if [ ! -e "/tmp/mondo-restore.cfg" ] ; then
619    LogIt "Warning - /tmp/mondo-restore.cfg not found"
620fi
621
622if [ "`grep -i 'tape ' /tmp/mondo-restore.cfg`" ] || [ "`grep -i udev /tmp/mondo-restore.cfg`" ]; then
623    HandleTape
624    ExtractDataDisksAndLoadModules
625elif [ "`grep -i pxe /proc/cmdline`" ]; then
626    # We need to get here exported variables from start-nfs
627    . /sbin/start-nfs
628
629    # Simulate a local CD
630    echo "/mnt/cdrom" > /tmp/CDROM-LIVES-HERE
631    CD_MOUNTED_OK=yes
632    ExtractDataDisksAndLoadModules
633elif [ "`grep -i usb= /proc/cmdline`" ] || [ "`grep -i usb /tmp/mondo-restore.cfg | grep media-type`" ]; then
634    # We need to get here exported variables from start-nfs
635    . /sbin/start-usb
636
637    # Simulate a local CD
638    echo "/mnt/cdrom" > /tmp/CDROM-LIVES-HERE
639    CD_MOUNTED_OK=yes
640    ExtractDataDisksAndLoadModules
641else
642    HandleCDROMorFloppies
643    ExtractDataDisksAndLoadModules
644    # We need to get here exported variables from start-nfs
645    . /sbin/start-nfs
646fi
647res=$?
648ConfigureLoggingDaemons
649if [ -e "/tmp/USE-DEVFS" ] ; then
650    umount /mnt/cdrom 2> /dev/null
651    mv /dev/cdrom /cdrom.lnk 2> /dev/null
652    CD_MOUNTED_OK=""
653    RunDevfsd
654fi
655LoadKeymap
656WelcomeMessage
657RstHW
658echo "Starting potential Raid/LVMs ..."
659PauseForRaids
660StartRaids
661StartLvms
662CopyBootDevEntry
663mkdir -p /tmp/tmpfs
664sleep 2
665#clear
666if [ -e "/dev/md0" ] && [ ! -e "/dev/md/0" ] && [ "`grep /dev/md/ /tmp/mountlist.txt`" != "" ] ; then
667    LogIt "Creating /dev/md/* softlinks just in case." 1
668    mkdir -p /dev/md
669    cp -af /dev/md0 /dev/md/0 2> /dev/null
670    cp -af /dev/md1 /dev/md/1 2> /dev/null
671    cp -af /dev/md2 /dev/md/2 2> /dev/null
672fi
673# SpaceTests; # Mandrake Linux 8.1 doesn't like this
674[ -e "/tmp/mountlist.txt" ] && cp -f /tmp/mountlist.txt /tmp/mountlist.original
675
676if ! [ "`grep -i "pxe" /proc/cmdline`" ] ; then
677    res="`cat /mnt/cdrom/archives/THIS-CD-NUMBER 2> /dev/null`"
678    [ "$res" != "1" ] && [ "$res" != "" ] && Die "This is CD #$res in the series. Please insert CD #1."
679    [ -e "/cdrom.lnk" ] && mv -f /cdrom.lnk /dev/cdrom && mount /dev/cdrom /mnt/cdrom && CD_MOUNTED_OK=yes
680    [ "$CD_MOUNTED_OK" != "yes" ] && TryAgainToFindCD
681    #mount | grep cdrom > /dev/null 2> /dev/null || mount /dev/cdrom /mnt/cdrom >> $LOGFILE 2>> $LOGFILE
682fi
683hack-cfg-if-necessary || LogIt "Cannot find hack-cfg-if-necessary"
684
685# Log some useful info
686LogIt "init (from mindi v$MINDI_VER-r${MINDI_REV}"
687LogIt "/proc/cmdline is:"
688cat /proc/cmdline  >> $LOGFILE
689LogIt "df result:"
690LogIt "----------"
691df >> $LOGFILE
692LogIt "-------------"
693LogIt "mount result:"
694LogIt "-------------"
695mount >> $LOGFILE
696LogIt "-------------"
697LogIt "lsmod result:"
698LogIt "-------------"
699lsmod >> $LOGFILE
700LogIt "-------------"
701LogIt "dmesg result:"
702LogIt "-------------"
703dmesg >> $LOGFILE
704
705#-------------------------------
706#ABSORBENTANDYELLOWANDPOROUSISHE#;# --- don't touch this either :)
707#-------------------------------
708
709#ctrlaltdel soft
710for path in /usr.bin /usr/bin ; do
711    fname=$path/nano
712    [ -e "$fname" ] && ln -sf $fname /usr/bin/pico
713done
714res=`which nano 2> /dev/null`
715[ "$res" ] && ln -sf /usr/bin/
716for i in null stdout stdin stderr ; do
717    cp -af /dev/$i /tmp
718done
719if grep "backup-media-type" /tmp/mondo-restore.cfg > /dev/null 2> /dev/null ; then
720    LogIt "backup-media-type is specified in config file - great."
721    LogIt "Calling post-init $mountlist"
722    post-init
723else
724    LogIt "backup-media-type is not specified in config file."
725    LogIt "I think this CD/floppy has no archives on it."
726fi
727if grep "RESTORE" /proc/cmdline > /dev/null 2> /dev/null ; then
728    echo "Rebooting in 10 seconds automatically as per reboot order"
729    echo -en "Press ^C to interrupt if you have to ..."
730    for i in 1 2 3 4 5 6 7 8 9 10 ; do
731        sleep 1
732        echo -en "."
733    done
734    echo "Boom."
735    sleep 1
736else
737    echo -en "Type 'exit' to reboot the PC\n"
738    umount /mnt/cdrom 2> /dev/null
739    mount / -o rw,remount > /dev/null 2> /dev/null
740    LogIt "Launching Shell"
741    sh
742fi
743CaughtSoftReset
744# reboot
Note: See TracBrowser for help on using the repository browser.