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

Last change on this file since 1863 was 1863, checked in by bruno, 12 years ago
  • Try to overcome OpenSuSE stupidity in fstab format (why change again and again !) Ok, it keeps me busy, but I've not need for that anyway :-)
  • Increase sleep time after launching udevd to be sure it has time to start (again SuSE issue ?)
  • Property svn:keywords set to Id
File size: 20.9 KB
Line 
1#!/bin/sh
2#
3# $Id: init 1863 2008-01-16 11:00:03Z 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    echo "$DENY_MODS" | grep -q "usb-storage "
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 5
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
395echo "$DENY_MODS" | grep -Eq 'uhcd_hci |usbhid |usbcore '
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        echo "$DENY_MODS" | grep -q "$j "
579        if [ $? -eq 0 ]; then
580            echo "Denying $j..."
581            continue
582        fi
583        echo "Probing $j..."
584        modprobe -q $j
585    done
586}
587
588ExtractDataDisksAndLoadModules() {
589    echo "Installing additional tools ..."
590    install-additional-tools
591    # Keep the kernel silent again
592    PKLVL=`cut -f1 /proc/sys/kernel/printk`
593    echo 0 > /proc/sys/kernel/printk
594    if [ ! -e "/tmp/USE-UDEV" ] ; then
595        echo "Inserting modules ..."
596        insert-all-my-modules >> $LOGFILE 2>> $LOGFILE
597        for i in $FORCE_MODS; do
598            MyInsmod $i
599        done
600    else
601        ModprobeAllModules
602    fi
603    echo $PKLVL > /proc/sys/kernel/printk
604}
605
606# ------------------------ main -----------------------
607
608MINDI_VER=PBVER
609MINDI_REV=PBREV
610trap CaughtSoftReset SIGTERM
611LOGFILE=/var/log/mondorestore.log
612PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/mondo:/usr/games
613GROOVY=/tmp/groovy-stuff
614USER=root
615export PATH GROOVY USER LOGFILE
616
617echo "Welcome to init (from mindi ${MINDI_VER}-r${MINDI_REV})"
618
619mount -o remount rw /
620[ ! "$GROOVY" ] && Die "I'm not groovy!"
621for i in $GROOVY /mnt/floppy /mnt/cdrom /mnt/isodir /var/local/petris /tmp/isodir; do
622    mkdir -p $i
623done
624#/bin/update
625mount /proc/ /proc -v -t proc
626mkdir /sys 2> /dev/null
627mount /sys/ /sys -v -t sysfs 2>> $LOGFILE
628# For ESX 3
629[ -d /proc/vmware ] && ! grep -q /vmfs /proc/mounts && mount -t vmfs /vmfs /vmfs
630rm -f /foozero
631
632if [ "`grep -i denymods /proc/cmdline`" ]; then
633    export DENY_MODS="`cat /proc/cmdline | sed 's~.*denymods=\"\(.*\)\".*~\1~'` mondonone"
634else
635    export DENY_MODS=" "
636fi
637
638if [ "`grep -i forcemods /proc/cmdline`" ]; then
639    export FORCE_MODS="`cat /proc/cmdline | sed 's~.*forcemods=\"\(.*\)\".*~\1~'` mondonone"
640else
641    export FORCE_MODS=" "
642fi
643
644echo "Activating a potential USB keyboard/mouse"
645StartUSBKbd
646
647if [ -f /proc/sys/kernel/exec-shield ]; then
648    echo 0 > /proc/sys/kernel/exec-shield 2>> /dev/null
649fi
650
651if [ -f /proc/modules ]; then
652    echo "/sbin/modprobe" > /proc/sys/kernel/modprobe
653fi
654
655if [ -e "/tmp/USE-UDEV" ] ; then
656    RunUdevd
657fi
658ExtractDevTarballs
659LaunchTerminals
660
661# Keeping kernel silent  for module insertion
662PKLVL=`cut -f1 /proc/sys/kernel/printk`
663echo 0 > /proc/sys/kernel/printk
664if [ ! -e "/tmp/USE-UDEV" ] ; then
665    InsertEssentialModules
666else
667    ModprobeAllModules
668fi
669echo $PKLVL > /proc/sys/kernel/printk
670
671EnableCcissIfAppropriate
672#-------------------------------
673#WHOLIVESINAPINEAPPLEUNDERTHESEA#;# --- don't touch this :)
674#-------------------------------
675UseTmpfs
676if [ ! -e "/tmp/mondo-restore.cfg" ] ; then
677    LogIt "Warning - /tmp/mondo-restore.cfg not found"
678fi
679
680if [ "`grep -i 'tape ' /tmp/mondo-restore.cfg`" ] || [ "`grep -i udev /tmp/mondo-restore.cfg`" ]; then
681    HandleTape
682    ExtractDataDisksAndLoadModules
683elif [ "`grep -i pxe /proc/cmdline`" ]; then
684    # We need to get here exported variables from start-nfs
685    . /sbin/start-nfs
686
687    # Simulate a local CD
688    echo "/mnt/cdrom" > /tmp/CDROM-LIVES-HERE
689    CD_MOUNTED_OK=yes
690    ExtractDataDisksAndLoadModules
691elif [ "`grep -i usb= /proc/cmdline`" ] || [ "`grep -i usb /tmp/mondo-restore.cfg | grep media-type`" ]; then
692    # We need to get here exported variables from start-nfs
693    . /sbin/start-usb
694
695    # Simulate a local CD
696    echo "/mnt/cdrom" > /tmp/CDROM-LIVES-HERE
697    CD_MOUNTED_OK=yes
698    ExtractDataDisksAndLoadModules
699else
700    HandleCDROMorFloppies
701    ExtractDataDisksAndLoadModules
702    # We need to get here exported variables from start-nfs
703    . /sbin/start-nfs
704fi
705res=$?
706ConfigureLoggingDaemons
707if [ -e "/tmp/USE-DEVFS" ] ; then
708    umount /mnt/cdrom 2> /dev/null
709    mv /dev/cdrom /cdrom.lnk 2> /dev/null
710    CD_MOUNTED_OK=""
711    RunDevfsd
712fi
713LoadKeymap
714WelcomeMessage
715RstHW
716echo "Starting potential Raid/LVMs ..."
717PauseForRaids
718StartRaids
719StartLvms
720CopyBootDevEntry
721mkdir -p /tmp/tmpfs
722sleep 2
723#clear
724if [ -e "/dev/md0" ] && [ ! -e "/dev/md/0" ] && [ "`grep /dev/md/ /tmp/mountlist.txt`" != "" ] ; then
725    LogIt "Creating /dev/md/* softlinks just in case." 1
726    mkdir -p /dev/md
727    cp -af /dev/md0 /dev/md/0 2> /dev/null
728    cp -af /dev/md1 /dev/md/1 2> /dev/null
729    cp -af /dev/md2 /dev/md/2 2> /dev/null
730fi
731# SpaceTests; # Mandrake Linux 8.1 doesn't like this
732[ -e "/tmp/mountlist.txt" ] && cp -f /tmp/mountlist.txt /tmp/mountlist.original
733
734if ! [ "`grep -i "pxe" /proc/cmdline`" ] ; then
735    res="`cat /mnt/cdrom/archives/THIS-CD-NUMBER 2> /dev/null`"
736    [ "$res" != "1" ] && [ "$res" != "" ] && Die "This is CD #$res in the series. Please insert CD #1."
737    [ -e "/cdrom.lnk" ] && mv -f /cdrom.lnk /dev/cdrom && mount /dev/cdrom /mnt/cdrom && CD_MOUNTED_OK=yes
738    [ "$CD_MOUNTED_OK" != "yes" ] && TryAgainToFindCD
739    #mount | grep cdrom > /dev/null 2> /dev/null || mount /dev/cdrom /mnt/cdrom >> $LOGFILE 2>> $LOGFILE
740fi
741hack-cfg-if-necessary || LogIt "Cannot find hack-cfg-if-necessary"
742
743# Log some useful info
744LogIt "init (from mindi v$MINDI_VER-r${MINDI_REV})"
745LogIt "/proc/cmdline is:"
746cat /proc/cmdline  >> $LOGFILE
747LogIt "df result:"
748LogIt "----------"
749df >> $LOGFILE
750LogIt "-------------"
751LogIt "mount result:"
752LogIt "-------------"
753mount >> $LOGFILE
754LogIt "-------------"
755LogIt "lsmod result:"
756LogIt "-------------"
757lsmod >> $LOGFILE
758LogIt "-------------"
759LogIt "dmesg result:"
760LogIt "-------------"
761dmesg >> $LOGFILE
762
763#-------------------------------
764#ABSORBENTANDYELLOWANDPOROUSISHE#;# --- don't touch this either :)
765#-------------------------------
766
767#ctrlaltdel soft
768for path in /usr.bin /usr/bin ; do
769    fname=$path/nano
770    [ -e "$fname" ] && ln -sf $fname /usr/bin/pico
771done
772res=`which nano 2> /dev/null`
773[ "$res" ] && ln -sf /usr/bin/
774for i in null stdout stdin stderr ; do
775    cp -af /dev/$i /tmp
776done
777if grep "backup-media-type" /tmp/mondo-restore.cfg > /dev/null 2> /dev/null ; then
778    LogIt "backup-media-type is specified in config file - great."
779    LogIt "Calling post-init $mountlist"
780    post-init
781else
782    LogIt "backup-media-type is not specified in config file."
783    LogIt "I think this CD/floppy has no archives on it."
784fi
785if grep "RESTORE" /proc/cmdline > /dev/null 2> /dev/null ; then
786    echo "Rebooting in 10 seconds automatically as per reboot order"
787    echo -en "Press ^C to interrupt if you have to ..."
788    for i in 1 2 3 4 5 6 7 8 9 10 ; do
789        sleep 1
790        echo -en "."
791    done
792    echo "Boom."
793    sleep 1
794else
795    echo -en "Type 'exit' to reboot the PC\n"
796    umount /mnt/cdrom 2> /dev/null
797    mount / -o rw,remount > /dev/null 2> /dev/null
798    LogIt "Launching Shell"
799    sh
800fi
801CaughtSoftReset
802# reboot
Note: See TracBrowser for help on using the repository browser.