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

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