source: branches/3.3/mindi/rootfs/etc/init.d/rcS @ 3697

Last change on this file since 3697 was 3697, checked in by Bruno Cornec, 2 years ago

Remove usage of groovy word to clarify what is done

  • Property svn:keywords set to Id
File size: 32.9 KB
RevLine 
[3274]1#!/bin/bash
[1]2#
[736]3# $Id: rcS 3697 2018-01-07 13:52:31Z bruno $
[1]4#
[736]5# init script launched during the restore process
[1]6#------------------------------------------------------------
7
8CaughtSoftReset() {
[1747]9    trap SIGTERM
[2890]10
[2893]11    reboot
[3593]12    umount -a -d -r 2> /dev/null
13    sync
14    # If this is not sufficient, then continue killing what is runnig
15    kill -TERM 1 
16    sleep 1
17    kill -KILL 1 
18    sleep 1
19    # Finally force reboot at kernel level if everything else failed
20    echo s > /proc/sysrq-trigger
21    echo u > /proc/sysrq-trigger
22    echo b > /proc/sysrq-trigger
[1]23}
24
25
26ConfigureLoggingDaemons() {
[1747]27    echo -en "Running klogd..."
28    klogd -c 2 > /dev/null 2> /dev/null
29    echo -en "Done.\nRunning syslogd..."
30    syslogd > /dev/null 2> /dev/null
31    echo "Done."
32    LogIt "klogd and syslogd have been started."
[1]33}
34
35
36
37CopyBootDevEntry() {
[1747]38    local outfile devfile
39    devfile=/dev/boot_device
40    outfile=`cat /BOOTLOADER.DEVICE 2> /dev/null`
41    [ ! "$outfile" ] && return 0
42    echo -en "Copying boot device to $outfile..."
43    if [ -e "$outfile" ] ; then
[2174]44        echo "not needed."
[1410]45        return 0
[1747]46    fi
47    mkdir -p $outfile
48    rmdir $outfile
49    cp -pRdf $devfile $outfile
50    if [ "$?" -ne "0" ] ; then
[1410]51        echo "Failed."
52        return 1
[1747]53    else
[1410]54        echo "OK."
55        return 0
[1747]56    fi
[1]57}
58
59
[2888]60GetShell() {
[3653]61    echo -en "Type 'exit' to reboot the machine\n"
[2888]62    umount -d /mnt/cdrom 2> /dev/null
63    mount / -o rw,remount > /dev/null 2> /dev/null
[3051]64    for i in `cat /proc/cmdline`; do
[3247]65        echo $i | grep -qi console= && console=`echo $i | cut -d= -f2`
66        echo $i | grep -qi serial= && serial=`echo $i | cut -d= -f2`
67    done
68    LogIt "Launching Shell"
69    if [[ $serial != "" && -e $serial ]]; then
70        setsid sh -c "exec sh <$serial >$serial 2>&1"
71    elif [[ $console != "" && -e /dev/$console ]]; then
72        setsid sh -c "exec sh </dev/$console >/dev/$console 2>&1"
73    else
74        setsid sh -c "exec sh </dev/tty1 >/dev/tty1 2>&1"
75    fi
[2888]76}
[1]77
[2888]78
[1]79Die() {
[1747]80    LogIt "Fatal error! $1" 1
[2888]81    GetShell
[1]82}
83
84
85ExtractDevTarballs() {
[1747]86    cd /
[3489]87    if [ -x /usr/lib/systemd/systemd-udevd ] || [ -x /lib/systemd/systemd-udevd ]; then
[3277]88        # Just use vc dev files. The other are useless and create huge delays with LVM
89        tar -zxf /vc.tgz || LogIt "Error occurred while extracting /vc.tgz"
90    else
91        for fname in ataraid.tgz ida.tgz i2o.tgz rd.tgz raw.tgz cciss.tgz nst.tgz dm.tgz vc.tgz ; do
92            if [ ! -e "/$fname" ] ; then
93                LogIt "/$fname not found; cannot extract to /." 1
94            else
95                echo -en "\rExtracting /$fname...     "
96                tar -zxf /$fname || LogIt "Error occurred while extracting /$fname"
97            fi
98        done
99    fi
[1747]100    echo -en "\r"
101    LogIt "Extracted additional /dev entries OK.     " 1
[1]102}
103
104
105
106LaunchTerminals() {
[2727]107    # Depending on busybox version, syntax of openvt is different
108    /bin/busybox --help 2>&1 | head -1 | grep -Eq "1\.7\.3|1\.2\."
109    if [ "$?" -eq "0" ] ; then
110        opt=""
111    else
112        # 1.18.3 requires -c
113        opt="-c"
114    fi
[3278]115    echo "Launching terminals on other ttys - Use ALT+F[2-6] to use them"
[2727]116    openvt $opt 2 /bin/sh
117    openvt $opt 3 /bin/sh
118    openvt $opt 4 /bin/sh
119    openvt $opt 5 /bin/sh
120    openvt $opt 6 /bin/sh
121    openvt $opt 7 /bin/sh /sbin/wait-for-petris
122    openvt $opt 8 /usr/bin/tail -f $LOGFILE
[3274]123    if [ -f /var/log/messages ]; then
124        openvt $opt 9 /usr/bin/tail -f /var/log/messages
125    fi
[1922]126    # May avoid shell error messages
127    chmod 666 /dev/tty* /dev/console
[2484]128    # By default first serial line is configured as tty
[3274]129    # Required to have a correct serial console support (MP on ia64 or VSP with iLO e.g.)
[2484]130    for i in `cat /proc/cmdline` ; do
[3200]131        echo $i | grep -qi serial= && serial=`echo $i | cut -d= -f2`
[2484]132    done
[2487]133    # Doing that is only valid when using a real serial line
[3328]134    if [[ $serial != "" && -e $serial ]]; then
[2498]135        LogIt "Redirecting serial $serial to /dev/tty" 1
[2487]136        ln -s -f $serial /dev/tty
137    fi
[1]138}
139
140
141LoadKeymap() {
[1747]142    local fname
[3282]143    fname=`grep keymap-lives-here /tmp/mondorestore.cfg | cut -f2 -d' ' 2> /dev/null`
[1747]144    [ "$fname" = "" ] && return
145    if which loadkeys > /dev/null 2> /dev/null ; then
146        loadkeys $fname
[2846]147        LogIt "Using $fname keyboard map." 1
[1747]148    else
[2731]149        LogIt "Using default US keyboard map." 1
[1747]150    fi
[1]151}
152
153
154UntarTapeStuff() {
[1747]155    local old_pwd res
156    old_pwd=`pwd`
[3697]157    cd $EXTRACTDIR
[1747]158    [ "$1" != "" ] && tapedev=$1
[3274]159    [ ! "$tapedev" ] && tapedev=`grep media-dev /tmp/mondorestore.cfg 2>/dev/null | tr -s ' ' ' ' | cut -d' ' -f2`
[1962]160    mt -f $tapedev rewind
[3119]161    if [ $? -ne 0 ]; then
162        LogIt "WARNING: $tapedev failed to rewind, either not a tape or still in OBDR mode." 1
163        LogIt "         Trying to find the corresponding SCSI generic device." 1
164        c=0
165        for d in `ls /sys/class/scsi_device/*`; do
166            devtype=`cat $d/device/type`
[3153]167            if [ "$devtype" -eq "1" ]; then
[3119]168                LogIt "NOTE: Device /dev/sg$c is a Sequential device." 1
169                if [ -x /usr/bin/sg_map ]; then
170                    dev=`/usr/bin/sg_map | grep -E "^/dev/sg$c" | awk '{print $2}'`
171                    LogIt "      Retry using device $dev" 1
172                fi
[3153]173            elif [ "$devtype" -eq "0" ]; then
[3119]174                # Skipping a HDD
[3135]175                /bin/true
[3153]176            elif [ "$devtype" -eq "5" ]; then
[3119]177                # Checking whether it's a CD or a tape in OBDR mode
178                grep -q -i -E 'dat|ultrium|tape' $d/device/model
179                if [ $? -eq 0 ]; then
180                    # Is probably a Tape drive left in OBDR.
181                    LogIt "Found that /dev/sg$c is a tape drive (`cat $d/device/model`)." 1
182                    grep -q -i -w 'hp' $d/device/vendor
183                    if [ $? -eq 0 ]; then
184                        LogIt "This is an HP tape drive, even better :-)." 1
185                    fi
186                    if [ -x /usr/bin/sg_reset ]; then
187                        OBDR_MODS="st mptsas mptspi aic7xxx aic94xx mpt2sas "
188                        if [ "`grep -i obdrmods /proc/cmdline`" ]; then
189                            OBDR_MODS="$OBDR_MODS `cat /proc/cmdline | sed 's~.*obdrmods=\"\(.*\)\".*~\1~'`"
190                        fi
191                        LogIt "Removing modules $OBDR_MODS." 1
192                        for m in $OBDR_MODS; do
193                            rmmod $i
194                        done
195                        LogIt "Trying to force device /dev/sg$c to be in sequential mode." 1
196                        /usr/bin/sg_reset -d /dev/sg$c
197                        LogIt "Inserting modules `rev $OBDR_MODS`." 1
198                        for m in `rev $OBDR_MODS`; do
199                            modprobe $i
200                        done
201                        LogIt "Retry again as the device has been set back into sequential mode." 1
202                        mt -f $tapedev fsf 2
203                        res=$?
204                        # exit the loop to continue and return if that previous mt failed.
205                        # If it succeeded we transparently continue !!
206                        break
207                    else
208                        LogIt "WARNING: Unable to reset /dev/sg$c as the sg_reset command is not availble." 1
209                    fi
210                fi
211            else 
212                LogIt "Device /dev/sg$c has an unknown type $devtype." 1
213            fi
214            c=`expr $c + 1`
215        done
216
217        if [ $res -ne 0 ]; then
218            cd $old_pwd
219            return $res
220        fi
221    fi
222
[1958]223    mt -f $tapedev fsf 2
[2915]224    # 32k is DEFAULT_INTERNAL_TAPE_BLOCK_SIZE
225    mt -f $tapedev setblk 32768
[1747]226    dd if=$tapedev bs=32k count=1024 | tar -zx
227    res=$?
228    if [ "$res" -eq "0" ] ; then
[1958]229        # Store the dev name in case we changed it interactively
[3274]230        if [ -f "/tmp/mondorestore.cfg" ]; then
231            sed -i "s/^media-dev .*$/media-dev  $tapedev/" /tmp/mondorestore.cfg
[1983]232        fi
[1747]233    fi
234    cd $old_pwd
235    return $res
[1]236}
237
238HandleTape() {
[1747]239    local res tapedev
240    tapedev="" ; # will be set by UntarTapeStuff()
[1963]241
[1968]242    # Here we can add the USB storage module, it's working even with OBDR !
[2964]243    modprobe -q usb-storage 2> /dev/null
[1968]244    # Tape takes some time to appear
245    sleep 10
[3697]246    cd $EXTRACTDIR
[1958]247    UntarTapeStuff $tapedev
[1747]248    res=$?
[3124]249    tapedev="default tape device"
[1747]250    while [ "$res" -ne "0" ] ; do
251        LogIt "$tapedev failed to act as extended data disk for booting." 1
[3124]252        LogIt "Please specify an alternate non-rewinding tape device, such as /dev/nst0" 1
[1885]253        LogIt "or hit <Enter> to boot from another media." 1
[1747]254        echo -en "---> "
255        read tapedev
256        if [ "$tapedev" ] ; then
257            LogIt "User specified $tapedev instead"
258            UntarTapeStuff $tapedev
259            res=$?
260        else
261            LogIt "User opted not to specify an alternate tapedev"
262            res=1
[1]263        break
[1747]264        fi
265    done
[1962]266    # For post-init
267    export TAPEDEV=$tapedev
[1]268
[1747]269    if [ "$res" -ne "0" ] ; then
[1410]270        cd /
[1885]271        LogIt "Failed to use tape as extended datadisk. Reverting to another media." 1
272        HandleCDROM
[1410]273        res=$?
[1747]274    else
[1410]275        LogIt "Using tape as extended datadisk. Good." 3
276        echo "Using tape as extd ddisk." > /tmp/TAPEDEV-HAS-DATA-DISKS
277        res=0
[1747]278        CD_MOUNTED_OK=yes
279    fi
280    return $res
[1]281}
282
283
284
[1885]285HandleCDROM() {
[1825]286    # Just in case we have an iLO ensure we will map it correctly
[1830]287    echo "$DENY_MODS" | grep -q "usb-storage "
[1829]288    if [ $? -eq 0 ]; then
289        return
290    fi
[1826]291    echo "Activating a potential USB Storage device"
[2964]292    modprobe -q usb-storage 2> /dev/null
[1826]293    for i in 1 2 3 4 5 6 7 8 9 10 ; do
294        sleep 1
295        echo -en "."
296    done
[1825]297
[1747]298    find-and-mount-cdrom
299    res=$?
300    if [ "$res" -ne "0" ] ; then
[898]301        LogIt "First call to find-and-mount-cdrom failed." 1
302        LogIt "Sleeping for 3 seconds and trying again." 1
303        sleep 3
304        find-and-mount-cdrom
305        res=$?
[1747]306    fi
307    if [ "$res" -eq "0" ] ; then
[3274]308        LogIt "OK, I am running on a CD-ROM. Good." 1
[1747]309        CD_MOUNTED_OK=yes
310    else
[3274]311        LogIt "You probably not have the right drivers" 1
312        LogIt "to support the hardware on which we are running" 1
313        LogIt "Your archives are probably fine but" 1
314        LogIt "your tape streamer and/or CD-ROM drive are unsupported at that point." 1
[898]315        CD_MOUNTED_OK=""
[1747]316    fi
317    return 0
[1]318}
319
320
321PauseForRaids() {
[1747]322    if [ "`dmesg | grep -i "RAID Controller"`" != "" ] || [ "`dmesg | grep -i "Vendor: 3ware"`" != "" ] ; then
323        LogIt "RAID controller(s) detected. Pausing 10 seconds to let them warm up." 1
324        echo -en "Pausing..."
325        for i in 1 2 3 4 5 6 7 8 9 10 ; do
326            sleep 1
327            echo -en "$(($i*10))%..."
328        done
329        echo "Done."
330    fi
[1]331}
332
333
334# 06/13/2002 --- DuckX's & Hugo's new routine
335# 10/11/2003 --- added a simple devfsd.conf file
336# 01/24/2005 --- cater for arbitrary locations of devfsd.conf by using the
337#                config file path compiled into devfsd
338RunDevfsd() {
[1747]339    loc=`which devfsd 2> /dev/null`
340    if [ "$loc" != "" ] ; then
[1]341    LogIt "Devfs found. Testing kernel support..."
342    if [ ! -e "/dev/.devfsd" ] ; then
[746]343        mount -t devfs devfs /dev 2>> $LOGFILE
[3274]344        if [ "$?" -ne "0" ] ; then
345            LogIt "Error while trying to mount devfs"
[1]346        else
[3274]347            LogIt "Devfs mounted OK"
[1]348        fi
349    fi
350    #check if the kernel supports devfs
351    if [ -e "/dev/.devfsd" ] ; then
352        [ -d "/proc/1" ] || mount -n /proc
353        LogIt "Kernel support found. Creating config file and starting devfsd"
[911]354        conffile=`strings $loc | grep -E "devfsd.conf$"`
[1]355        [ "$conffile" ] || conffile="/etc/devfsd.conf"
356        confpath=`echo $conffile | sed "s/\/devfsd\.conf$//"`
357        [ -d "$confpath" ] || mkdir -p $confpath
358        echo -en "REGISTER .* MKOLDCOMPAT\nUNREGISTER .* RMOLDCOMPAT\n" > $conffile
359        devfsd /dev &
360        sleep 5
361    else
362        LogIt "No devfs kernel support."
363    fi
[1747]364    fi
[1]365}
366
[1718]367# Taken from udev management in Mandriva 2008.0. Kudos guys
[2845]368MakeExtraNodes () {
[1718]369    # there are a few things that sysfs does not export for us.
370    # these things are listed in /etc/udev/links.conf
371    grep '^[^#]' /etc/udev-links.conf | \
372    while read type name arg1; do
373        [ "$type" -a "$name" -a ! -e "/dev/$name" -a ! -L "/dev/$name" ] ||continue
374        case "$type" in
375            L) ln -s $arg1 /dev/$name ;;
376            D) mkdir -p /dev/$name ;;
[1719]377            M) mknod /dev/$name $arg1 && chmod 600 /dev/$name;;
378            *) echo "udev-links.conf: unparseable line (%s %s %s)\n" "$type" "$name" "$arg1" ;;
[1718]379        esac
380    done
381}
382
[2845]383CreateDevMakedev() {
[3368]384    if [ -e /sbin/MAKEDEV ]; then
385        ln -sf /sbin/MAKEDEV /dev/MAKEDEV
386    else
387        ln -sf /bin/true /dev/MAKEDEV
388    fi
[1792]389}
[1718]390
[1716]391RunUdevd() {
[3274]392    # Initial Inspiration from Mandriva 2008.0 startup script
393    LogIt "Preparing udev environment..." 1
[1718]394    mv /dev /dev.static
395    mkdir /dev
[3293]396    # Contributed during LinuxCon Japan !
[3489]397    if [ -x /usr/lib/systemd/systemd-udevd ] || [ -x /lib/systemd/systemd-udevd ]; then
[3293]398        mount -n -t devtmpfs none /dev
399    else
400        mount -n -o size=5M,mode=0755 -t tmpfs none /dev
401        MakeExtraNodes
402        mount -n -t devpts -o mode=620 none /dev/pts
403    fi
[3295]404    mkdir -p /dev/shm
[1718]405    mount -n -t tmpfs  none /dev/shm
[1789]406    if [ -e /proc/sys/kernel/hotplug ]; then
407        echo > /proc/sys/kernel/hotplug
408    fi
[1734]409    PKLVL=`cut -f1 /proc/sys/kernel/printk`
410    echo 0 > /proc/sys/kernel/printk
[2081]411    # Many possibilities depending on udev versions
[1759]412    if [ -x /sbin/startudev ]; then
413        /sbin/startudev
414    fi
[2081]415    if [ -x /sbin/start_udev ]; then
416        /sbin/start_udev
417    fi
[1759]418    # Depending on udevd version it gives back the hand or not :-(
[2673]419    ps | grep -v grep |grep udevd 2> /dev/null 1> /dev/null
[2437]420    if [ $? -ne 0 ]; then
[3277]421        echo "Waiting for udev to start..."
[2965]422        if [ -x /sbin/udevd ]; then
423            /sbin/udevd --daemon &
424        elif [ -x /usr/bin/udevd ]; then
425            /usr/bin/udevd --daemon &
[3489]426        elif [ -x /usr/lib/systemd/systemd-udevd ] || [ -x /lib/systemd/systemd-udevd ]; then
[3274]427            # from https://github.com/hut/minirc/blob/master/rc
[3277]428            echo "INFO: This is the systemd version of udev"
[3293]429            # Contributed during LinuxCon Japan
430            #mount -n -t tmpfs tmpfs /sys/fs/cgroup
[3285]431            #mount -n -t cgroup cgroup /sys/fs/cgroup/systemd
[3305]432            mkdir -p /run/udev
433            mkdir -p /run/systemd/journal
[3489]434            if [ -x /usr/lib/systemd/systemd-udevd ]; then
435                /usr/lib/systemd/systemd-udevd --daemon
436            else
437                /lib/systemd/systemd-udevd --daemon
438            fi
[3274]439            udevadm trigger --action=add --type=subsystems
440            udevadm trigger --action=add --type=devices
[2965]441        fi
[2437]442        sleep 5
[3274]443        LogIt "udev started manually" 1
[2437]444    fi
[1792]445    mkdir -p /dev/.udev/queue/
[1789]446    if [ -x /sbin/udevtrigger ]; then
447        /sbin/udevtrigger
448    fi
[2442]449    echo "Waiting for udev to discover..."
[2845]450    CreateDevMakedev
[2182]451    # Newer version use udevadm for that
[2437]452    if [ -x /sbin/udevsettle ]; then
[2442]453        /sbin/udevsettle --timeout=10
[2846]454        LogIt "Discovering with udevsettle"
[2965]455    elif [ -x /sbin/udevadm ] || [ -x /usr/bin/udevadm ]; then
456        ua=`UdevadmTrigger`
457        $ua settle --timeout=10
[2846]458        LogIt "Discovering with udevadm"
[1816]459    fi
[1824]460    # It seems we need to have more static devs on some distro were
461    # udev as some other requirements to be covered later on.
462    # So in the mean time:
463    for d in `ls /dev.static`; do
464        if [ ! -e /dev/$d ]; then
465            mv /dev.static/$d /dev
466        fi
467    done
[1816]468    echo $PKLVL > /proc/sys/kernel/printk
[1716]469}
[1]470
[1761]471RstHW() {
[1]472
[1761]473    # Restore the HW configuration if available (NOT by default)
474    answer="NO"
[1]475
[1815]476    grep -q nohw /proc/cmdline
477    if [ "$?" -eq 0 ]; then
478        return
479    fi
[1761]480    if [ -x ./mindi-rsthw ]; then
481        grep -q RESTORE /proc/cmdline
482        if [ "$?" -ne 0 ]; then
[1815]483            #clear
[1761]484            echo "*********************************************************************"
485            echo "Do you want to restore the HW configuration of the original machine ?"
486            echo "(This may dammage your hardware so be sure to check twice before saying yes)"
487            echo "*********************************************************************"
488            echo "Please confirm by typing YES exactly as written here (NO by default)"
489            echo -n "--> "
490            read answer
491        else
492            answer="YES"
493        fi
[1910]494        if [ "$answer" = "YES" ] ; then
[1761]495            ./mindi-rsthw
496        fi
497    fi
498}
[1]499
[1761]500
[1787]501StartUSBKbd() {
502# Prepare minimal USB env in case we have USB kbd such as with iLO
503[ -d /proc/bus/usb ] && ! grep -q /proc/bus/usb /proc/mounts && mount -t usbfs none /proc/bus/usb
[1830]504echo "$DENY_MODS" | grep -Eq 'uhcd_hci |usbhid |usbcore '
[1829]505if [ $? -eq 0 ]; then
506    return
507fi
[2964]508modprobe -q uhcd_hci 2> /dev/null
509modprobe -q usbhid 2> /dev/null
[1787]510}
[1]511
512
[1787]513
[1]514StartLvms() {
[2477]515    if [ "`grep -i nolvm /proc/cmdline`" ]; then
516        return;
517    fi
[1747]518    if [ -e "/tmp/i-want-my-lvm" ] ; then
[3274]519        # Recent LVM need this caching daemon to work
[3484]520        LVMETAD=""
521        if [ -x /sbin/lvmetad ]; then
522            LVMETAD="/sbin/lvmetad"
523        fi
[3274]524        if [ -x /usr/sbin/lvmetad ]; then
[3484]525            LVMETAD="/usr/sbin/lvmetad"
526        fi
527        if [ -x $LVMETAD ]; then
[3277]528            mkdir -p /run/lvm
[3484]529            $LVMETAD
[3274]530        fi
[1747]531        LogIt "Scanning LVM's..." 1
[739]532        if which lvm ; then
[2964]533            modprobe -q dm-mod 2> /dev/null
534            modprobe -q dm_mod 2> /dev/null
[2845]535            lvm vgscan --mknodes
[739]536        else
[2845]537            vgscan
[739]538        fi
[2533]539
540        # Exclude devices we may not want
541        rm -f /tmp/restorevgs
[2564]542        for d in $MINDI_EXCLUDE_DEVS ; do
[2580]543            echo "LVM exclusion == $d"
[3286]544            # LVM: $4 to be checked if changed
[2533]545            EXCLUDE_VGS=`grep " $d" /tmp/i-want-my-lvm | grep vgcreate | awk '{print $4}'`
546            vg=`echo $EXCLUDE_VGS | sed "s/ /|/g"`
547            if [ "$vg" != "" ]; then
548                re=" $d|$vg"
549            else 
550                re=" $d"
551            fi
552            # Remove VGs from i-want-my-lvm
553            grep -Ev "$re" /tmp/i-want-my-lvm > /tmp/i-want-my-lvm.new
554            mv /tmp/i-want-my-lvm.new /tmp/i-want-my-lvm
555            # Prepare  script to restore the VG exluded here if needed
556            for v in $EXCLUDE_VGS; do
557                echo "vgcfgrestore $v" >> /tmp/restorevgs
558                # Remove LVs from mountlist
[3286]559                # LVM: sed to be checked if changed
[2533]560                EXCLUDE_LVS=`grep " $v" /tmp/i-want-my-lvm | grep lvcreate | sed "s/^.*-n \([^ ][^ ]*\) .*$/$1/"`
561                for l in $EXCLUDE_LVS; do
[2535]562                    # FIXME: Should search for all possible device names here
[3203]563                    if [ -f "/tmp/mountlist.txt" ]; then
564                        grep -Ev "/dev/$v/$l" /tmp/mountlist.txt > /tmp/mountlist.txt.new
565                        grep -Ev "/dev/mapper/${v}-$l" /tmp/mountlist.txt.new > /tmp/mountlist.txt
566                    fi
[2533]567                done
568            done
569        done
570
[3286]571        # LVM: remove #
[1747]572        grep -E "^#.*vgchange" /tmp/i-want-my-lvm | sed "s/^#[ ]*//" > /tmp/start-lvm
573        chmod +x /tmp/start-lvm
574        echo -en "Starting LVM's..."
575        /tmp/start-lvm &
576        for i in 1 2 3 4 5 ; do
[2845]577            echo -en "."
578            sleep 1
[1747]579        done
580        echo "Done."
581    fi
[1]582# If necessary, cannibalize 'analyze-my-lvm'; copy some of its code here,
583# pipe vgscan's output, strip it, run 'vgchange' on its output, etc.etc.
[1747]584    LogIt "LVM's have been started."
[1]585}
586
[2177]587StartPowerPath() {
[1]588
[2177]589    # Taken from the init script of EMC PowerPath on RHEL
[2845]590    if [ -f /etc/emcp_devicesDB.dat ]; then 
591        if [ -f /etc/emcp_devicesDB.idx ]; then
592            /etc/opt/emcpower/emcpmgr map -p > /dev/null 2>&1
593        fi
594    fi
[2177]595
[2845]596    /sbin/powermt config > /dev/null 2>&1
597    #   Wait for udev to finish creating emcpower devices
598    #
599    pdfound=1
600    for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15; do
601        pdfound=1
602        for pd in `/bin/ls -d /sys/block/emcpower* 2> /dev/null`; do
603            bpd=`basename $pd`
604            if [ ! -e /dev/$bpd ]; then
605                pdfound=0
606                sleep 2
607                break;
608            fi
609        done
610        if [ "$pdfound" -eq 1 ]; then
[2177]611            break
[2845]612        fi
613    done
614    if [ "$pdfound" -eq 0 ]; then
615        echo "Unable to start PowerPath"
616    fi
[2177]617
[2845]618    /sbin/powermt load      > /dev/null 2>&1
619    /etc/opt/emcpower/emcpmgr map   > /dev/null 2>&1
620    /etc/opt/emcpower/powercf -C    > /dev/null 2>&1
621    if [ ! -e /etc/powermt.custom ]; then 
622        /sbin/powermt save      > /dev/null 2>&1
623    fi 
624    /sbin/powermt register  > /dev/null 2>&1
625    /sbin/powermig transition -startup -noprompt    > /dev/null 2>&1
[2177]626}
627
[2072]628StartMpath() {
629    if [ "`grep -i nompath /proc/cmdline`" ]; then
630        return;
631    fi
[3203]632    if [ -f "/tmp/mountlist.txt" ] && [ "`grep mpath /tmp/mountlist.txt`" ]; then
[2353]633        if [ -x /sbin/multipath ]; then
634            echo "Starting Mpath..."
635            mkdir -p /var/lib/multipath
636            cat > /etc/multipath.conf << EOF
[2072]637defaults {
638        user_friendly_names yes
639}
640EOF
[2353]641            /sbin/multipath -v 0
642            if [ -x /sbin/kpartx ]; then
643                /sbin/dmsetup ls --target multipath --exec "/sbin/kpartx -a -p p"
644            fi
[2846]645            LogIt "Multipath started"
[2072]646        fi
647    fi
648}
649
[3661]650StartDRBD() {
651    if [ "`grep -i nodrbd /proc/cmdline`" ]; then
652        return;
653    fi
654    if [ "`grep -i drbd /proc/cmdline`" ]; then
655        echo "Starting DRBD..."
656        mkdir -p /var/run/drbd
657        drbdadm adjust-with-progress all
658        drbdadm wait-con-int
659        # Become primary
660        drbdadm sh-b-pri
661        drbdadm sh-status
662        drbdsetup all show
663        LogIt "DRBD started"
664    fi
665}
666
[1]667StartRaids() {
[1747]668    local raid_devices i
[1273]669
[2353]670    if [ "`grep -i noraid /proc/cmdline`" ]; then
671        return;
672    fi
673
[3203]674    if [ -f "/tmp/mountlist.txt" ]; then
675        raid_devices=`grep /dev/md /tmp/mountlist.txt | cut -d' ' -f1`
676    else
677        raid_devices=""
678    fi
679
[623]680    if which raidstart > /dev/null 2> /dev/null ; then
[1747]681        for i in $raid_devices ; do
682            if grep `basename $i` /proc/mdstat > /dev/null 2> /dev/null ; then
683                LogIt "$i is started already; no need to run 'raidstart $i'" 1
684            else
[623]685                LogIt "Running 'raidstart $i'" 1
686                raidstart $i
[1747]687            fi
688        done
[623]689    elif which mdrun > /dev/null 2> /dev/null ; then
[2353]690        if [ "`grep -i nomd /proc/cmdline`" ]; then
691            return;
692        fi
[623]693        LogIt "Running 'mdrun'" 1
694        mdrun
[1273]695    elif which mdadm > /dev/null 2> /dev/null ; then
[2353]696        if [ "`grep -i nomd /proc/cmdline`" ]; then
697            return;
698        fi
[1273]699        LogIt "Running 'mdadm'" 1
700        for i in $raid_devices ; do
[1747]701            if grep `basename $i` /proc/mdstat > /dev/null 2> /dev/null ; then
702                LogIt "$i is started already; no need to run 'mdadm $i'" 1
703            else
[1610]704                if [ -f /etc/mdadm.conf ] ; then
705                    LogIt "Running 'mdadm $i' with user supplied /etc/mdadm.conf" 1
706                    mdadm -A $i -c /etc/mdadm.conf
707                elif [ -f /etc/mdadm/mdadm.conf ] ; then
708                    LogIt "Running 'mdadm $i' with user supplied /etc/mdadm/mdadm.conf" 1
709                    mdadm -A $i -c /etc/mdadm/mdadm.conf
710                else
711                    LogIt "Running 'mdadm $i'" 1
712                    mdadm -Ac partitions -m dev $i
713                fi
[1747]714            fi
715        done
[2075]716    elif which dmraid > /dev/null 2> /dev/null ; then
[2072]717        if [ "`grep -i nodmraid /proc/cmdline`" ]; then
718            return;
719        fi
720        for x in $(/sbin/dmraid -ay -i -p -t 2>/dev/null | grep -E  -iv "^no " |awk -F ':' '{ print $1 }') ; do
721            echo "Please send the result of /sbin/dmraid -ay -i -p -t to the devteam !!!"
722            return
723            #dmname=$(resolve_dm_name $x)
724            #[ -z "$dmname" ] && continue
725            #/sbin/dmraid  -ay -i -p "$dmname" >/dev/null 2>&1
726            #/sbin/kpartx -a -p p "/dev/mapper/$dmname"
727        done
[623]728    else
729        LogIt "Warning: Neither 'raidstart' nor 'mdrun''found. RAID devices may not have started." 1
730    fi
731
[1]732}
733
734
735TryAgainToFindCD() {
[1747]736    local res
737    mount | grep /mnt/cdrom && return 0
[3274]738    [ "`grep "backup_media_type" /tmp/mondorestore.cfg 2> /dev/null | grep "cdstream"`" ] && return
[1747]739    LogIt "Trying to mount CD-ROM a 2nd time..."
740    find-and-mount-cdrom --second-try
741    res=$?
742    if [ "$res" -eq "0" ] ; then
743        CD_MOUNTED_OK=yes
744        LogIt "CD-ROM drive mounted successfully." 1
745    else
746        LogIt "I still cannot find or mount the CD-ROM drive, by the way."
747    fi
[1]748}
749
750
751
752UseTmpfs()
753{
[1747]754    local mount_cmd
755    echo -en "Mounting /tmp/tmpfs..."
756    mkdir -p /tmp/tmpfs
[1]757# For technical reasons, some sets are as large as 16MB.
758# I am allowing 32MB because selective restore occupies a lot of space.
[3035]759    for size in 256m 128m 64m 48m 40m 32m ; do
[1747]760        mount_cmd="mount /dev/shm -t tmpfs -o size=$size" ; # was 34m until 04/2003
761        LogIt "Trying '$mount_cmd'"
762        $mount_cmd /tmp/tmpfs 2>> $LOGFILE
763        res=$?
764        [ "$res" -eq "0" ] && break
765    done
766    if [ "$res" -ne "0" ] ; then
767        LogIt "Failed. I could not run '$mount_cmd /tmp/tmpfs'. Your kernel is BROKEN or you do not have enough RAM." 1
768        umount /tmp/tmpfs > /dev/null 2> /dev/null
769        rmdir /tmp/tmpfs
[3274]770        ln -sf /mnt/RESTORING/tmp /tmp/tmpfs; # used by mondorestore
[1747]771        LogIt "Failed to mount /tmp/tmpfs; using ugly softlink instead"
772    else
773        LogIt "Great. Pivot succeeded w/ size=$size" 1
774        echo -en "Pivoting /tmp..."
775        umount /tmp/tmpfs
776        mkdir -p /tmp.old
[1752]777        mv /tmp/* /tmp.old/
778        # Try to Deal with a busybox bug on inexistant links
[3454]779        cp /tmp/* /tmp.old/ 2> /dev/null
[1747]780        rm -f /tmp/*
781        $mount_cmd /tmp
[3454]782        mv /tmp.old/* /tmp/ 2> /dev/null
[1752]783        # Try to Deal with a busybox bug on inexistant links
[3454]784        cp /tmp.old/* /tmp/ 2> /dev/null
[1747]785        rm -rf /tmp.old
786        mkdir -p /tmp/tmpfs
[3697]787        mkdir -p $EXTRACTDIR
[1]788    echo "Done."
789    LogIt "Successfully mounted dynamic /tmp ramdisk"
790#   mkdir -p /tmp/tmpfs/var
791#        mv -f /var/log /tmp/tmpfs/var/log
792#        ln -sf /tmp/tmpfs/var/log /var/log
[1747]793    fi
[1]794}
795
796
797WelcomeMessage()
798{
[1747]799    echo "********************************************************************"
800    echo "MINDI-LINUX by Mondo Dev Team - web site: http://www.mondorescue.org"
801    echo "Boot disk based on AlfaLinux & Trinux. BusyBox by Erik Andersen."
[1]802which petris > /dev/null 2> /dev/null && echo "Petris was written by Peter Seidler <p.seidler@mail1.stofanet.dk>."
[1747]803    echo "Executables and source code are covered by the GNU GPL. No warranty."
804    echo "running on $ARCH"
805    echo "********************************************************************"
[1]806}
807
808EnableCcissIfAppropriate() {
[2908]809    local f
[2913]810
811    # In some cases, the OBDR tape remains in CD-ROM mode. This branch solves that issue (#498)
[3274]812    if [ "`grep -i 'obdr ' /tmp/mondorestore.cfg 2>/dev/null`" ] && [ -x /usr/bin/hpsa_obdr_mode ]; then
[2925]813        for lun in `/usr/bin/hpsa_obdr_mode -m query /dev/cciss/* 2>&1 | grep "is an OBDR device" | cut -d' ' -f4`; do
[2913]814            /usr/bin/hpsa_obdr_mode -m query -l $lun /dev/cciss/* 2>&1 | grep -q "is in CD-ROM mode"
815            if [ $? -eq 0 ]; then
816                # This tape/lun should be brought back in Sequential mode
817                LogIt "Putting back tape $lun in Sequential mode..."
818                /usr/bin/hpsa_obdr_mode -m tape -l $lun /dev/cciss/* 2>&1 > /dev/null
819            fi
820        done
821    fi
822
823    # Now engage all Smart Array controllers to detect attached devices
[2955]824    if [ -d  "/proc/driver/cciss" ]; then
825        for f in /proc/driver/cciss/cciss* ; do
826            LogIt "Engaging $f"
827            echo "engage scsi" > $f
828            LogIt "...result=$?"
829        done
830    fi
[1]831}
832
[1802]833ModprobeAllModules() {
[1]834
[3278]835    echo "Searching for modules to install..."
[3310]836    if [ ! -e /tmp/modules ]; then
837        LogIt "Unable to find the modules list. Computing one. This may take some time..."
838        lismod=`find /lib/modules -name '*\.ko*' -o -name '*\.o*'`
839        for m in $lismod; do
840            k=`basename $m | sed 's/\.ko.*$//'`
841            j=`basename $k | sed 's/\.o.*$//'`
842            echo "$j" >> /tmp/modules
843        done
844    fi
[2562]845    # loading forced modules first
[3310]846    for j in `cat /tmp/modules`; do
[2562]847        echo "$FORCE_MODS" | grep -q "$j "
848        if [ $? -eq 0 ]; then
849            echo "Forcing first $j..."
[2964]850            modprobe -q $j 2> /dev/null
[2562]851        fi
852    done
[3310]853    for j in `cat /tmp/modules`; do
[1830]854        echo "$DENY_MODS" | grep -q "$j "
[1829]855        if [ $? -eq 0 ]; then
[1830]856            echo "Denying $j..."
[1829]857            continue
858        fi
[2562]859        echo "$FORCE_MODS" | grep -q "$j "
860        if [ $? -eq 0 ]; then
861            continue
862        fi
[1829]863        echo "Probing $j..."
[2964]864        modprobe -q $j 2> /dev/null
[1802]865    done
866}
867
[2755]868UdevadmTrigger() {
[2844]869
[2965]870# This function should just echo the return value $ua
871
[2844]872if [ -x /sbin/udevadm ]; then
[2965]873    ua="/sbin/udevadm"
874elif [ -x /usr/bin/udevadm ]; then
875    ua="/usr/bin/udevadm"
876else
877    LogIt "WARNING: Unable to find udevadm. Not triggering udev"
878    ua="/bin/true"
879fi
880
881v="`$ua --version`"
882
883if [ -x "$v" ]; then
884    LogIt "Triggering udev again..."
885    if [ "$v" -ge "146" -a "$v" -lt "174" ]; then
886        $ua trigger --type=failed
887    elif [ "$v" -lt "146" ]; then
888        $ua trigger --retry-failed
[2755]889    else
[2965]890        LogIt "... not needed"
[2755]891    fi
[2844]892fi
[2965]893echo $ua
[2755]894}
895
[287]896ExtractDataDisksAndLoadModules() {
[2846]897    LogIt "Installing additional tools ..." 1
[3430]898    # TODO: test return value
[287]899    install-additional-tools
[2081]900
901    # Retry failed udev events now that local filesystems are mounted read-write
902    # (useful for rules creating network ifcfg files)
903    if [ -e "/tmp/USE-UDEV" ] ; then
[2965]904        ua=`UdevadmTrigger`
[2081]905    fi
[287]906}
[1]907
908# ------------------------ main -----------------------
909
[1698]910MINDI_VER=PBVER
911MINDI_REV=PBREV
[1]912trap CaughtSoftReset SIGTERM
[2964]913trap GetShell SIGINT
[1643]914LOGFILE=/var/log/mondorestore.log
[1236]915PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/mondo:/usr/games
[3697]916EXTRACTDIR=/tmp/extract
[1]917USER=root
[2163]918ARCH=`uname -m`
[1]919
[3697]920export PATH EXTRACTDIR USER LOGFILE ARCH
[2163]921
[3310]922mount -o remount,rw /
[3274]923rm -f $LOGFILE
[898]924
[3277]925mkdir /proc 2> /dev/null
926mount /proc /proc -t proc
927
[3274]928# Creates log file
929LogIt ""
[3279]930# Backup fd
931exec 4>&2 5>&1
[3277]932# Redirect every message to the LOGFILE
933exec > >(tee -a ${LOGFILE})
934exec 2> >(tee -a ${LOGFILE} >&2)
935
[3278]936echo "Welcome to init (from mindi ${MINDI_VER}-r${MINDI_REV})"
[3274]937
938mkdir /sys 2> /dev/null
[3277]939mount /sys /sys -t sysfs
[3274]940
[3697]941for i in $EXTRACTDIR /mnt/cdrom /mnt/isodir /var/local/petris /tmp/isodir; do
[1747]942    mkdir -p $i
[1]943done
[1824]944# For ESX 3
945[ -d /proc/vmware ] && ! grep -q /vmfs /proc/mounts && mount -t vmfs /vmfs /vmfs
[1]946
[1829]947if [ "`grep -i denymods /proc/cmdline`" ]; then
948    export DENY_MODS="`cat /proc/cmdline | sed 's~.*denymods=\"\(.*\)\".*~\1~'` mondonone"
[1830]949else
950    export DENY_MODS=" "
[1829]951fi
[3274]952if [ "`grep -i 'obdr ' /tmp/mondorestore.cfg 2> /dev/null`" ]; then
[1958]953    # Do not try to load usb storage when dealing with OBDR it makes the modprobe hang :-(
[1960]954    export DENY_MODS="usb-storage $DENY_MODS"
[1958]955fi
[1829]956if [ "`grep -i forcemods /proc/cmdline`" ]; then
957    export FORCE_MODS="`cat /proc/cmdline | sed 's~.*forcemods=\"\(.*\)\".*~\1~'` mondonone"
[1830]958else
959    export FORCE_MODS=" "
[1829]960fi
[1826]961echo "Activating a potential USB keyboard/mouse"
[1787]962StartUSBKbd
963
[1720]964if [ -f /proc/sys/kernel/exec-shield ]; then
965    echo 0 > /proc/sys/kernel/exec-shield 2>> /dev/null
966fi
[1]967
[1729]968if [ -f /proc/modules ]; then
969    echo "/sbin/modprobe" > /proc/sys/kernel/modprobe
970fi
971
[1716]972if [ -e "/tmp/USE-UDEV" ] ; then
[1747]973    RunUdevd
[1716]974fi
[1798]975ExtractDevTarballs
[1]976LaunchTerminals
[1718]977
[3274]978# Keeping kernel silent for module insertion
[1789]979PKLVL=`cut -f1 /proc/sys/kernel/printk`
980echo 0 > /proc/sys/kernel/printk
[1922]981ModprobeAllModules
[1789]982echo $PKLVL > /proc/sys/kernel/printk
[1718]983
[1]984EnableCcissIfAppropriate
985#-------------------------------
986#WHOLIVESINAPINEAPPLEUNDERTHESEA#;# --- don't touch this :)
987#-------------------------------
988UseTmpfs
[3274]989if [ ! -e "/tmp/mondorestore.cfg" ] ; then
[3526]990    LogIt "WARNING: /tmp/mondorestore.cfg not found - forging an empty one"
991    LogIt "         Hopefully this is a Mindi media"
992    touch /tmp/mondorestore.cfg
[1]993fi
[3661]994if [ "`grep -i pxe /proc/cmdline`" ] || [ "`grep -i net /proc/cmdline`" ] || [ "`grep 'netfs-proto ' /tmp/mondorestore.cfg`" ] || [ "`grep -i drbd /proc/cmdline`" ]; then
[2380]995    # We need to get here exported variables from start-netfs
[3324]996    . /usr/sbin/start-netfs
[2182]997fi
[1]998
[3274]999if [ "`grep -i 'obdr ' /tmp/mondorestore.cfg 2>/dev/null`" ] || [ "`grep -i ' udev' /tmp/mondorestore.cfg 2>/dev/null`" ]; then
[1747]1000    HandleTape
[287]1001    ExtractDataDisksAndLoadModules
[737]1002elif [ "`grep -i pxe /proc/cmdline`" ]; then
[287]1003    # Simulate a local CD
1004    echo "/mnt/cdrom" > /tmp/CDROM-LIVES-HERE
[1747]1005    CD_MOUNTED_OK=yes
[287]1006    ExtractDataDisksAndLoadModules
[2182]1007    # Fake the conf file to force it to NFS mode, even if we made originally a CD (mandatory for mondorestore to work correctly)
[3274]1008    sed -i "s/backup-media-type.*/backup-media-type netfs/" /tmp/mondorestore.cfg
1009elif [ "`grep -i usb= /proc/cmdline`" ] || [ "`grep -i usb /tmp/mondorestore.cfg 2>/dev/null | grep media-type`" ]; then
[3324]1010    . /usr/sbin/start-usb
[1698]1011
1012    # Simulate a local CD
1013    echo "/mnt/cdrom" > /tmp/CDROM-LIVES-HERE
[1747]1014    CD_MOUNTED_OK=yes
[1698]1015    ExtractDataDisksAndLoadModules
[1]1016else
[1885]1017    HandleCDROM
[287]1018    ExtractDataDisksAndLoadModules
[1]1019fi
1020res=$?
1021ConfigureLoggingDaemons
1022if [ -e "/tmp/USE-DEVFS" ] ; then
[2878]1023    umount -d /mnt/cdrom 2> /dev/null
[1747]1024    mv /dev/cdrom /cdrom.lnk 2> /dev/null
1025    CD_MOUNTED_OK=""
1026    RunDevfsd
[1]1027fi
[3441]1028
1029if [ "`grep -i excludedevs /proc/cmdline`" ]; then
1030    export MINDI_EXCLUDE_DEVS="`cat /proc/cmdline | sed 's~.*excludedevs=\"\(.*\)\".*~\1~'` mondonone"
1031    for d in $MINDI_EXCLUDE_DEVS ; do
1032        echo "Mountlist exclusion == $d"
1033        if [ -e "/tmp/mountlist.txt" ]; then
1034            perl -i -ne 'print $_ unless m~$d~' /tmp/mountlist.txt
1035        fi
1036    done
1037else
1038    export MINDI_EXCLUDE_DEVS=" "
1039fi
1040
[1813]1041LoadKeymap
1042WelcomeMessage
1043RstHW
[2559]1044echo "Starting potential Raid/Multipath ..."
[2580]1045[ -e "/tmp/mountlist.txt" ] && cp -f /tmp/mountlist.txt /tmp/mountlist.original
[1]1046PauseForRaids
1047StartRaids
[2072]1048StartMpath
[3661]1049StartDRBD
[3639]1050# avoids messagesa round leaked fd - Cf lvm man page
1051export LVM_SUPPRESS_FD_WARNINGS=1
[1]1052StartLvms
1053CopyBootDevEntry
1054mkdir -p /tmp/tmpfs
1055sleep 2
1056#clear
[3203]1057if [ -e "/dev/md0" ] && [ ! -e "/dev/md/0" ] && [ -e "/tmp/mountlist.txt" ] && [ "`grep /dev/md/ /tmp/mountlist.txt`" != "" ] ; then
[1747]1058    LogIt "Creating /dev/md/* softlinks just in case." 1
1059    mkdir -p /dev/md
1060    cp -af /dev/md0 /dev/md/0 2> /dev/null
1061    cp -af /dev/md1 /dev/md/1 2> /dev/null
1062    cp -af /dev/md2 /dev/md/2 2> /dev/null
[1]1063fi
1064
[241]1065if ! [ "`grep -i "pxe" /proc/cmdline`" ] ; then
[1]1066    res="`cat /mnt/cdrom/archives/THIS-CD-NUMBER 2> /dev/null`"
1067    [ "$res" != "1" ] && [ "$res" != "" ] && Die "This is CD #$res in the series. Please insert CD #1."
1068    [ -e "/cdrom.lnk" ] && mv -f /cdrom.lnk /dev/cdrom && mount /dev/cdrom /mnt/cdrom && CD_MOUNTED_OK=yes
1069    [ "$CD_MOUNTED_OK" != "yes" ] && TryAgainToFindCD
1070    #mount | grep cdrom > /dev/null 2> /dev/null || mount /dev/cdrom /mnt/cdrom >> $LOGFILE 2>> $LOGFILE
1071fi
1072hack-cfg-if-necessary || LogIt "Cannot find hack-cfg-if-necessary"
1073
[1403]1074# Log some useful info
[1837]1075LogIt "init (from mindi v$MINDI_VER-r${MINDI_REV})"
[1413]1076LogIt "/proc/cmdline is:"
[2346]1077LogIt "----------"
[1403]1078cat /proc/cmdline  >> $LOGFILE
[2346]1079LogIt "----------"
[1413]1080LogIt "df result:"
1081LogIt "----------"
[1403]1082df >> $LOGFILE
[1413]1083LogIt "-------------"
1084LogIt "mount result:"
1085LogIt "-------------"
[1403]1086mount >> $LOGFILE
[1413]1087LogIt "-------------"
1088LogIt "lsmod result:"
1089LogIt "-------------"
[1403]1090lsmod >> $LOGFILE
[1413]1091LogIt "-------------"
[1476]1092LogIt "dmesg result:"
1093LogIt "-------------"
1094dmesg >> $LOGFILE
[2015]1095LogIt "-------------"
[2979]1096LogIt "/proc/mdstat:" >> $LOGFILE
1097LogIt "-------------"
1098cat /proc/mdstat  >> $LOGFILE
1099LogIt "-------------"
[2015]1100LogIt "/proc/swaps:" >> $LOGFILE
1101LogIt "-------------"
1102cat /proc/swaps  >> $LOGFILE
1103LogIt "-------------"
1104LogIt "/proc/filesystems:" >> $LOGFILE
1105LogIt "-------------"
1106cat /proc/filesystems  >> $LOGFILE
1107LogIt "-------------"
1108LogIt "/proc/partitions:" >> $LOGFILE
1109LogIt "-------------"
1110cat /proc/partitions  >> $LOGFILE
[2346]1111LogIt "-------------"
1112LogIt "fdisk result:" >> $LOGFILE
1113LogIt "-------------"
1114fdisk -l  >> $LOGFILE
[2768]1115LogIt "-------------"
[3274]1116if [ -f /tmp/mondorestore.cfg ]; then
1117    LogIt "/tmp/mondorestore.cfg result:" >> $LOGFILE
[2832]1118    LogIt "-------------"
[3274]1119    cat /tmp/mondorestore.cfg  >> $LOGFILE
[2832]1120fi
[1403]1121
[1983]1122ide-opt
[1]1123
1124#ctrlaltdel soft
1125for i in null stdout stdin stderr ; do
[1747]1126    cp -af /dev/$i /tmp
[1]1127done
[2081]1128# Not sure it's still needed, but shouldn't hurt
1129if [ -e "/tmp/USE-UDEV" ] ; then
[2965]1130    ua=`UdevadmTrigger`
[2081]1131fi
[3274]1132if grep "backup-media-type" /tmp/mondorestore.cfg > /dev/null 2> /dev/null ; then
[1747]1133    LogIt "backup-media-type is specified in config file - great."
[2197]1134    LogIt "Calling post-init"
[2380]1135    # start-netfs moved it under /tmp as the NFS share is already unmounted
[3210]1136    if [ _"$pre" != _"" ] && [ "`echo $pre | grep -E '^/tmp/isodir'`" ]; then
[2533]1137        pre=`echo $pre | sed 's|^/tmp/isodir|/tmp|'`
[2255]1138    fi
[3210]1139    if [ _"$pre" != _"" ] && [ -x $pre ]; then
[2255]1140        echo "Executing preliminary script $pre"
1141        LogIt "Executing preliminary script $pre"
1142        $pre
1143    fi
[1747]1144    post-init
[1]1145else
[1747]1146    LogIt "backup-media-type is not specified in config file."
[1885]1147    LogIt "I think this media has no archives on it."
[1]1148fi
[2255]1149if [ "`grep -i "post=" /proc/cmdline`" ] ; then
[2249]1150    for i in `cat /proc/cmdline` ; do
[3210]1151        echo $i | grep -qi post= && post=`echo $i | cut -d= -f2`
[2249]1152    done
[2380]1153    # start-netfs moved it under /tmp as the NFS share is already unmounted
[2255]1154    if [ "`echo $post | grep -E '^/tmp/isodir'`" ]; then
1155        post=`echo $post | sed 's|^/tmp/isodir|/tmp|'`
[2253]1156    fi
[2581]1157    if [ -r $post ]; then
[2255]1158        echo "Executing final script $post"
1159        LogIt "Executing final script $post"
1160        if [ "`echo $post | grep -E '^/mnt/RESTORING'`" ]; then
[3542]1161            mr-mount-me
[2253]1162        fi
[2581]1163        chmod 755 $post
[2255]1164        $post
1165        if [ "`echo $post | grep -E '^/mnt/RESTORING'`" ]; then
[3542]1166            mr-unmount-me
[2253]1167        fi
[2249]1168    fi
1169fi
[1612]1170if grep "RESTORE" /proc/cmdline > /dev/null 2> /dev/null ; then
1171    echo "Rebooting in 10 seconds automatically as per reboot order"
1172    echo -en "Press ^C to interrupt if you have to ..."
1173    for i in 1 2 3 4 5 6 7 8 9 10 ; do
1174        sleep 1
1175        echo -en "."
1176    done
1177    echo "Boom."
1178    sleep 1
1179else
[2888]1180    GetShell
[1612]1181fi
[1]1182CaughtSoftReset
Note: See TracBrowser for help on using the repository browser.