Changeset 3565 in MondoRescue for branches/3.2/mindi/mindi


Ignore:
Timestamp:
Apr 13, 2016, 11:59:30 AM (8 years ago)
Author:
Bruno Cornec
Message:
  • Check that ll rm are now executed from a subdirectory context to avoid erasing files if launched from / (due to previous modification to suppress old_pwd some remaining commands were not protected)
  • Check that all cd are done in a subshell
  • Rename LogIt into LogAll
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.2/mindi/mindi

    r3557 r3565  
    166166    LogScreen "$1"
    167167    LogFile "$1" "$2"
    168 }
    169 
    170 # Preserved for compatibility
    171 LogIt() {
    172     LogAll "$1" "$2"
    173168}
    174169
     
    689684            LocateDeps $bigdir/usr/bin/mondo*restore >> $outfile.pre
    690685        else
    691             LogIt "ERROR: Cannot find mondo*restore in mondo's tempdir, $MINDI_TMP"
    692             LogIt "       I bet you've got a spare copy of Mondo or Mindi floating around on your system."
    693             LogIt "       If Mindi was called by Mondo then send a bug report."
    694             LogIt "       It not, type 'ps ax' to see which Mondo-related process is still running then kill it. :-)"
    695             LogIt "       Finally, run Mindi again."
     686            LogAll "ERROR: Cannot find mondo*restore in mondo's tempdir, $MINDI_TMP"
     687            LogAll "       I bet you've got a spare copy of Mondo or Mindi floating around on your system."
     688            LogAll "       If Mindi was called by Mondo then send a bug report."
     689            LogAll "       It not, type 'ps ax' to see which Mondo-related process is still running then kill it. :-)"
     690            LogAll "       Finally, run Mindi again."
    696691            Die "Odd."
    697692        fi
    698         cp -f $MINDI_TMP/BOOTLOADER.* $bigdir 2>> $LOGFILE || LogIt "\nINFO: Mondo v1.2x defaults to LILO as the bootloader, BTW."
     693        cp -f $MINDI_TMP/BOOTLOADER.* $bigdir 2>> $LOGFILE || LogAll "\nINFO: Mondo v1.2x defaults to LILO as the bootloader, BTW."
    699694        if [ -e "$MINDI_TMP/NETFS-SERVER-MOUNT" ] ; then
    700695            LogAll "\nINFO: Incorporating Network-related settings"
     
    10511046    [ -e "$MY_FSTAB" ] || Die "Cannot find your fstab file ($MY_FSTAB)"
    10521047
    1053     [ "$mountlist" != "" ] && rm -Rf $mountlist
     1048    [ "$mountlist" != "" ] && [ "$mountlist" != "/" ] && rm -Rf $mountlist
    10541049    > $mountlist
    10551050    all_partitions=""
     
    18211816            cat $MINDI_TMP/syslinux.log |tee -a $LOGFILE
    18221817            LogAll "------------------------------------------"
    1823             LogIt "ERROR: Failed to create USB image."
     1818            LogAll "ERROR: Failed to create USB image."
    18241819        else
    18251820            LogFile "INFO: Created bootable USB image on $USBDEVICE"
     
    23162311    echo -e "$DONE"
    23172312
    2318     rm -rf $bigdir
     2313    [ "$bigdir" != "/" ] && rm -rf $bigdir
    23192314    rm -f $needlist
    23202315}
     
    25782573        if [ -h "/$d" ]; then
    25792574            thelink=`readlink /$d`
    2580             mkdir -p $mountpoint/$thelink || LogIt "ERROR: Unable to create $thelink in $mountpoint."
     2575            mkdir -p $mountpoint/$thelink || LogAll "ERROR: Unable to create $thelink in $mountpoint."
    25812576            mv $mountpoint/$d/* $mountpoint/$d/.??* $mountpoint/$thelink 2> /dev/null
    25822577            if [ -d "$mountpoint/$d" -a ! -h "$mountpoint/$d" ]; then
     
    25852580            if [ ! -h $mountpoint/$d ]; then
    25862581                rm -f $mountpoint/$d 2> /dev/null
    2587                 (cd $mountpoint ; ln -s $thelink $d) || LogIt "ERROR: /$d is a symbolic link, but I couldn't create it in $mountpoint."
     2582                (cd $mountpoint ; ln -s $thelink $d) || LogAll "ERROR: /$d is a symbolic link, but I couldn't create it in $mountpoint."
    25882583            fi
    25892584        fi
     
    26322627    if [ $? -eq 0 ]; then
    26332628        # We want to use the real mount and all the supported variants (nfs, cifs, ...)
    2634         rm -f bin/mount
     2629        rm -f $mountpoint/bin/mount
    26352630    fi
    26362631
     
    26842679    fnllist=`echo $finallist | tr ' ' '\n' | sort -u | tr '\n' ' '`
    26852680    LogFile "INFO: Copy the minimal env with cp -a --parents $fnllist -t $mountpoint"
    2686     cp -a --parents $fnllist -t $mountpoint 2> $templog || LogIt "WARNING: Problem in minimal analysis" $templog
     2681    cp -a --parents $fnllist -t $mountpoint 2> $templog || LogAll "WARNING: Problem in minimal analysis" $templog
    26872682
    26882683    # In case target /bin dir still doesn't exist, create it before using it
     
    27082703        echo "udev device manager found" > $mountpoint/tmp/USE-UDEV
    27092704        LogFile "INFO: udev device manager found"
    2710         tar cf - -C / /etc/udev 2> $templog | (cd $mountpoint ; tar xf -)  || LogIt "ERROR: Problem in /etc/udev analysis" $templog
     2705        tar cf - -C / /etc/udev 2> $templog | (cd $mountpoint ; tar xf -)  || LogAll "ERROR: Problem in /etc/udev analysis" $templog
    27112706        # This avoids NIC remapping if on another machine at restore time on Debian/Ubuntu at least
    2712         rm -f ./etc/udev/rules.d/[z]*[0-9][0-9][-_]persistent-net.rules
     2707        rm -f $mountpoint/etc/udev/rules.d/[z]*[0-9][0-9][-_]persistent-net.rules
    27132708        # Do not do it if it's a link (Ubuntu 64 bits #503)
    27142709        if [ -e "/lib64/udev" ] && [ ! -h "/lib64" ] && [ ! -h "/lib64/udev" ]; then
    2715             tar cf - -C / /lib64/udev 2> $templog | (cd $mountpoint ; tar xf -)  || LogIt "ERROR: Problem in /lib64/udev analysis" $templog
     2710            tar cf - -C / /lib64/udev 2> $templog | (cd $mountpoint ; tar xf -)  || LogAll "ERROR: Problem in /lib64/udev analysis" $templog
    27162711        fi
    27172712        if [ -e "/lib32/udev" ] && [ ! -h "/lib32" ] && [  ! -h "/lib32/udev" ]; then
    2718             tar cf - -C / /lib32/udev 2> $templog | (cd $mountpoint ; tar xf -)  || LogIt "ERROR: Problem in /lib32/udev analysis" $templog
     2713            tar cf - -C / /lib32/udev 2> $templog | (cd $mountpoint ; tar xf -)  || LogAll "ERROR: Problem in /lib32/udev analysis" $templog
    27192714        fi
    27202715        if [ -e "/lib/udev" ] && [ ! -h "/lib" ] && [  ! -h "/lib/udev" ]; then
    2721             tar cf - -C / /lib/udev 2> $templog | (cd $mountpoint ; tar xf -)  || LogIt "ERROR: Problem in /lib/udev analysis" $templog
     2716            tar cf - -C / /lib/udev 2> $templog | (cd $mountpoint ; tar xf -)  || LogAll "ERROR: Problem in /lib/udev analysis" $templog
    27222717        fi
    27232718        if [ -e "/usr/lib/udev" ] && [ ! -h "/usr/lib" ] && [  ! -h "/usr/lib/udev" ]; then
    2724             tar cf - -C / /usr/lib/udev 2> $templog | (cd $mountpoint ; tar xf -)  || LogIt "ERROR: Problem in /usr/lib/udev analysis" $templog
     2719            tar cf - -C / /usr/lib/udev 2> $templog | (cd $mountpoint ; tar xf -)  || LogAll "ERROR: Problem in /usr/lib/udev analysis" $templog
    27252720        fi
    27262721        if [ -x /sbin/udevd ] || [ -x /usr/bin/udevd ] || [ -x /usr/lib/systemd/systemd-udevd ] || [ -x /lib/systemd/systemd-udevd ]; then
     
    27482743                if [ "`echo $i | cut -c1`" = "/" ]; then
    27492744                    j=`echo $i | cut -c2-`
    2750                     [ "$j" != "" ] && rm -f $j
     2745                    [ "$j" != "" ] && rm -f $mountpoint/$j
    27512746                fi
    27522747                echo "$i" >> $MINDI_TMP/udev.lis
     
    27672762            fnllist=`echo $finallist | tr ' ' '\n' | sort -u | tr '\n' ' '`
    27682763            LogFile "INFO: Copying udev related files with cp -a --parents $fnllist -t $mountpoint/"
    2769             cp -a --parents $fnllist $lis3 -t $mountpoint/ 2> $templog  || LogIt "WARNING: Problem in udev.lis analysis" $templog
     2764            cp -a --parents $fnllist $lis3 -t $mountpoint/ 2> $templog  || LogAll "WARNING: Problem in udev.lis analysis" $templog
    27702765            rm -f $MINDI_TMP/udev.lis
    27712766        else
     
    27802775    mindi-bkphw $MINDI_CACHE $MINDI_CONF | tee -a $LOGFILE
    27812776    if [ -d $MINDI_CACHE/bkphw ]; then
    2782         LogIt "INFO: Hardware Information found and saved ..."
     2777        LogAll "INFO: Hardware Information found and saved ..."
    27832778        cp -rp $MINDI_CACHE/bkphw $mountpoint
    27842779        if [ -f $MINDI_CACHE/tools.files ]; then
    27852780            lis=`grep -Ev '^#' $MINDI_CACHE/tools.files`
    27862781            LocateDeps $lis > $MINDI_TMP/tools.lis
    2787             tar cf - $lis `sort -u $MINDI_TMP/tools.lis` 2> $templog | (cd $mountpoint ; tar xf -) || LogIt "ERROR: Problem in tools.lis analysis" $templog
     2782            tar cf - $lis `sort -u $MINDI_TMP/tools.lis` 2> $templog | (cd $mountpoint ; tar xf -) || LogAll "ERROR: Problem in tools.lis analysis" $templog
    27882783        fi
    27892784        if [ -f $MINDI_CACHE/mindi-rsthw ]; then
     
    27962791    # Management of perl scripts delivered needed at restore time
    27972792    LogAll "INFO: Analyzing perl modules dependencies..."
    2798     mindi-get-perl-modules `cat $MINDI_CONF/perl-scripts` /usr/[s]*bin/mr-* 2> $templog > $MINDI_TMP/perl.lis || LogIt "ERROR: Problem in mindi-get-perl-modules" $templog
     2793    mindi-get-perl-modules `cat $MINDI_CONF/perl-scripts` /usr/[s]*bin/mr-* 2> $templog > $MINDI_TMP/perl.lis || LogAll "ERROR: Problem in mindi-get-perl-modules" $templog
    27992794    LogFile "DBG4: Perl Modules found:"
    28002795    LogFile "-------------------------"
    28012796    cat $MINDI_TMP/perl.lis >> $LOGFILE
    28022797    LogFile "-------------------------"
    2803     tar cf - `cat $MINDI_TMP/perl.lis` 2> $templog | (cd $mountpoint ; tar xf -) || LogIt "ERROR: Problem in perl scripts analysis" $templog
     2798    tar cf - `cat $MINDI_TMP/perl.lis` 2> $templog | (cd $mountpoint ; tar xf -) || LogAll "ERROR: Problem in perl scripts analysis" $templog
    28042799
    28052800    for w in cdrom groovy-stuff ; do
     
    28072802    done
    28082803
    2809     tar cf - -C / /dev/fd0*[1,2][4,7,8]* 2> $templog | (cd $mountpoint ; tar xf -) || LogIt "ERROR: Problem in fd dev analysis" $templog
     2804    tar cf - -C / /dev/fd0*[1,2][4,7,8]* 2> $templog | (cd $mountpoint ; tar xf -) || LogAll "ERROR: Problem in fd dev analysis" $templog
    28102805
    28112806    needed_modules=""
     
    28292824    fi
    28302825
    2831     [ -e "/$needed_modules_path" ] || LogIt "WARNING: path $needed_modules_path does not exist.\n         If you're not using a modular kernel then mindi won't probably work."
     2826    [ -e "/$needed_modules_path" ] || LogAll "WARNING: path $needed_modules_path does not exist.\n         If you're not using a modular kernel then mindi won't probably work."
    28322827    LogAll "INFO: Analyzing kernel modules dependencies..."
    28332828    needed_modules=`mr-kernel-get-modules $mkgmopt $list_of_groovy_mods`
    28342829
    28352830    LogFile "INFO: Adding $needed_modules to the rootfs with $mkgmopt"
    2836     cp --parents -aL $needed_modules $mountpoint/ 2> $templog || LogIt "ERROR: Unable to copy modules to $mountpoint" $templog
     2831    cp --parents -aL $needed_modules $mountpoint/ 2> $templog || LogAll "ERROR: Unable to copy modules to $mountpoint" $templog
    28372832
    28382833    # Uncompress modules if not using udev and native modprobe
     
    28532848
    28542849    # Also copy modules.* in case of udev so that normal modprobe works
    2855     tar cf - -C / /$needed_modules_path/modules.* 2> $templog | (cd "$mountpoint" ; tar xf -) || LogIt "ERROR: Unable to copy modules.* to $mountpoint" $templog
     2850    tar cf - -C / /$needed_modules_path/modules.* 2> $templog | (cd "$mountpoint" ; tar xf -) || LogAll "ERROR: Unable to copy modules.* to $mountpoint" $templog
    28562851
    28572852    # Copy FW in case some drivers needs it
     
    28782873            mkdir -p $mountpoint/usr/bin
    28792874            cp -a /usr/bin/hpsa_obdr_mode $mountpoint/usr/bin
    2880             LogIt "INFO: Copying /usr/bin/hpsa_obdr_mode to ramdisk for improved Smart Array OBDR support"
     2875            LogAll "INFO: Copying /usr/bin/hpsa_obdr_mode to ramdisk for improved Smart Array OBDR support"
    28812876            found=1
    28822877        fi
     
    28852880            lis="/usr/bin/sg_map /usr/bin/sg_inq /usr/bin/sg_reset /usr/bin/rev"
    28862881            LocateDeps $lis > $MINDI_TMP/obdr.lis
    2887             tar cf - $lis -C /  `sort -u $MINDI_TMP/obdr.lis` 2> $templog | (cd $mountpoint ; tar xf -) || LogIt "ERROR: Problem in obdr.lis analysis" $templog
    2888             LogIt "INFO: Copying /usr/bin/sg_reset to ramdisk for improved SCSI OBDR support"
     2882            tar cf - $lis -C /  `sort -u $MINDI_TMP/obdr.lis` 2> $templog | (cd $mountpoint ; tar xf -) || LogAll "ERROR: Problem in obdr.lis analysis" $templog
     2883            LogAll "INFO: Copying /usr/bin/sg_reset to ramdisk for improved SCSI OBDR support"
    28892884            found=1
    28902885        fi
     
    30423037if which awk &> /dev/null ; then
    30433038    if ! which gawk &> /dev/null ; then
    3044         LogIt "INFO: You have awk but not gawk.\nPlease note that mindi works fine with a _sane_ awk binary.\nIf your awk binary misbehaves then please contact your vendor\nor distribution's mailing list for technical support.\n"
     3039        LogAll "INFO: You have awk but not gawk.\nPlease note that mindi works fine with a _sane_ awk binary.\nIf your awk binary misbehaves then please contact your vendor\nor distribution's mailing list for technical support.\n"
    30453040    fi
    30463041fi
     
    33863381        [ "$USE_LZMA" = "" ] && USE_LZMA=no
    33873382        [ "$NOT_BOOT" = "" ] && NOT_BOOT=no
    3388         [ "$TAPEDEV" ] && LogIt "INFO: This is a tape-based backup. Fine."
     3383        [ "$TAPEDEV" ] && LogAll "INFO: This is a tape-based backup. Fine."
    33893384        # MONDO_ROOT is the real scratchdir
    33903385        MONDO_ROOT=`echo $MINDI_CACHE | sed 's/\(.*\)\/.*/\1/'`
     
    34083403
    34093404if [ _"$MONDO_SHARE" = _"" ]; then
    3410     LogIt "Mindi Linux mini-distro generator v$MINDI_VERSION"
    3411     LogIt "Latest Mindi is available from http://www.mondorescue.org"
    3412     LogIt "BusyBox sources are available from http://www.busybox.net"
    3413     LogIt "------------------------------------------------------------------------------"
     3405    LogAll "Mindi Linux mini-distro generator v$MINDI_VERSION"
     3406    LogAll "Latest Mindi is available from http://www.mondorescue.org"
     3407    LogAll "BusyBox sources are available from http://www.busybox.net"
     3408    LogAll "------------------------------------------------------------------------------"
    34143409else
    34153410    LogFile "INFO: You are using Mindi v$MINDI_VERSION to make boot+data disks"
    34163411fi
    34173412if [ -f $MINDI_LIB/rootfs/usr/bin/busybox ]; then
    3418     LogIt "INFO: You are using Mindi-`$MINDI_LIB/rootfs/usr/bin/busybox 2>&1 | head -1`"
     3413    LogAll "INFO: You are using Mindi-`$MINDI_LIB/rootfs/usr/bin/busybox 2>&1 | head -1`"
    34193414else
    3420     LogIt "ERROR: Unable to find mindi-busybox, please install it"
     3415    LogAll "ERROR: Unable to find mindi-busybox, please install it"
    34213416    MindiExit -1
    34223417fi
     
    34333428LogFile "NOT_BOOT = '$NOT_BOOT'"
    34343429if [ "$NOT_BOOT" != "" ] && [ "$NOT_BOOT" != "0" ] && [ "$NOT_BOOT" != "no" ] ; then
    3435     LogIt "INFO: Just creating $MRCFG and a small all.tar.gz for Mondo. Nothing else."
     3430    LogAll "INFO: Just creating $MRCFG and a small all.tar.gz for Mondo. Nothing else."
    34363431    MakeMondoConfigFile $MINDI_TMP/$MRCFG
    34373432    MakeMountlist $MINDI_TMP/mountlist.txt
    34383433    CheckMountlist $MINDI_TMP/mountlist.txt
    34393434    mkdir -p $MINDI_TMP/small-all/tmp
    3440     cd "$MINDI_TMP/small-all"
    3441     cp -f $MINDI_TMP/{mountlist.txt,$MRCFG,filelist.full.gz,biggielist.txt} tmp 2>> $LOGFILE || Die "Cannot copy small all.tar.gz"
    3442     tar -cv ./tmp | gzip -9 > $MINDI_TMP/all.tar.gz 2>> $MINDI_TMP/$$.log || Die "Cannot make small all.tar.gz" $MINDI_TMP/$$.log
     3435    cp -f $MINDI_TMP/{mountlist.txt,$MRCFG,filelist.full.gz,biggielist.txt} $MINDI_TMP/small-all/tmp 2>> $LOGFILE || Die "Cannot copy small all.tar.gz"
     3436    (cd $MINDI_TMP/small-all ; tar -cv ./tmp | gzip -9 > $MINDI_TMP/all.tar.gz 2>> $MINDI_TMP/$$.log || Die "Cannot make small all.tar.gz" $MINDI_TMP/$$.log)
    34433437    sleep 2
    3444     LogIt "Done. Exiting."
     3438    LogAll "Done. Exiting."
    34453439    MindiExit 0
    34463440fi
    34473441
    34483442if [ "$PROMPT_MAKE_USB_IMAGE" = "yes" ] && [ "$USBDEVICE" != "" ]; then
    3449     LogIt "INFO: Including the generation of a Bootable USB device on $USBDEVICE"
     3443    LogAll "INFO: Including the generation of a Bootable USB device on $USBDEVICE"
    34503444fi
    34513445
     
    34693463
    34703464echo -e "Mindi's temp dir = $MINDI_TMP \nMindi's output dir=$MINDI_CACHE" >> $LOGFILE
    3471 [ "$(($RANDOM%64))" -eq "0" ] && LogIt "INFO: Dude, I've looked inside your computer and it's really dusty..."
     3465[ "$(($RANDOM%64))" -eq "0" ] && LogAll "INFO: Dude, I've looked inside your computer and it's really dusty..."
    34723466
    34733467mountpoint=$MINDI_TMP/mountpoint.$$
     
    35143508else
    35153509    if [ _"$MONDO_SHARE" != _"" ] ; then
    3516         LogIt "ERROR: You don't have a $MRCFG file !"
     3510        LogAll "ERROR: You don't have a $MRCFG file !"
    35173511    fi
    35183512fi
Note: See TracChangeset for help on using the changeset viewer.