Changeset 2329 in MondoRescue


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.

Location:
branches/2.2.10
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.10/mindi/mindi

    r2312 r2329  
    25612561    LVM="false"
    25622562fi
     2563
     2564if [ -e "/proc/cmdline" ]; then
     2565    CMDLINE="/proc/cmdline"
     2566elif [ -e "/tmp/cmdline" ]; then
     2567    CMDLINE="/tmp/cmdline"
     2568else
     2569    CMDLINE="/dev/null"
     2570fi
     2571
    25632572echo "LVM set to $LVM" >> $LOGFILE
    25642573echo "----------" >> $LOGFILE
     
    25742583fi
    25752584echo "-------------" >> $LOGFILE
    2576 echo "cat /proc/cmdline:" >> $LOGFILE
     2585echo "cat $CMDLINE" >> $LOGFILE
    25772586echo "-------------" >> $LOGFILE
    2578 cat /proc/cmdline >> $LOGFILE
     2587cat $CMDLINE >> $LOGFILE
    25792588echo "-------------" >> $LOGFILE
    25802589echo "cat /proc/swaps:" >> $LOGFILE
  • 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 ..."
  • branches/2.2.10/mindi/rootfs/sbin/post-init

    r2098 r2329  
    55#------------------------------------------------------------
    66
    7 
    87sleep 1
    98
     
    1110cat /tmp/mountlist.txt >> $LOGFILE
    1211
    13 iso=`grep iso /proc/cmdline`
    14 nuke=`grep nuke /proc/cmdline`
     12iso=`grep iso $CMDLINE`
     13nuke=`grep nuke $CMDLINE`
    1514if [ "$nuke" = "" ] ; then
    16     nuke=`grep -i "RESTORE " /proc/cmdline`
     15    nuke=`grep -i "RESTORE " $CMDLINE`
    1716fi
    18 expert=`grep expert /proc/cmdline`
    19 compare=`grep compare /proc/cmdline`
    20 interactive=`grep interactive /proc/cmdline`
    21 pxe=`grep pxe /proc/cmdline`
     17expert=`grep expert $CMDLINE`
     18compare=`grep compare $CMDLINE`
     19interactive=`grep interactive $CMDLINE`
     20pxe=`grep pxe $CMDLINE`
    2221[ "$interactive" ]  && expert=""; # in case 'expert' crops up somewhere
    2322if which mondorestore > /dev/null 2> /dev/null ; then
     
    6261fi
    6362
    64 if [ "`grep -i 'debug' /proc/cmdline`" ]; then
     63if [ "`grep -i 'debug' $CMDLINE`" ]; then
    6564    mondoopt="$mondoopt -K 99"
    6665fi
  • branches/2.2.10/mindi/rootfs/sbin/start-nfs

    r2255 r2329  
    3030
    3131# info from cmdline are predominent
    32 for i in `cat /proc/cmdline` ; do
     32for i in `cat $CMDLINE` ; do
    3333    echo $i | grep -qi ping= && ipcount=`echo $i | cut -d= -f2`
    3434    echo $i | grep -qi ipconf= && ipconf=`echo $i | cut -d= -f2`
  • branches/2.2.10/mindi/rootfs/sbin/start-usb

    r2127 r2329  
    1010
    1111# info from cmdline are predominent
    12 for i in `cat /proc/cmdline` ; do
     12for i in `cat $CMDLINE` ; do
    1313    echo $i | grep -qi usb= && MRUSBDEV=`echo $i | cut -d= -f2`
    1414done
  • branches/2.2.10/mondo/src/common/libmondo-devices.c

    r2328 r2329  
    732732
    733733    if (found_it) {
    734         mr_asprintf(tmp1, "grep \"%s=ide-scsi\" /proc/cmdline &> /dev/null", strrchr(output, '/') + 1);
     734        mr_asprintf(tmp1, "grep \"%s=ide-scsi\" " CMDLINE " &> /dev/null", strrchr(output, '/') + 1);
    735735        if (system(tmp1) == 0) {
    736736            log_msg(4, "%s is not right. It's being SCSI-emulated. Continuing.", output);
  • branches/2.2.10/mondo/src/common/libmondo-tools.c

    r2328 r2329  
    745745    }
    746746    g_current_media_number = 1;
    747     bkpinfo->postnuke_tarball[0] = '\0';
    748747    return (res);
    749748}
  • branches/2.2.10/mondo/src/include/my-stuff.h

    r2237 r2329  
    9393 */
    9494#define MONDO_TRACEFILE "/var/log/mondo-tracefile.log"
     95
     96#ifdef __FreeBSD__
     97#define CMDLINE "/tmp/cmdline"
     98#else
     99// Default Linux
     100#define CMDLINE "/proc/cmdline"
     101#endif
    95102
    96103#undef assert
  • branches/2.2.10/mondo/src/mondorestore/mondo-rstr-tools.c

    r2327 r2329  
    784784        }
    785785   
    786         if (strstr(call_program_and_get_last_line_of_output("cat /proc/cmdline"), "pxe")) {
     786        if (strstr(call_program_and_get_last_line_of_output("cat " CMDLINE), "pxe")) {
    787787            /* We need to override prefix value in PXE mode as it's
    788788            * already done in start-nfs */
     
    948948
    949949tmp = read_cfg_var(g_mondo_cfg_file, "please-dont-eject");
    950 if (tmp || strstr(call_program_and_get_last_line_of_output("cat /proc/cmdline"), "donteject")) {
     950if (tmp || strstr(call_program_and_get_last_line_of_output("cat " CMDLINE), "donteject")) {
    951951    bkpinfo->please_dont_eject = TRUE;
    952952    log_msg(2, "Ok, I shan't eject when restoring! Groovy.");
     
    977977        }
    978978    }
    979     if (strstr(call_program_and_get_last_line_of_output("cat /proc/cmdline"), "pxe")) {
     979    if (strstr(call_program_and_get_last_line_of_output("cat " CMDLINE), "pxe")) {
    980980        /* We need to override values in PXE mode as it's
    981981        * already done in start-nfs */
  • branches/2.2.10/mondo/src/mondorestore/mondorestore.c

    r2327 r2329  
    471471    log_it("Done loading config file; resizing ML");
    472472
    473 #ifdef __FreeBSD__
    474     if (strstr(call_program_and_get_last_line_of_output("cat /tmp/cmdline"), "noresize"))
    475 #else
    476     if (strstr(call_program_and_get_last_line_of_output("cat /proc/cmdline"), "noresize"))
    477 #endif
    478     {
     473    if (strstr(call_program_and_get_last_line_of_output("cat " CMDLINE), "noresize")) {
    479474        log_msg(1, "Not resizing mountlist.");
    480475    } else {
     
    773768    get_cfg_file_from_archive_or_bust();
    774769    load_mountlist(mountlist, g_mountlist_fname);   // in case read_cfg_file_into_bkpinfo updated the mountlist
    775 #ifdef __FreeBSD__
    776     if (strstr
    777         (call_program_and_get_last_line_of_output("cat /tmp/cmdline"),
    778          "noresize"))
    779 #else
    780     if (strstr
    781         (call_program_and_get_last_line_of_output("cat /proc/cmdline"),
    782          "noresize"))
    783 #endif
    784     {
     770    if (strstr(call_program_and_get_last_line_of_output("cat " CMDLINE), "noresize")) {
    785771        log_msg(2, "Not resizing mountlist.");
    786772    } else {
     
    811797            twenty_seconds_til_yikes();
    812798            g_fprep = fopen("/tmp/prep.sh", "w");
    813 #ifdef __FreeBSD__
    814             if (strstr
    815                 (call_program_and_get_last_line_of_output
    816                  ("cat /tmp/cmdline"), "nopart"))
    817 #else
    818             if (strstr
    819                 (call_program_and_get_last_line_of_output
    820                  ("cat /proc/cmdline"), "nopart"))
    821 #endif
    822             {
     799            if (strstr(call_program_and_get_last_line_of_output("cat " CMDLINE), "nopart")) {
    823800                log_msg(2,
    824801                        "Not partitioning drives due to 'nopart' option.");
     
    894871    if (retval) {
    895872        log_to_screen("Errors occurred during the nuke phase.");
    896     } else if (strstr(call_program_and_get_last_line_of_output("cat /proc/cmdline"), "RESTORE")) {
     873    } else if (strstr(call_program_and_get_last_line_of_output("cat " CMDLINE), "RESTORE")) {
    897874        log_to_screen
    898875            ("PC was restored successfully. Thank you for using Mondo Rescue.");
     
    26672644    /* Configure global variables */
    26682645    malloc_libmondo_global_strings();
    2669 #ifdef __FreeBSD__
    2670     if (strstr(call_program_and_get_last_line_of_output("cat /tmp/cmdline"), "textonly"))
    2671 #else
    2672     if (strstr(call_program_and_get_last_line_of_output("cat /proc/cmdline"), "textonly"))
    2673 #endif
     2646    if (strstr(call_program_and_get_last_line_of_output("cat " CMDLINE), "textonly"))
    26742647    {
    26752648        g_text_mode = TRUE;
Note: See TracChangeset for help on using the changeset viewer.