Changeset 1548 in MondoRescue for branches/stable/mondo/src/restore-scripts/mondo/hack-fstab
- Timestamp:
- Jul 24, 2007, 1:39:36 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/stable/mondo/src/restore-scripts/mondo/hack-fstab
r1039 r1548 3 3 # $Id$ 4 4 # 5 # Recreate /etc/fstab from first mountlist analysis 6 # and then complement wirh old fstab content. 5 7 6 8 LogIt() { … … 10 12 11 13 AddFancyParams() { 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 14 16 incoming=`echo "$1" | tr -s '\t' ' '` 15 17 [ "$incoming" = "" ] && return 16 18 device=`echo "$incoming" | cut -d' ' -f1` 17 [ "`echo "$device" | grep "/dev/"`" = "" ] && return18 19 mountpoint=`echo "$incoming" | cut -d' ' -f2` 19 20 format=`echo "$incoming" | cut -d' ' -f3` 20 21 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` 22 24 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" 27 31 fi 28 32 fi 29 30 # LogIt "my_res = $my_res"31 33 32 34 echo -e -n "$device $mountpoint $format " 33 35 34 36 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 ' ' ' ' 37 38 else 38 39 echo -e "defaults 0 0" … … 43 44 ProcessFstab() { 44 45 local incoming dev mountlist_entry blanklines new_i 46 45 47 read incoming 46 48 blanklines=0 47 49 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 69 64 done 70 65 } … … 73 68 HackIncomingIfLABELused() { 74 69 local incoming col1 col2 col_rest orig out result 70 71 # Keep LABEL or UUID if originally there in fstab 75 72 result="" 76 73 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="`" != "" ] ; then82 echo "orig = $orig" >> /dev/stderr83 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 ' ' ' ' 84 81 fi 85 82 } … … 93 90 ProcessMountlist() { 94 91 local incoming outstr res spc 92 95 93 read incoming 96 94 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 111 107 done 112 108 }
Note:
See TracChangeset
for help on using the changeset viewer.