Changeset 3319 in MondoRescue for branches/3.0/mindi/rootfs/etc/init.d/rcS


Ignore:
Timestamp:
Dec 1, 2014, 11:35:39 PM (9 years ago)
Author:
Bruno Cornec
Message:
  • Backport most mindi modifications done in the 3.2 branch into 3.0 in order to have soon a 2.1.8 version which is probably Fedora 17+ compatible (all modifications up to 2014-10-16)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.0/mindi/rootfs/etc/init.d/rcS

    r3244 r3319  
    55# init script launched during the restore process
    66#------------------------------------------------------------
    7 
    87
    98CaughtSoftReset() {
     
    7574ExtractDevTarballs() {
    7675    cd /
    77     for fname in ataraid.tgz ida.tgz i2o.tgz rd.tgz raw.tgz cciss.tgz nst.tgz dm.tgz vc.tgz ; do
    78         if [ ! -e "/$fname" ] ; then
    79             LogIt "/$fname not found; cannot extract to /." 1
    80         else
    81             echo -en "\rExtracting /$fname...     "
    82             tar -zxf /$fname || LogIt "Error occurred while extracting /$fname"
    83         fi
    84     done
     76    if [ -x /usr/lib/systemd/systemd-udevd ]; then
     77        # Just use vc dev files. The other are useless and create huge delays with LVM
     78        tar -zxf /vc.tgz || LogIt "Error occurred while extracting /vc.tgz"
     79    else
     80        for fname in ataraid.tgz ida.tgz i2o.tgz rd.tgz raw.tgz cciss.tgz nst.tgz dm.tgz vc.tgz ; do
     81            if [ ! -e "/$fname" ] ; then
     82                LogIt "/$fname not found; cannot extract to /." 1
     83            else
     84                echo -en "\rExtracting /$fname...     "
     85                tar -zxf /$fname || LogIt "Error occurred while extracting /$fname"
     86            fi
     87        done
     88    fi
    8589    echo -en "\r"
    8690    LogIt "Extracted additional /dev entries OK.     " 1
     
    98102        opt="-c"
    99103    fi
     104    echo "Launching terminals on other ttys - Use ALT+F[2-6] to use them"
    100105    openvt $opt 2 /bin/sh
    101106    openvt $opt 3 /bin/sh
     
    105110    openvt $opt 7 /bin/sh /sbin/wait-for-petris
    106111    openvt $opt 8 /usr/bin/tail -f $LOGFILE
    107     openvt $opt 9 /usr/bin/tail -f /var/log/messages
     112    if [ -f /var/log/messages ]; then
     113        openvt $opt 9 /usr/bin/tail -f /var/log/messages
     114    fi
    108115    # May avoid shell error messages
    109116    chmod 666 /dev/tty* /dev/console
    110117    # By default first serial line is configured as tty
    111     # Required to have a correct serial console support (MP on ia64 or VSP with iLO2 e.g.)
     118    # Required to have a correct serial console support (MP on ia64 or VSP with iLO e.g.)
    112119    for i in `cat /proc/cmdline` ; do
    113120        echo $i | grep -qi serial= && serial=`echo $i | cut -d= -f2`
    114121    done
    115122    # Doing that is only valid when using a real serial line
    116     if [[ $serial != "" && -e $serial ]]; then
     123    if [[ $serial != "" && -e $serial ]]; then
    117124        LogIt "Redirecting serial $serial to /dev/tty" 1
    118125        ln -s -f $serial /dev/tty
     
    288295    fi
    289296    if [ "$res" -eq "0" ] ; then
    290         LogIt "OK, I am running on a CD-ROM. Good." 3
     297        LogIt "OK, I am running on a CD-ROM. Good." 1
    291298        CD_MOUNTED_OK=yes
    292299    else
    293         LogIt "You probably not have the right drivers" 3
    294         LogIt "to support the hardware on which we are running" 3
    295         LogIt "Your archives are probably fine but" 3
    296         LogIt "your tape streamer and/or CD-ROM drive are unsupported at that point." 3
     300        LogIt "You probably not have the right drivers" 1
     301        LogIt "to support the hardware on which we are running" 1
     302        LogIt "Your archives are probably fine but" 1
     303        LogIt "your tape streamer and/or CD-ROM drive are unsupported at that point." 1
    297304        CD_MOUNTED_OK=""
    298305    fi
     
    324331    if [ ! -e "/dev/.devfsd" ] ; then
    325332        mount -t devfs devfs /dev 2>> $LOGFILE
    326             if [ "$?" -ne "0" ] ; then
    327         LogIt "Error while trying to mount devfs"
     333        if [ "$?" -ne "0" ] ; then
     334            LogIt "Error while trying to mount devfs"
    328335        else
    329         LogIt "Devfs mounted OK"
     336            LogIt "Devfs mounted OK"
    330337        fi
    331338    fi
     
    372379
    373380RunUdevd() {
    374     # Inspiration from Mandriva 2008.0 startup script
    375     echo "Preparing udev environment..."
    376     LogIt "Preparing udev environment..."
     381    # Initial Inspiration from Mandriva 2008.0 startup script
     382    LogIt "Preparing udev environment..." 1
    377383    mv /dev /dev.static
    378384    mkdir /dev
    379     mount -n -o size=5M,mode=0755 -t tmpfs none /dev
    380     MakeExtraNodes
    381     mount -n -t devpts -o mode=620 none /dev/pts
     385    # Contributed during LinuxCon Japan !
     386    if [ -x /usr/lib/systemd/systemd-udevd ]; then
     387        mount -n -t devtmpfs none /dev
     388    else
     389        mount -n -o size=5M,mode=0755 -t tmpfs none /dev
     390        MakeExtraNodes
     391        mount -n -t devpts -o mode=620 none /dev/pts
     392    fi
     393    mkdir -p /dev/shm
    382394    mount -n -t tmpfs  none /dev/shm
    383395    if [ -e /proc/sys/kernel/hotplug ]; then
     
    396408    ps | grep -v grep |grep udevd 2> /dev/null 1> /dev/null
    397409    if [ $? -ne 0 ]; then
     410        echo "Waiting for udev to start..."
    398411        if [ -x /sbin/udevd ]; then
    399412            /sbin/udevd --daemon &
     
    401414            /usr/bin/udevd --daemon &
    402415        elif [ -x /usr/lib/systemd/systemd-udevd ]; then
    403             /usr/lib/systemd/systemd-udevd -daemon &
    404         fi
    405         echo "Waiting for udev to start..."
     416            # from https://github.com/hut/minirc/blob/master/rc
     417            echo "INFO: This is the systemd version of udev"
     418            # Contributed during LinuxCon Japan
     419            #mount -n -t tmpfs tmpfs /sys/fs/cgroup
     420            #mount -n -t cgroup cgroup /sys/fs/cgroup/systemd
     421            mkdir -p /run/udev
     422            mkdir -p /run/systemd/journal
     423            /usr/lib/systemd/systemd-udevd --daemon
     424            udevadm trigger --action=add --type=subsystems
     425            udevadm trigger --action=add --type=devices
     426        fi
    406427        sleep 5
    407         LogIt "udev started manually"
     428        LogIt "udev started manually" 1
    408429    fi
    409430    mkdir -p /dev/.udev/queue/
     
    481502    fi
    482503    if [ -e "/tmp/i-want-my-lvm" ] ; then
     504        # Recent LVM need this caching daemon to work
     505        if [ -x /usr/sbin/lvmetad ]; then
     506            mkdir -p /run/lvm
     507            /usr/sbin/lvmetad
     508        fi
    483509        LogIt "Scanning LVM's..." 1
    484510        if which lvm ; then
     
    494520        for d in $MINDI_EXCLUDE_DEVS ; do
    495521            echo "LVM exclusion == $d"
     522            # LVM: $4 to be checked if changed
    496523            EXCLUDE_VGS=`grep " $d" /tmp/i-want-my-lvm | grep vgcreate | awk '{print $4}'`
    497524            vg=`echo $EXCLUDE_VGS | sed "s/ /|/g"`
     
    508535                echo "vgcfgrestore $v" >> /tmp/restorevgs
    509536                # Remove LVs from mountlist
     537                # LVM: sed to be checked if changed
    510538                EXCLUDE_LVS=`grep " $v" /tmp/i-want-my-lvm | grep lvcreate | sed "s/^.*-n \([^ ][^ ]*\) .*$/$1/"`
    511539                for l in $EXCLUDE_LVS; do
    512540                    # FIXME: Should search for all possible device names here
    513                     grep -Ev "/dev/$v/$l" /tmp/mountlist.txt > /tmp/mountlist.txt.new
    514                     grep -Ev "/dev/mapper/${v}-$l" /tmp/mountlist.txt.new > /tmp/mountlist.txt
     541                    if [ -f "/tmp/mountlist.txt" ]; then
     542                        grep -Ev "/dev/$v/$l" /tmp/mountlist.txt > /tmp/mountlist.txt.new
     543                        grep -Ev "/dev/mapper/${v}-$l" /tmp/mountlist.txt.new > /tmp/mountlist.txt
     544                    fi
    515545                done
    516546            done
    517547        done
    518548
     549        # LVM: remove #
    519550        grep -E "^#.*vgchange" /tmp/i-want-my-lvm | sed "s/^#[ ]*//" > /tmp/start-lvm
    520551        chmod +x /tmp/start-lvm
     
    577608        return;
    578609    fi
    579     if [ "`grep mpath /tmp/mountlist.txt`" ]; then
     610    if [ -f "/tmp/mountlist.txt" ] && [ "`grep mpath /tmp/mountlist.txt`" ]; then
    580611        if [ -x /sbin/multipath ]; then
    581612            echo "Starting Mpath..."
     
    602633    fi
    603634
    604     raid_devices=`grep /dev/md /tmp/mountlist.txt | cut -d' ' -f1`
     635    if [ -f "/tmp/mountlist.txt" ]; then
     636        raid_devices=`grep /dev/md /tmp/mountlist.txt | cut -d' ' -f1`
     637    else
     638        raid_devices=""
     639    fi
     640
    605641    if which raidstart > /dev/null 2> /dev/null ; then
    606642        for i in $raid_devices ; do
     
    693729        umount /tmp/tmpfs > /dev/null 2> /dev/null
    694730        rmdir /tmp/tmpfs
    695         ln -sf /mnt/RESTORING/tmp /tmp/tmpfs; # used by mondo-restore
     731        ln -sf /mnt/RESTORING/tmp /tmp/tmpfs; # used by mondorestore
    696732        LogIt "Failed to mount /tmp/tmpfs; using ugly softlink instead"
    697733    else
     
    845881export PATH GROOVY USER LOGFILE ARCH
    846882
     883mount -o remount,rw /
     884rm -f $LOGFILE
     885
     886mkdir /proc 2> /dev/null
     887mount /proc /proc -t proc
     888
     889# Creates log file
     890LogIt ""
     891# Backup fd
     892exec 4>&2 5>&1
     893# Redirect every message to the LOGFILE
     894exec > >(tee -a ${LOGFILE})
     895exec 2> >(tee -a ${LOGFILE} >&2)
     896
    847897echo "Welcome to init (from mindi ${MINDI_VER}-r${MINDI_REV})"
    848898
    849 mount -o remount rw /
     899mkdir /sys 2> /dev/null
     900mount /sys /sys -t sysfs
     901
    850902[ ! "$GROOVY" ] && Die "I'm not groovy!"
    851903for i in $GROOVY /mnt/cdrom /mnt/isodir /var/local/petris /tmp/isodir; do
    852904    mkdir -p $i
    853905done
    854 #/bin/update
    855 mkdir /proc 2> /dev/null
    856 mount /proc/ /proc -v -t proc
    857 mkdir /sys 2> /dev/null
    858 mount /sys/ /sys -v -t sysfs 2>> $LOGFILE
    859906# For ESX 3
    860907[ -d /proc/vmware ] && ! grep -q /vmfs /proc/mounts && mount -t vmfs /vmfs /vmfs
     
    879926    for d in $MINDI_EXCLUDE_DEVS ; do
    880927        echo "Mountlist exclusion == $d"
    881         perl -i -ne 'print $_ unless m~$d~' /tmp/mountlist.txt
     928        if [ -e "/tmp/mountlist.txt" ]; then
     929            perl -i -ne 'print $_ unless m~$d~' /tmp/mountlist.txt
     930        fi
    882931    done
    883932else
     
    902951LaunchTerminals
    903952
    904 # Keeping kernel silent  for module insertion
     953# Keeping kernel silent for module insertion
    905954PKLVL=`cut -f1 /proc/sys/kernel/printk`
    906955echo 0 > /proc/sys/kernel/printk
     
    9651014sleep 2
    9661015#clear
    967 if [ -e "/dev/md0" ] && [ ! -e "/dev/md/0" ] && [ "`grep /dev/md/ /tmp/mountlist.txt`" != "" ] ; then
     1016if [ -e "/dev/md0" ] && [ ! -e "/dev/md/0" ] && [ -e "/tmp/mountlist.txt" ] && [ "`grep /dev/md/ /tmp/mountlist.txt`" != "" ] ; then
    9681017    LogIt "Creating /dev/md/* softlinks just in case." 1
    9691018    mkdir -p /dev/md
     
    10441093    LogIt "Calling post-init"
    10451094    # start-netfs moved it under /tmp as the NFS share is already unmounted
    1046     if [ "`echo $pre | grep -E '^/tmp/isodir'`" ]; then
     1095    if [ _"$pre" != _"" ] && [ "`echo $pre | grep -E '^/tmp/isodir'`" ]; then
    10471096        pre=`echo $pre | sed 's|^/tmp/isodir|/tmp|'`
    10481097    fi
    1049     if [ -x $pre ]; then
     1098    if [ _"$pre" != _"" ] && [ -x $pre ]; then
    10501099        echo "Executing preliminary script $pre"
    10511100        LogIt "Executing preliminary script $pre"
     
    10591108if [ "`grep -i "post=" /proc/cmdline`" ] ; then
    10601109    for i in `cat /proc/cmdline` ; do
    1061         echo $i | grep -qi post= && post=`echo $i | cut -d= -f2`
     1110        echo $i | grep -qi post= && post=`echo $i | cut -d= -f2`
    10621111    done
    10631112    # start-netfs moved it under /tmp as the NFS share is already unmounted
Note: See TracChangeset for help on using the changeset viewer.