Ignore:
Timestamp:
Jul 24, 2007, 1:39:36 AM (13 years ago)
Author:
Bruno Cornec
Message:
  • Add the possibiilty to edit in interactive mode mtab and device.map for grub
  • Remove blkid cache files after restore to avoid problems in cloning mode
  • Fix what seems to appear a huge number of bugs in hack-fstab (illustration of 1 LOC = 1 bug :-)
  • Especially improve LABEL and UUID support.
  • Should fix #185
  • Exclude_path should be 4*MAX_STR_LEN everywhere. Fixed now.
  • Increasing that value will allow to having larger exclude paths.
  • Should solve bug #137 (and maybe #3 as well)
  • Adds support for fedora 7

(merge -r 1533:1547 $SVN_M/branches/2.2.5)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/stable/mondo/src/restore-scripts/mondo/hack-fstab

    r1039 r1548  
    33# $Id$
    44#
     5# Recreate /etc/fstab from first mountlist analysis
     6# and then complement wirh old fstab content.
    57
    68LogIt() {
     
    1012
    1113AddFancyParams() {
    12     local incoming device mountpoint format size original_fstab_line
    13 #    echo "AddFancyParams '$1'" >> /dev/stderr
     14    local incoming device mountpoint format size original_fstab_line label uuid
     15
    1416    incoming=`echo "$1" | tr -s '\t' ' '`
    1517    [ "$incoming" = "" ] && return
    1618    device=`echo "$incoming"     | cut -d' ' -f1`
    17     [ "`echo "$device" | grep "/dev/"`" = "" ] && return
    1819    mountpoint=`echo "$incoming" | cut -d' ' -f2`
    1920    format=`echo "$incoming"     | cut -d' ' -f3`
    2021    size=`echo "$incoming"       | cut -d' ' -f4`
    21 #    echo "'$device' '$mountpoint' '$format' '$size'" > /dev/stderr
     22    label=`echo "$incoming"       | cut -d' ' -f5`
     23    uuid=`echo "$incoming"       | cut -d' ' -f6`
    2224    original_fstab_line=`grep " $mountpoint " $old_fstab | grep -v "#" | tr -s ' ' ' '`
    23 #    echo "original_fstab_line = $original_fstab_line" >> /dev/stderr
    24     if [ "`grep "LABEL=" $old_fstab`" != "" ] ; then
    25         if [ "$format" = "ext2" ] || [ "$format" = "ext3" ] ; then
    26             device="LABEL=$mountpoint"
     25    if [ "$format" = "ext2" ] || [ "$format" = "ext3" ] ; then
     26        if [ "`echo "$original_fstab_line" | grep "LABEL="`" != "" ] ; then
     27            device="LABEL=$label"
     28        fi
     29        if [ "`echo "$original_fstab_line" | grep "UUID="`" != "" ] ; then
     30            device="UUID=$uuid"
    2731        fi
    2832    fi
    29 
    30 #    LogIt "my_res = $my_res"
    3133
    3234    echo -e -n "$device $mountpoint $format "
    3335
    3436    if [ "$original_fstab_line" != "" ] ; then
    35 #   echo $original_fstab_line | gawk '{i=index($0,$4); print substr($0,i);}'
    36         echo "$original_fstab_line" | cut -d' ' -f4-19 | tr -s ' ' ' '
     37        echo "$original_fstab_line" | cut -d' ' -f4- | tr -s ' ' ' '
    3738    else
    3839        echo -e "defaults 0 0"
     
    4344ProcessFstab() {
    4445    local incoming dev mountlist_entry blanklines new_i
     46
    4547    read incoming
    4648    blanklines=0
    4749    while [ "$blanklines" -lt "5" ] ; do
    48     if [ "$incoming" = "" ] ; then
    49         blanklines=$(($blanklines+1))
    50         read incoming
    51         continue
    52     fi
    53     incoming=`echo "$incoming" | tr -s '\t' ' '`
    54 #   new_i=`HackIncomingIfLABELused "$incoming"`
    55 #   if [ ! "$new_i" ] ; then
    56     if [ "`echo "$incoming" | grep -v "LABEL="`" ] ; then
    57         dev=`echo "$incoming" | cut -d' ' -f1`
    58 #       echo "OK, $dev isn't a label" >> /dev/stderr
    59         mountlist_entry=`grep "$dev " $old_mountlist`
    60 #       echo "MLE($dev) = '$mountlist_entry'" >> /dev/stderr
    61         if [ "$mountlist_entry" = "" ] ; then
    62 #       echo "(PF) '$incoming'" >> /dev/stderr
    63         echo "$incoming"
    64         fi
    65 #   else
    66 #       echo "Skipping '$incoming'" >> /dev/stderr
    67     fi
    68     read incoming
     50        if [ "$incoming" = "" ] ; then
     51            blanklines=$(($blanklines+1))
     52            read incoming
     53            continue
     54        fi
     55        incoming=`echo "$incoming" | tr -s '\t' ' '`
     56        if [ "`echo "$incoming" | grep -vE "LABEL=|UUID="`" ] ; then
     57            dev=`echo "$incoming" | cut -d' ' -f1`
     58            mountlist_entry=`grep "$dev " $old_mountlist`
     59            if [ "$mountlist_entry" = "" ] ; then
     60                echo "$incoming"
     61            fi
     62        fi
     63        read incoming
    6964    done
    7065}
     
    7368HackIncomingIfLABELused() {
    7469    local incoming col1 col2 col_rest orig out result
     70
     71    # Keep LABEL or UUID if originally there in fstab
    7572    result=""
    7673    incoming=`echo "$1" | tr -s '\t' ' '`
    77     col1=`echo "$incoming" | cut -f1`
    78     col2=`echo "$incoming" | cut -f2`
    79     col_rest=`echo "$incoming" | cut -f3-19 | tr -s ' ' ' '`
    80     orig="`grep " $col2 " $old_fstab | cut -f1`"
    81     if [ "`echo "$orig" | grep "LABEL="`" != "" ] ; then
    82     echo "orig = $orig" >> /dev/stderr
    83     echo -e "$orig $col2 $col_rest | tr -s ' ' ' '"
     74    col1=`echo "$incoming" | cut -d' ' -f1`
     75    col2=`echo "$incoming" | cut -d' ' -f2`
     76    col_rest=`echo "$incoming" | cut -d' ' -f3- | tr -s ' ' ' '`
     77    orig="`grep " $col2 " $old_fstab | cut -d' ' -f1`"
     78    if [ "`echo "$orig" | grep -E "LABEL=|UUID="`" != "" ] ; then
     79        echo "orig = $orig" >> /dev/stderr
     80        echo -e "$orig $col2 $col_rest" | tr -s ' ' ' '
    8481    fi
    8582}
     
    9390ProcessMountlist() {
    9491    local incoming outstr res spc
     92
    9593    read incoming
    9694    while [ "$incoming" != "" ] ; do
    97     incoming=`echo "$incoming" | tr -s '\t' ' '`
    98 #   echo "(PM) incoming = '$incoming'" >> /dev/stderr
    99     res=`HackIncomingIfLABELused "$incoming"`
    100     if [ ! "$res" ] ; then
    101         outstr=`AddFancyParams "$incoming"`
    102     else
    103         outstr=`AddFancyParams "$res"`
    104     fi
    105     spc="`echo "$outstr" | tr -s '\t' ' '`"
    106     if [ "$spc" != "" ] && [ "$spc" != " " ] && [ "`echo "$spc" | grep "raid raid"`" = "" ] ; then
    107         echo "$spc"
    108 #       echo "(PM) outgoing = '$outstr'" >> /dev/stderr
    109     fi
    110     read incoming
     95        incoming=`echo "$incoming" | tr -s '\t' ' '`
     96        res=`HackIncomingIfLABELused "$incoming"`
     97        if [ ! "$res" ] ; then
     98            outstr=`AddFancyParams "$incoming"`
     99        else
     100            outstr=`AddFancyParams "$res"`
     101        fi
     102        spc="`echo "$outstr" | tr -s '\t' ' '`"
     103        if [ "$spc" != "" ] && [ "$spc" != " " ] && [ "`echo "$spc" | grep "raid raid"`" = "" ] ; then
     104            echo "$spc"
     105        fi
     106        read incoming
    111107    done
    112108}
Note: See TracChangeset for help on using the changeset viewer.