Ignore:
Timestamp:
Jun 19, 2013, 8:34:46 AM (11 years ago)
Author:
Bruno Cornec
Message:
  • First pass on svn merge -r 2935:3146 ../3.0
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.1/mondo/src/restore-scripts/mondo/make-me-bootable

    r2196 r3147  
    22
    33
    4 if [ "$#" -ne "1" ] && [ "$#" -ne "2" ] ; then
    5     echo "make-me-bootable <fname> (dummy)"
     4if [ "$#" -ne "2" ] && [ "$#" -ne "3" ] ; then
     5    echo "make-me-bootable <fname> <drive> [noaction]"
    66    exit 1
    77fi
    88
    9 dummy=$2
     9drivetouse=$2
    1010boot_drv=""
    1111boot_part=""
    1212root_drv=""
    1313root_part=""
     14if [ ! "$LOGFILE" ]; then
     15    LOGFILE="/tmp/mondorestore2.log"
     16fi
     17dummy="$3"
    1418
    15 HAVE_ACTIVE="false"
     19activepart=`parted2fdisk -l $drivetouse | tr -s '\t' ' ' | grep "$drivetouse" | grep '*' | cut -d' ' -f1`
     20
    1621for i in `cat $1 | tr -s '\t' ' ' | cut -d' ' -f1 | grep -vE "/dev/fd|none|#"` ; do
    17     mountpt=`grep "$i " $1 | tr -s '\t' ' ' | cut -d' ' -f2`
    18     format=`grep "$i " $1 | tr -s '\t' ' ' | cut -d' ' -f3`
    1922    # Warning wrong if LVM !
    2023    drive=`echo $i | sed -e 's/[0-9]*$//' -e 's/\([0-9]\)p$/\1/'`
    21     partno=`echo $i | sed -e 's/^.*[^0-9]\([0-9]*\)$/\1/'`
     24    if [ "$drivetouse" = "$drive" ]; then
     25        # We can continue as this is the drive we ned to work on
     26        partno=`echo $i | sed -e 's/^.*[^0-9]\([0-9]*\)$/\1/'`
     27        mountpt=`grep "$i " $1 | tr -s '\t' ' ' | cut -d' ' -f2`
    2228
    23     if [ "$HAVE_ACTIVE" = "false" ] && [ "`parted2fdisk -l $drive | tr -s '\t' ' ' | grep "$i " | grep -v "*"`" ] ; then
    2429        if [ "$mountpt" = "/" ] ; then
    2530            root_drv=$drive
    26         root_part=$partno
     31            root_part=$partno
    2732        elif [ "$mountpt" = "/boot" ] ; then
    2833            boot_drv=$drive
     
    4651
    4752if [ "$drive" ] ; then
     53    if [ "$partno" = "0" ] || [ ! "$partno" ] ; then
     54        partno="1"
     55    fi
     56    cmd=""
     57    for p in "$activepart"; do
     58        # First desactivate active partitions (coming from previous usage)
     59        cmd="${cmd}a\n$p\n"
     60        if [ "$dummy" != "" ] ; then
     61            echo "Will desactivate $p on $drive" >> $LOGFILE
     62        fi
     63    done
     64    # Then activate the one which should
    4865    if [ "$dummy" != "" ] ; then
    49         if [ "$partno" = "0" ] || [ ! "$partno" ] ; then
    50             partno="1"
    51         fi
    52         echo "$partno"
    53     else
    54         echo -en "a\n$partno\nw\n" | parted2fdisk $drive >> $LOGFILE 2>> $LOGFILE
    55     fi
     66        echo "Would activate $partno on $drive" >> $LOGFILE
     67    else
     68        echo -en "${cmd}a\n$partno\np\nw\n" | parted2fdisk $drive >> $LOGFILE 2>> $LOGFILE
     69    fi
    5670fi
    5771exit 0
Note: See TracChangeset for help on using the changeset viewer.