1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195
|
#!/bin/sh
echo 'This script is quite dumb, it asks you more questions'
echo 'than you might think is necessary. However, this script'
echo 'is meant to run exactly one time. If it fails, there is'
echo 'some trouble ahead. See Q16 of the HOWTO.FAQ.DO-DONT of'
echo 'the distribution how to get back out of the trouble.'
echo 'Please supply the required information'
echo 'so this script will succeed. Have fun.'
echo ' '
matches(){
RESULT=`echo "$1" | egrep -i "$2" | wc -l`
echo $RESULT
}
writeoutline(){
if [ "$SERVER"X = X ] ; then
SERVER="$DEFSERVER"
fi
if [ "$PORT"X = X ] ; then
PORT="$DEFPORT"
fi
echo "$BUNUM":" $SERVER $PORT $CART $FILE"
BUNUM=""
SERVER=""
PORT=""
CART=""
FILE=""
}
cleanup(){
/bin/rm -f $TMPFILE
exit $EST
}
TMPFILE=/tmp/afbu_update_mininfo.$$
trap cleanup 2
trap cleanup 15
DEFPORT=2988
echo "Please enter the hostname of your default backup server:"
read DEFSERVER
echo ' '
echo "Please enter the port number of your default backup service"
echo '(normally this is 2988):'
read DEFPORT
echo ' '
echo "Please enter the full path of the .../var directory of your"
echo "clientside installation:"
EXISTS=no
while [ $EXISTS = no ] ; do
read DN
STARTPOSFILE="$DN/start_positions"
if [ -f "$STARTPOSFILE" ] ; then
echo " "
echo "The file $STARTPOSFILE already esists."
echo "It contains `wc -l < $STARTPOSFILE` lines."
echo "Please check and possibly remove or rename"
echo "this file before proceeding. Please try again:"
continue
fi
if [ ! -f $DN/num ] ; then
echo "Error: The file $DN/num is not present. Please check and try again."
continue
fi
touch "$STARTPOSFILE"
if [ $? -ne 0 ] ; then
echo ' '
echo "Could not create file $STARTPOSFILE (necessary),"
echo "please try again:"
else
EXISTS=yes
fi
done
echo ' '
echo "Please enter the filename with your pre-3.2 style"
echo "Minimum restore info:"
EXISTS=no
while [ $EXISTS = no ] ; do
read FN
if [ ! -r $FN ] ; then
echo " "
echo "This file does not exist or is not readable."
echo "Please try again:"
else
EXISTS=yes
fi
done
echo " "
BUNUM=""
CART=""
FILE=""
SERVER=""
PORT=""
echo " "
echo "Writing $STARTPOSFILE, this may take a while ..."
/bin/rm -f $TMPFILE
if [ -f $TMPFILE ] ; then
echo "Security alert: Could not remove file $TMPFILE. Exiting."
exit 3
fi
grep '^~~' $FN > $TMPFILE
NLINES=`wc -l < $TMPFILE`
N=0
while read line ; do
case "$line" in
~~Backup*)
if [ "$BUNUM"X != X -a "$CART"X != X -a "$FILE"X != X ] ; then
writeoutline >> $STARTPOSFILE
fi
BUNUM=`echo $line | awk '{print $NF}'`
NUM="$BUNUM"
;;
~~Cartridge*)
CART=`echo $line | awk '{print $NF}'`
;;
~~File*)
FILE=`echo $line | awk '{print $NF}'`
;;
~~Server*)
SERVER=`echo $line | awk '{print $NF}'`
;;
~~Port*)
PORT=`echo $line | awk '{print $NF}'`
;;
esac
N=`expr $N + 1`
echo dummy|awk '{printf "%d %% done\r",'"$N * 100 / $NLINES"'}'
done < $TMPFILE
if [ "$BUNUM"X != X -a "$CART"X != X -a "$FILE"X != X ] ; then
writeoutline >> $STARTPOSFILE
fi
echo "Wrote `wc -l < $STARTPOSFILE` lines."
if [ "$NUM"X = X ] ; then
echo "Error: No old style minimum restore info found."
exit 1
fi
echo " "
echo "Checking current backup number ..."
FNUM=`cat $DN/num`
if [ $FNUM -ne $NUM ] ; then
echo "File $DN/num contains `cat $DN/num` while the last"
echo "found backup number in your old style minimum restore"
echo "file is $NUM. This is an error, exiting."
exit 2
fi
echo " "
echo "Now to write this file to disk and to create the"
echo "minimum restore information we must run a short"
echo "full backup saving only this file. Please enter the"
echo "full path to the version 3.2 full_backup program:"
EXISTS=no
while [ $EXISTS = no ] ; do
read FB
if [ ! -x $FB ] ; then
echo " "
echo "$FB is not executable. Please try again:"
else
EXISTS=yes
fi
done
echo " "
$FB -va $STARTPOSFILE
cleanup
|