source: branches/stable/mindi/rootfs/sbin/init @ 1924

Last change on this file since 1924 was 1924, checked in by bruno, 11 years ago

svn merge -r 1902:1923 $SVN_M/branches/2.2.6

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