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

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