1 diff -urN amanda-2.4.2p2/changer-src/chg-zd-mtx.sh.in amanda-2.4.2p2.new/changer-src/chg-zd-mtx.sh.in
2 --- amanda-2.4.2p2/changer-src/chg-zd-mtx.sh.in Tue Apr 3 02:43:07 2001
3 +++ amanda-2.4.2p2.new/changer-src/chg-zd-mtx.sh.in Tue Mar 19 20:06:46 2002
7 echo "EJECT -> ejecting tape from $tape to slot $usedslot" >> $DBGFILE
8 - if [ $usedslot -gt 0 ]; then
9 - if [ $OFFLINE_BEFORE_UNLOAD -gt 0 ]; then
10 + if [ "$usedslot" -gt 0 ]; then
11 + if [ "$OFFLINE_BEFORE_UNLOAD" -gt 0 ]; then
12 $MT $MTF $tape offline
14 $MTX unload $usedslot $drivenum 2>/dev/null
16 echo "LOADSLOT -> load tape from slot $whichslot" >> $DBGFILE
19 - if [ $usedslot -lt 0 ]; then
20 + if [ "$usedslot" -lt 0 ]; then
23 echo "$usedslot $tape"
28 - if [ $usedslot -lt 0 ]; then
29 + if [ "$usedslot" -lt 0 ]; then
32 loadslot=`expr $usedslot + 1`
33 - if [ $loadslot -gt $lastslot ]; then
34 + if [ "$loadslot" -gt "$lastslot" ]; then
40 loadslot=`expr $usedslot - 1`
41 - if [ $loadslot -lt $firstslot ]; then
42 + if [ "$loadslot" -lt "$firstslot" ]; then
50 - if [ $whichslot -gt $lastslot ] || [ $whichslot -lt $firstslot ]; then
51 + if [ "$whichslot" -gt "$lastslot" ] || [ "$whichslot" -lt "$firstslot" ]; then
52 echo "0 Slot $whichslot is out of range ($firstslot - $lastslot)"
58 # Is this already the current slot?
59 - if [ $loadslot = $usedslot ]; then
60 + if [ "$loadslo"t = "$usedslot" ]; then
61 echo "$usedslot $tape"
65 # Is this a cleaning request?
66 - if [ $loadslot = $cleanslot ]; then
67 + if [ "$loadslot" = "$cleanslot" ]; then
68 expr $cleancount + 1 > $cleanfile
71 expr $accesscount + 1 > $accessfile
72 - if [ $AUTOCLEAN -gt 0 -a $accesscount -gt $autocleancount ]; then
73 + if [ "$AUTOCLEAN" -gt 0 -a "$accesscount" -gt "$autocleancount" ]; then
74 $myname -slot clean >/dev/null
76 # Slot $cleanslot might contain an ordinary tape rather than a cleaning
80 # Unload any previous tape
81 - if [ $usedslot -ne "-1" ]; then
82 + if [ "$usedslot" -ne "-1" ]; then
83 echo " -> unload $usedslot from $tape" >> $DBGFILE
84 - if [ $OFFLINE_BEFORE_UNLOAD -gt 0 ]; then
85 + if [ "$OFFLINE_BEFORE_UNLOAD" -gt 0 ]; then
86 $MT $MTF $tape offline
88 result=`$MTX unload $usedslot $drivenum 2>&1`
90 echo " -> status $status, result '$result'" >> $DBGFILE
92 # If there is an error, abort unless the slot is simply empty
93 - if [ $status -ne 0 ]; then
94 + if [ "$status" -ne 0 ]; then
95 empty=`echo $result | grep "Empty"`
96 if [ -z "$empty" ]; then
97 echo "$loadslot $result"
99 #### Don't assume the drive is ready until we get an ONLINE
100 #### This is tested by the variable $offlinestatus from the beginning.
102 - if [ $offlinestatus -eq 0 ]; then
103 + if [ "$offlinestatus" -eq 0 ]; then
105 while [ -n "$readyError" ]; do
106 readyStatus=`$MT $MTF $tape status 2>&1`
108 echo "INFO -> current slot $usedslot, last slot $lastslot, can go backwards 1" >> $DBGFILE
109 #### Checks if you have a barcode reader or not. If so, it passes the 4th item in the echo
110 #### back to amtape signifying it can search based on barcodes.
111 - if [ $havereader -eq 1 ]; then
112 - if [ $usedslot -lt 0 ]; then
113 + if [ "$havereader" -eq 1 ]; then
114 + if [ "$usedslot" -lt 0 ]; then
115 #### added a variable to the end of the following 2 echos.
116 #### This indicates to amtape that it can/cannot read barcodes.
117 echo "0 $lastslot 1 1"
122 - if [ $usedslot -lt 0 ]; then
123 + if [ "$usedslot" -lt 0 ]; then
126 echo "$usedslot $lastslot 1"
127 @@ -360,17 +360,17 @@
130 echo "LABEL -> Adding Barcode $barcode and amlabel $tapelabel for Slot $usedslot into $labelfile" >> $DBGFILE
131 - if [ $labelfilesize -eq 2 ]; then
132 + if [ "$labelfilesize" -eq 2 ]; then
133 echo "$tapelabel $barcode" > $labelfile
134 echo "0 $usedslot $tape"
136 included=`grep $tapelabel $labelfile | awk '{print $1}'`
137 - if [ -z $included ]; then
138 + if [ -z "$included" ]; then
139 echo "$tapelabel $barcode" >> $labelfile
140 echo "0 $usedslot $tape"
142 oldbarcode=`grep $tapelabel $labelfile | awk '{print $2}'`
143 - if [ $oldbarcode -eq $barcode ]; then
144 + if [ "$oldbarcode" -eq "$barcode" ]; then
145 echo " -> Barcode $barcode $oldbarcode already synced for $tapelabel" >> $DBGFILE
146 echo "0 $usedslot $tape"
149 includedslot=`echo $tmpincludedslot | sed -n "s/\(.*\)Storage Element \([1-9][0-9]*\):\(.*\)/\2/p;s/Data Transfer Element $drivenum:Full (Storage Element \([1-9][0-9]*\) Loaded)\(.*\)/\1/p"`
152 - if [ $tapelabel == $includedtag ]; then
153 + if [ "$tapelabel" == "$includedtag" ]; then
155 loadslot $includedslot