Changeset 2329 in MondoRescue for branches/2.2.10/mindi/rootfs/sbin/init


Ignore:
Timestamp:
Aug 18, 2009, 3:20:46 PM (15 years ago)
Author:
Bruno Cornec
Message:

r3340@localhost: bruno | 2009-08-12 00:17:29 +0200
Improve portability by defining all cmdline usage in 1 include (/tmp for FreeBSD and /proc fior LInux). Also doing tht for scripts.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.10/mindi/rootfs/sbin/init

    r2286 r2329  
    55# init script launched during the restore process
    66#------------------------------------------------------------
     7
     8if [ -e "/proc/cmdline" ]; then
     9    export CMDLINE="/proc/cmdline"
     10elif [ -e "/tmp/cmdline" ]; then
     11    export CMDLINE="/tmp/cmdline"
     12else
     13    export CMDLINE="/dev/null"
     14fi
     15
    716
    817
     
    327336    answer="NO"
    328337
    329     grep -q nohw /proc/cmdline
     338    grep -q nohw $CMDLINE
    330339    if [ "$?" -eq 0 ]; then
    331340        return
    332341    fi
    333342    if [ -x ./mindi-rsthw ]; then
    334         grep -q RESTORE /proc/cmdline
     343        grep -q RESTORE $CMDLINE
    335344        if [ "$?" -ne 0 ]; then
    336345            #clear
     
    443452
    444453StartMpath() {
    445     if [ "`grep -i nompath /proc/cmdline`" ]; then
     454    if [ "`grep -i nompath $CMDLINE`" ]; then
    446455        return;
    447456    fi
     
    496505        done
    497506    elif which dmraid > /dev/null 2> /dev/null ; then
    498         if [ "`grep -i nodmraid /proc/cmdline`" ]; then
     507        if [ "`grep -i nodmraid $CMDLINE`" ]; then
    499508            return;
    500509        fi
     
    661670rm -f /foozero
    662671
    663 if [ "`grep -i denymods /proc/cmdline`" ]; then
    664     export DENY_MODS="`cat /proc/cmdline | sed 's~.*denymods=\"\(.*\)\".*~\1~'` mondonone"
     672if [ "`grep -i denymods $CMDLINE`" ]; then
     673    export DENY_MODS="`cat $CMDLINE | sed 's~.*denymods=\"\(.*\)\".*~\1~'` mondonone"
    665674else
    666675    export DENY_MODS=" "
     
    670679    export DENY_MODS="usb-storage $DENY_MODS"
    671680fi
    672 if [ "`grep -i forcemods /proc/cmdline`" ]; then
    673     export FORCE_MODS="`cat /proc/cmdline | sed 's~.*forcemods=\"\(.*\)\".*~\1~'` mondonone"
     681if [ "`grep -i forcemods $CMDLINE`" ]; then
     682    export FORCE_MODS="`cat $CMDLINE | sed 's~.*forcemods=\"\(.*\)\".*~\1~'` mondonone"
    674683else
    675684    export FORCE_MODS=" "
     
    707716    LogIt "Warning - /tmp/mondo-restore.cfg not found"
    708717fi
    709 if [ "`grep -i pxe /proc/cmdline`" ] || [ "`grep -i net /proc/cmdline`" ]; then
     718if [ "`grep -i pxe $CMDLINE`" ] || [ "`grep -i net $CMDLINE`" ]; then
    710719    # We need to get here exported variables from start-nfs
    711720    . /sbin/start-nfs
     
    715724    HandleTape
    716725    ExtractDataDisksAndLoadModules
    717 elif [ "`grep -i pxe /proc/cmdline`" ]; then
     726elif [ "`grep -i pxe $CMDLINE`" ]; then
    718727    # Simulate a local CD
    719728    echo "/mnt/cdrom" > /tmp/CDROM-LIVES-HERE
     
    722731    # Fake the conf file to force it to NFS mode, even if we made originally a CD (mandatory for mondorestore to work correctly)
    723732    sed -i "s/backup-media-type.*/backup-media-type nfs/" /tmp/mondo-restore.cfg
    724 elif [ "`grep -i usb= /proc/cmdline`" ] || [ "`grep -i usb /tmp/mondo-restore.cfg 2>/dev/null | grep media-type`" ]; then
     733elif [ "`grep -i usb= $CMDLINE`" ] || [ "`grep -i usb /tmp/mondo-restore.cfg 2>/dev/null | grep media-type`" ]; then
    725734    . /sbin/start-usb
    726735
     
    764773[ -e "/tmp/mountlist.txt" ] && cp -f /tmp/mountlist.txt /tmp/mountlist.original
    765774
    766 if ! [ "`grep -i "pxe" /proc/cmdline`" ] ; then
     775if ! [ "`grep -i "pxe" $CMDLINE`" ] ; then
    767776    res="`cat /mnt/cdrom/archives/THIS-CD-NUMBER 2> /dev/null`"
    768777    [ "$res" != "1" ] && [ "$res" != "" ] && Die "This is CD #$res in the series. Please insert CD #1."
     
    775784# Log some useful info
    776785LogIt "init (from mindi v$MINDI_VER-r${MINDI_REV})"
    777 LogIt "/proc/cmdline is:"
    778 cat /proc/cmdline  >> $LOGFILE
     786LogIt "$CMDLINE is:"
     787cat $CMDLINE  >> $LOGFILE
    779788LogIt "df result:"
    780789LogIt "----------"
     
    841850    LogIt "I think this media has no archives on it."
    842851fi
    843 if [ "`grep -i "post=" /proc/cmdline`" ] ; then
    844     for i in `cat /proc/cmdline` ; do
     852if [ "`grep -i "post=" $CMDLINE`" ] ; then
     853    for i in `cat $CMDLINE` ; do
    845854        echo $i | grep -qi post= && post=`echo $i | cut -d= -f2`
    846855    done
     
    861870    fi
    862871fi
    863 if grep "RESTORE" /proc/cmdline > /dev/null 2> /dev/null ; then
     872if grep "RESTORE" $CMDLINE > /dev/null 2> /dev/null ; then
    864873    echo "Rebooting in 10 seconds automatically as per reboot order"
    865874    echo -en "Press ^C to interrupt if you have to ..."
Note: See TracChangeset for help on using the changeset viewer.