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

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

svn merge -r 1938:1976 $SVN_M/branches/2.2.6

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