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

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

Adds boot options denymods (for udev) and forcemods (if not udev)

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