source: branches/2.2.9/mindi/rootfs/sbin/init @ 2163

Last change on this file since 2163 was 2163, checked in by Bruno Cornec, 11 years ago
  • Apply other ia64 fixes after tests feedback from Giuseppe Grassi giuseppe.grassi2_at_italtel.it

(ARCH set earlier in init and flush logs + some more print in parted2fdisk)

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