Changeset 1546 in MondoRescue
- Timestamp:
- Jul 24, 2007, 12:42:18 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2.5/mondo/src/restore-scripts/mondo/hack-fstab
r567 r1546 1 1 #!/bin/sh 2 2 # 3 # $Id$ 3 4 # 4 # 5 # 6 # 7 # 2003/08/04 8 # - added some logging 9 # 10 # mid-2002 --- created 11 ################################################ 12 5 # Recreate /etc/fstab from first mountlist analysis 6 # and then complement wirh old fstab content. 13 7 14 8 LogIt() { … … 17 11 18 12 13 AddFancyParams() { 14 local incoming device mountpoint format size original_fstab_line label uuid 19 15 20 21 AddFancyParams() {22 local incoming device mountpoint format size original_fstab_line23 # echo "AddFancyParams '$1'" >> /dev/stderr24 16 incoming=`echo "$1" | tr -s '\t' ' '` 25 17 [ "$incoming" = "" ] && return 26 18 device=`echo "$incoming" | cut -d' ' -f1` 27 [ "`echo "$device" | grep "/dev/"`" = "" ] && return28 19 mountpoint=`echo "$incoming" | cut -d' ' -f2` 29 20 format=`echo "$incoming" | cut -d' ' -f3` 30 21 size=`echo "$incoming" | cut -d' ' -f4` 31 # echo "'$device' '$mountpoint' '$format' '$size'" > /dev/stderr 22 label=`echo "$incoming" | cut -d' ' -f5` 23 uuid=`echo "$incoming" | cut -d' ' -f6` 32 24 original_fstab_line=`grep " $mountpoint " $old_fstab | grep -v "#" | tr -s ' ' ' '` 33 # echo "original_fstab_line = $original_fstab_line" >> /dev/stderr34 if [ "`grep "LABEL=" $old_fstab`" != "" ] ; then35 25 if [ "$format" = "ext2" ] || [ "$format" = "ext3" ] ; then 36 device="LABEL=$mountpoint" 37 fi 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" 31 fi 38 32 fi 39 40 # LogIt "my_res = $my_res"41 33 42 34 echo -e -n "$device $mountpoint $format " 43 35 44 36 if [ "$original_fstab_line" != "" ] ; then 45 # echo $original_fstab_line | gawk '{i=index($0,$4); print substr($0,i);}' 46 echo "$original_fstab_line" | cut -d' ' -f4-19 | tr -s ' ' ' ' 37 echo "$original_fstab_line" | cut -d' ' -f4- | tr -s ' ' ' ' 47 38 else 48 echo -e "defaults 0 0"39 echo -e "defaults 0 0" 49 40 fi 50 41 } … … 54 45 ProcessFstab() { 55 46 local incoming dev mountlist_entry blanklines new_i 47 56 48 read incoming 57 49 blanklines=0 58 50 while [ "$blanklines" -lt "5" ] ; do 59 if [ "$incoming" = "" ] ; then 60 blanklines=$(($blanklines+1)) 61 read incoming 62 continue 63 fi 64 incoming=`echo "$incoming" | tr -s '\t' ' '` 65 # new_i=`HackIncomingIfLABELused "$incoming"` 66 # if [ ! "$new_i" ] ; then 67 if [ "`echo "$incoming" | grep -v "LABEL="`" ] ; then 68 dev=`echo "$incoming" | cut -d' ' -f1` 69 # echo "OK, $dev isn't a label" >> /dev/stderr 70 mountlist_entry=`grep "$dev " $old_mountlist` 71 # echo "MLE($dev) = '$mountlist_entry'" >> /dev/stderr 72 if [ "$mountlist_entry" = "" ] ; then 73 # echo "(PF) '$incoming'" >> /dev/stderr 74 echo "$incoming" 75 fi 76 # else 77 # echo "Skipping '$incoming'" >> /dev/stderr 78 fi 79 read incoming 51 if [ "$incoming" = "" ] ; then 52 blanklines=$(($blanklines+1)) 53 read incoming 54 continue 55 fi 56 incoming=`echo "$incoming" | tr -s '\t' ' '` 57 if [ "`echo "$incoming" | grep -vE "LABEL=|UUID="`" ] ; then 58 dev=`echo "$incoming" | cut -d' ' -f1` 59 mountlist_entry=`grep "$dev " $old_mountlist` 60 if [ "$mountlist_entry" = "" ] ; then 61 echo "$incoming" 62 fi 63 fi 64 read incoming 80 65 done 81 66 } … … 84 69 HackIncomingIfLABELused() { 85 70 local incoming col1 col2 col_rest orig out result 71 72 # Keep LABEL or UUID if originally there in fstab 86 73 result="" 87 74 incoming=`echo "$1" | tr -s '\t' ' '` 88 col1=`echo "$incoming" | cut - f1`89 col2=`echo "$incoming" | cut - f2`90 col_rest=`echo "$incoming" | cut - f3-19| tr -s ' ' ' '`91 orig="`grep " $col2 " $old_fstab | cut - f1`"92 if [ "`echo "$orig" | grep "LABEL="`" != "" ] ; then93 echo "orig = $orig" >> /dev/stderr94 echo -e "$orig $col2 $col_rest | tr -s ' ' ' '"75 col1=`echo "$incoming" | cut -d' ' -f1` 76 col2=`echo "$incoming" | cut -d' ' -f2` 77 col_rest=`echo "$incoming" | cut -d' ' -f3- | tr -s ' ' ' '` 78 orig="`grep " $col2 " $old_fstab | cut -d' ' -f1`" 79 if [ "`echo "$orig" | grep -E "LABEL=|UUID="`" != "" ] ; then 80 echo "orig = $orig" >> /dev/stderr 81 echo -e "$orig $col2 $col_rest" | tr -s ' ' ' ' 95 82 fi 96 83 } … … 104 91 ProcessMountlist() { 105 92 local incoming outstr res spc 93 106 94 read incoming 107 95 while [ "$incoming" != "" ] ; do 108 incoming=`echo "$incoming" | tr -s '\t' ' '` 109 # echo "(PM) incoming = '$incoming'" >> /dev/stderr 110 res=`HackIncomingIfLABELused "$incoming"` 111 if [ ! "$res" ] ; then 112 outstr=`AddFancyParams "$incoming"` 113 else 114 outstr=`AddFancyParams "$res"` 115 fi 116 spc="`echo "$outstr" | tr -s '\t' ' '`" 117 if [ "$spc" != "" ] && [ "$spc" != " " ] && [ "`echo "$spc" | grep "raid raid"`" = "" ] ; then 118 echo "$spc" 119 # echo "(PM) outgoing = '$outstr'" >> /dev/stderr 120 fi 121 read incoming 96 incoming=`echo "$incoming" | tr -s '\t' ' '` 97 res=`HackIncomingIfLABELused "$incoming"` 98 if [ ! "$res" ] ; then 99 outstr=`AddFancyParams "$incoming"` 100 else 101 outstr=`AddFancyParams "$res"` 102 fi 103 spc="`echo "$outstr" | tr -s '\t' ' '`" 104 if [ "$spc" != "" ] && [ "$spc" != " " ] && [ "`echo "$spc" | grep "raid raid"`" = "" ] ; then 105 echo "$spc" 106 fi 107 read incoming 122 108 done 123 109 }
Note:
See TracChangeset
for help on using the changeset viewer.