1 --- amanda-2.4.3/changer-src/chg-zd-mtx.sh.in.orig Mon Sep 16 16:36:15 2002
2 +++ amanda-2.4.3/changer-src/chg-zd-mtx.sh.in Thu Jan 9 23:16:47 2003
7 - if [ $internal_call -gt 0 ]; then
8 + if [ "$internal_call" -gt 0 ]; then
14 Log $call_type "($code)" "->" "$exit_slot" "$@"
15 echo "$exit_slot" "$@"
16 - if [ $call_type = Return ]; then
17 + if [ "$call_type" = "Return" ]; then
20 amgetconf$SUF dbclose.$argv0:$DBGFILE > /dev/null 2>&1
24 test -n "$DEBUG" && set -x
25 - if [ $mtx_status_valid -ne 0 ]; then
26 + if [ "$mtx_status_valid" -ne 0 ]; then
30 Run $MTX status > $mtx_status 2>&1
32 - if [ $status -eq 0 ]; then
33 + if [ "$status" -eq 0 ]; then
39 ' < $mtx_status 2>&1 | grep -v "^${cleanslot}\$" | sort -n`
40 slot_list=`echo $slot_list` # remove the newlines
41 - if [ $firstslot -lt 0 -o $lastslot -lt 0 ]; then
42 + if [ "$firstslot" -lt 0 -o "$lastslot" -lt 0 ]; then
44 for slot in $slot_list; do
45 - if [ $firstslot -lt 0 ]; then
46 + if [ "$firstslot" -lt 0 ]; then
47 Log "SLOTLIST -> firstslot set to $slot"
50 - if [ $lastslot -lt 0 ]; then
51 + if [ "$lastslot" -lt 0 ]; then
55 - if [ $lastslot -lt 0 -a $last -ge 0 ]; then
56 + if [ "$lastslot" -lt 0 -a "$last" -ge 0 ]; then
57 Log "SLOTLIST -> lastslot set to $last"
60 - if [ $firstslot -lt 0 ]; then
61 + if [ "$firstslot" -lt 0 ]; then
64 "cannot determine first slot"
65 return $? # in case we are internal
66 - elif [ $lastslot -lt 0 ]; then
67 + elif [ "$lastslot" -lt 0 ]; then
70 "cannot determine last slot"
74 for slot in $slot_list; do
75 - if [ $slot -ge $firstslot -a $slot -le $lastslot ]; then
76 + if [ "$slot" -ge "$firstslot" -a "$slot" -le "$lastslot" ]; then
77 amanda_slot_list="$amanda_slot_list $slot"
83 "tapedev may not be empty"
84 -elif [ $tape = "/dev/null" -o `expr "$tape" : 'null:'` -eq 5 ]; then
85 +elif [ "$tape" = "/dev/null" -o `expr "$tape" : 'null:'` -eq 5 ]; then
88 "tapedev ($tape) may not be the null device"
92 "changerdev may not be empty"
93 -elif [ $TAPE = "/dev/null" ]; then
94 +elif [ "$TAPE" = "/dev/null" ]; then
97 "changerdev ($TAPE) may not be the null device"
100 # Get DBGFILE set if it is not already.
102 -if [ $DBGFILE = /dev/null ]; then
103 +if [ "$DBGFILE" = /dev/null ]; then
104 if [ -d "$DBGDIR" ]; then
105 DBGFILE=$DBGDIR/changer.debug.drive$driveslot
110 for var in $varlist; do
111 - if [ $var = "OFFLINE_BEFORE_UNLOAD" ]; then
112 + if [ "$var" = "OFFLINE_BEFORE_UNLOAD" ]; then
114 - elif [ $var = "AUTOCLEAN" ]; then
115 + elif [ "$var" = "AUTOCLEAN" ]; then
119 @@ -752,13 +752,13 @@
121 # Run the rest of the config file sanity checks.
123 -if [ $firstslot -gt $lastslot ]; then
124 +if [ "$firstslot" -gt "$lastslot" ]; then
127 "firstslot ($firstslot) greater than" \
128 "lastslot ($lastslot) in $configfile"
130 -if [ $autoclean -ne 0 -a $cleanslot -lt 0 ]; then
131 +if [ "$autoclean" -ne 0 -a "$cleanslot" -lt 0 ]; then
134 "autoclean set but cleanslot not valid ($cleanslot)"
135 @@ -768,12 +768,12 @@
137 currentslot=`cat $slotfile`
138 if IsNumeric "$currentslot" ; then
139 - if [ $currentslot -lt $firstslot ]; then
140 + if [ "$currentslot" -lt "$firstslot" ]; then
141 Log "SETUP -> current slot $currentslot" \
142 "less than $firstslot ..." \
143 "resetting to $firstslot"
144 currentslot=$firstslot
145 - elif [ $currentslot -gt $lastslot ]; then
146 + elif [ "$currentslot" -gt "$lastslot" ]; then
147 Log "SETUP -> current slot $currentslot" \
148 "greater than $lastslot ..." \
149 "resetting to $lastslot"
150 @@ -789,19 +789,19 @@
151 first_slot_in_list=-1
152 next_slot_after_current=-1
153 for slot in $slot_list; do
154 - if [ $first_slot_in_list -lt 0 ]; then
155 + if [ "$first_slot"_in_list -lt 0 ]; then
156 first_slot_in_list=$slot # in case $firstslot is missing
158 - if [ $slot -eq $currentslot ]; then
159 + if [ "$slot" -eq "$currentslot" ]; then
162 - elif [ $slot -gt $currentslot ]; then
163 + elif [ "$slot" -gt "$currentslot" ]; then
164 next_slot_after_current=$slot # $currentslot is missing
168 -if [ $found_current -eq 0 ]; then
169 - if [ $next_slot_after_current -lt 0 ]; then
170 +if [ "$found_current" -eq 0 ]; then
171 + if [ "$next_slot_after_current" -lt 0 ]; then
172 new_currentslot=$first_slot_in_list
174 new_currentslot=$next_slot_after_current
175 @@ -821,10 +821,10 @@
176 test -n "$DEBUG" && set -x
177 Log "EJECT -> ejecting tape from $tape"
179 - if [ $loadedslot -gt 0 ]; then
180 + if [ "$loadedslot" -gt 0 ]; then
181 Log "EJECT -> moving tape from drive $driveslot" \
182 "to storage slot $loadedslot"
183 - if [ $offline_before_unload -ne 0 ]; then
184 + if [ "$offline_before_unload" -ne 0 ]; then
185 Run $MT $MTF $tape offline > /dev/null 2>&1
190 Log " -> status $status, result \"$result\""
192 - if [ $status -ne 0 ]; then
193 + if [ "$status" -ne 0 ]; then
200 while [ $# -gt 0 ]; do
201 - if [ $1 -eq $find_slot ]; then
202 + if [ "$1" -eq "$find_slot" ]; then
207 # If the desired slot is already loaded, we are done. Only update
208 # current slot if this is not the cleaning slot.
210 - if [ $loadslot = $loadedslot ]; then
211 - if [ $loadslot -ne $cleanslot ]; then
212 + if [ "$loadslot" = "$loadedslot" ]; then
213 + if [ "$loadslot" -ne "$cleanslot" ]; then
215 echo $loadslot > $slotfile
217 @@ -954,20 +954,20 @@
218 # If we are loading the cleaning tape, bump the cleaning count
219 # and reset the access count. Otherwise, bump the access count
220 # and see if it is time to do a cleaning.
221 - if [ $loadslot = $cleanslot ]; then
222 + if [ "$loadslot" = "$cleanslot" ]; then
223 rm -f $cleanfile $accessfile
224 expr $cleancount + 1 > $cleanfile
228 expr $accesscount + 1 > $accessfile
229 - if [ $autoclean -ne 0 -a $accesscount -gt $autocleancount ]
230 + if [ "$autoclean" -ne 0 -a "$accesscount" -gt "$autocleancount" ]
232 internal_call=`expr $internal_call + 1`
233 loadslot clean > /dev/null 2>&1
235 internal_call=`expr $internal_call - 1`
236 - if [ $status -ne 0 ]; then
237 + if [ "$status" -ne 0 ]; then
238 Exit $status "$loadslot" "$exit_answer"
239 return $? # in case we are internal
241 @@ -987,14 +987,14 @@
242 eject > /dev/null 2>&1
244 internal_call=`expr $internal_call - 1`
245 - if [ $status -gt 1 ]; then
246 + if [ "$status" -gt 1 ]; then
247 Exit $status "$exit_slot" "$exit_answer"
248 return $? # in case we are internal
251 # If we were doing an "advance", we are done.
252 - if [ $whichslot = advance ]; then
253 - if [ $loadslot -ne $cleanslot ]; then
254 + if [ "$whichslot" = "advance" ]; then
255 + if [ "$loadslot" -ne "$cleanslot" ]; then
257 echo $loadslot > $slotfile
259 @@ -1009,7 +1009,7 @@
261 Log " -> status $status, result \"$result\""
263 - if [ $status -ne 0 ]; then
264 + if [ "$status" -ne 0 ]; then
265 Exit 2 "$loadslot" "$result"
266 return $? # in case we are internal
268 @@ -1019,7 +1019,7 @@
269 # for "long enough" (as determined empirically by the user),
270 # then return success.
272 - if [ $loadslot -eq $cleanslot ]; then
273 + if [ "$loadslot" -eq "$cleanslot" ]; then
274 Run sleep $cleancycle
275 Exit 0 "$loadslot" "$tape"
276 return $? # in case we are internal
277 @@ -1039,14 +1039,14 @@
278 sleep $poll_drive_ready
279 waittime=`expr $waittime + $poll_drive_ready`
281 - if [ $ready -eq 0 ]; then
282 + if [ "$ready" -eq 0 ]; then
283 Exit 2 "$loadslot" "Drive not ready after" \
284 "$max_drive_wait seconds," \
285 "rewind said \"$result\""
286 return $? # in case we are internal
289 - if [ $loadslot -ne $cleanslot ]; then
290 + if [ "$loadslot" -ne "$cleanslot" ]; then
292 echo $loadslot > $slotfile
294 @@ -1077,11 +1077,11 @@
295 # can search based on barcodes.
298 - if [ $havereader -eq 1 ]; then
299 + if [ "$havereader" -eq 1 ]; then
303 - if [ $currentslot -lt $firstslot -o $currentslot -gt $lastslot ]; then
304 + if [ "$currentslot" -lt "$firstslot" -o "$currentslot" -gt "$lastslot" ]; then
305 currentslot=$firstslot # what "current" will get
308 @@ -1116,8 +1116,8 @@
309 "Line $line malformed in $labelfile: $lbl $bc $junk"
310 return $? # in case we are internal
312 - if [ $lbl = "$lbl_search" -o $bc = "$bc_search" ]; then
313 - if [ $labelfile_entry_found -ne 0 ]; then
314 + if [ "$lbl" = "$lbl_search" -o "$bc" = "$bc_search" ]; then
315 + if [ "$labelfile_entry_found" -ne 0 ]; then
316 Log "ERROR -> Duplicate entries: $labelfile line $line"
317 LogAppend " -> Remove $labelfile" \
319 @@ -1146,12 +1146,12 @@
320 return $? # in case we are internal
323 - if [ $havereader -eq 0 ]; then
324 + if [ "$havereader" -eq 0 ]; then
325 Exit 2 "<none>" "Not configured with barcode reader"
326 return $? # in case we are internal
329 - if [ $loadedslot -lt 0 ]; then
330 + if [ "$loadedslot" -lt 0 ]; then
331 Exit 1 "<none>" "No tape currently loaded"
332 return $? # in case we are internal
334 @@ -1160,7 +1160,7 @@
335 "for slot $loadedslot" \
337 read_labelfile "$tapelabel" "$loadedbarcode" < $labelfile
338 - if [ $labelfile_entry_found -ne 0 ]; then
339 + if [ "$labelfile_entry_found" -ne 0 ]; then
341 if [ "$labelfile_barcode" != "$loadedbarcode" ]; then
343 @@ -1212,13 +1212,13 @@
344 return $? # in case we are internal
347 - if [ $havereader -eq 0 ]; then
348 + if [ "$havereader" -eq 0 ]; then
349 Exit 2 "<none>" "Not configured with barcode reader"
350 return $? # in case we are internal
352 Log "SEARCH -> Hunting for label \"$tapelabel\""
353 read_labelfile "$tapelabel" "" < $labelfile
354 - if [ $labelfile_entry_found -eq 0 ]; then
355 + if [ "$labelfile_entry_found" -eq 0 ]; then
356 LogAppend " -> !!! label \"$tapelabel\" not found" \
358 LogAppend " -> Remove $labelfile" \