]> git.pld-linux.org Git - packages/amanda.git/blame - amanda-chg-zd-mtx-sh.patch
- rel 2
[packages/amanda.git] / amanda-chg-zd-mtx-sh.patch
CommitLineData
b1d5b2b9
JR
1--- amanda-2.6.0/changer-src/chg-zd-mtx.sh.orig 2008-01-18 01:31:16.000000000 +0100
2+++ amanda-2.6.0/changer-src/chg-zd-mtx.sh 2008-05-07 13:00:14.000000000 +0200
3@@ -361,7 +361,7 @@
76c54e97
TO
4
5 internal_call=0
6 Exit() {
7- if [ $internal_call -gt 0 ]; then
8+ if [ "$internal_call" -gt 0 ]; then
9 call_type=Return
10 else
11 call_type=Exit
b1d5b2b9 12@@ -373,7 +373,7 @@
76c54e97 13 exit_answer="$@"
b1d5b2b9 14 Log $call_type "($code) -> $exit_slot $@"
76c54e97
TO
15 echo "$exit_slot" "$@"
16- if [ $call_type = Return ]; then
17+ if [ "$call_type" = "Return" ]; then
18 return $code
19 fi
b1d5b2b9
JR
20 amgetconf dbclose.$argv0:$DBGFILE > /dev/null 2>&1
21@@ -390,12 +390,12 @@
22 "$@" > $stdout 2> $stderr
23 exitcode=$?
24 Log `_ 'Exit code: %s' "$exitcode"`
25- if [ -s $stdout ]
26+ if [ -s "$stdout" ]
27 then
28 LogAppend Stdout:
29 cat $stdout >> $DBGFILE
30 fi
31- if [ -s $stderr ]
32+ if [ -s "$stderr" ]
33 then
34 LogAppend Stderr:
35 cat $stderr >> $DBGFILE
36@@ -422,13 +422,13 @@
76c54e97
TO
37 mtx_status_valid=0
38 get_mtx_status() {
39 test -n "$DEBUG" && set -x
40- if [ $mtx_status_valid -ne 0 ]; then
41+ if [ "$mtx_status_valid" -ne 0 ]; then
42 return 0
43 fi
44 rm -f $mtx_status
45 Run $MTX status > $mtx_status 2>&1
46 status=$?
47- if [ $status -eq 0 ]; then
48+ if [ "$status" -eq 0 ]; then
49 mtx_status_valid=1
50 fi
51 return $status
b1d5b2b9
JR
52@@ -489,7 +489,7 @@
53 fi
54
55 #Use the current slot if it's empty and we don't know which slot is loaded'
56- if [ $loadedslot -eq -2 ]; then
57+ if [ "$loadedslot" -eq -2 ]; then
58 set x `sed -n '
59 {
60 /^.*Storage Element '$currentslot':Empty/ {
61@@ -512,13 +512,13 @@
62 ' < $mtx_status 2>& 1`
63 shift # get rid of the "x"
64 loadedslotx=$1
65- if [ ! -z $loadedslotx ]; then
66+ if [ ! -z "$loadedslotx" ]; then
67 loadedslot=$loadedslotx
68 fi
69 fi
70
71 #Use the first empty slot if we don't know which slot is loaded'
72- if [ $loadedslot -eq -2 ]; then
73+ if [ "$loadedslot" -eq -2 ]; then
74 set x `sed -n '
75 {
76 /^.*Storage Element \([0-9][0-9]*\):Empty/ {
77@@ -586,27 +586,27 @@
76c54e97
TO
78 }
79 ' < $mtx_status 2>&1 | grep -v "^${cleanslot}\$" | sort -n`
80 slot_list=`echo $slot_list` # remove the newlines
81- if [ $firstslot -lt 0 -o $lastslot -lt 0 ]; then
82+ if [ "$firstslot" -lt 0 -o "$lastslot" -lt 0 ]; then
83 last=$lastslot
84 for slot in $slot_list; do
85- if [ $firstslot -lt 0 ]; then
86+ if [ "$firstslot" -lt 0 ]; then
b1d5b2b9 87 Log `_ 'SLOTLIST -> firstslot set to %s' "$slot"`
76c54e97 88 firstslot=$slot
0adfa9dc 89 fi
76c54e97
TO
90- if [ $lastslot -lt 0 ]; then
91+ if [ "$lastslot" -lt 0 ]; then
92 last=$slot
0adfa9dc 93 fi
76c54e97
TO
94 done
95- if [ $lastslot -lt 0 -a $last -ge 0 ]; then
96+ if [ "$lastslot" -lt 0 -a "$last" -ge 0 ]; then
b1d5b2b9 97 Log `_ 'SLOTLIST -> lastslot set to %s' "$last"`
76c54e97
TO
98 lastslot=$last
99 fi
100- if [ $firstslot -lt 0 ]; then
101+ if [ "$firstslot" -lt 0 ]; then
102 Exit 2 \
b1d5b2b9
JR
103 `_ '<none>'` \
104 `_ 'cannot determine first slot'`
76c54e97
TO
105 return $? # in case we are internal
106- elif [ $lastslot -lt 0 ]; then
107+ elif [ "$lastslot" -lt 0 ]; then
108 Exit 2 \
b1d5b2b9
JR
109 `_ '<none>'` \
110 `_ 'cannot determine last slot'`
111@@ -615,7 +615,7 @@
76c54e97
TO
112 fi
113 amanda_slot_list=
114 for slot in $slot_list; do
115- if [ $slot -ge $firstslot -a $slot -le $lastslot ]; then
116+ if [ "$slot" -ge "$firstslot" -a "$slot" -le "$lastslot" ]; then
117 amanda_slot_list="$amanda_slot_list $slot"
118 fi
119 done
b1d5b2b9
JR
120@@ -652,7 +652,7 @@
121 Exit 2 \
122 ` _ '<none>'` \
123 "tapedev $rawtape is not a tape device."
76c54e97 124-elif [ $tape = "/dev/null" -o `expr "$tape" : 'null:'` -eq 5 ]; then
b1d5b2b9 125+elif [ "$tape" = "/dev/null" -o "`expr "$tape" : 'null:'`" -eq 5 ]; then
76c54e97 126 Exit 2 \
b1d5b2b9 127 `_ '<none>'` \
76c54e97 128 "tapedev ($tape) may not be the null device"
b1d5b2b9 129@@ -663,7 +663,7 @@
76c54e97 130 Exit 2 \
b1d5b2b9 131 `_ '<none>'` \
76c54e97
TO
132 "changerdev may not be empty"
133-elif [ $TAPE = "/dev/null" ]; then
134+elif [ "$TAPE" = "/dev/null" ]; then
135 Exit 2 \
b1d5b2b9 136 `_ '<none>'` \
76c54e97 137 "changerdev ($TAPE) may not be the null device"
b1d5b2b9
JR
138@@ -676,19 +676,19 @@
139 #### Set up the various config files.
140
141 conf_match=`expr "$changerfile" : .\*\.conf\$`
142-if [ $conf_match -ge 6 ]; then
143+if [ "$conf_match" -ge 6 ]; then
144 configfile=$changerfile
145 changerfile=`echo $changerfile | sed 's/.conf$//g'`
146 else
147 configfile=$changerfile.conf
148 fi
149
150-if [ ! -e $configfile ]; then
151+if [ ! -e "$configfile" ]; then
152 Exit 2 \
153 `_ '<none>'` \
154 "configuration file \"$configfile\" doesn't exist"
155 fi
156-if [ ! -f $configfile ]; then
157+if [ ! -f "$configfile" ]; then
158 Exit 2 \
159 `_ '<none>'` \
160 "configuration file \"$configfile\" is not a file"
161@@ -698,10 +698,10 @@
162 accessfile=$changerfile-access
163 slotfile=$changerfile-slot
164 labelfile=$changerfile-barcodes
165-[ ! -s $cleanfile ] && echo 0 > $cleanfile
166-[ ! -s $accessfile ] && echo 0 > $accessfile
167-[ ! -s $slotfile ] && echo -1 > $slotfile
168-[ ! -f $labelfile ] && > $labelfile
169+[ ! -s "$cleanfile" ] && echo 0 > $cleanfile
170+[ ! -s "$accessfile" ] && echo 0 > $accessfile
171+[ ! -s "$slotfile" ] && echo -1 > $slotfile
172+[ ! -f "$labelfile" ] && > $labelfile
173 cleancount=`cat $cleanfile`
174 accesscount=`cat $accessfile`
175
176@@ -747,7 +747,7 @@
76c54e97
TO
177
178 # Get DBGFILE set if it is not already.
179
180-if [ $DBGFILE = /dev/null ]; then
181+if [ "$DBGFILE" = /dev/null ]; then
182 if [ -d "$DBGDIR" ]; then
183 DBGFILE=$DBGDIR/changer.debug.drive$driveslot
184 else
b1d5b2b9 185@@ -827,9 +827,9 @@
0adfa9dc 186
b1d5b2b9 187 Log `_ "Config info:"`
76c54e97
TO
188 for var in $varlist; do
189- if [ $var = "OFFLINE_BEFORE_UNLOAD" ]; then
190+ if [ "$var" = "OFFLINE_BEFORE_UNLOAD" ]; then
191 continue # old name
192- elif [ $var = "AUTOCLEAN" ]; then
193+ elif [ "$var" = "AUTOCLEAN" ]; then
194 continue # old name
0adfa9dc 195 fi
76c54e97 196 eval val=\"'$'$var\"
b1d5b2b9 197@@ -850,12 +850,12 @@
0adfa9dc 198
76c54e97
TO
199 # Run the rest of the config file sanity checks.
200
201-if [ $firstslot -gt $lastslot ]; then
202+if [ "$firstslot" -gt "$lastslot" ]; then
203 Exit 2 \
b1d5b2b9
JR
204 `_ '<none>'` \
205 `_ 'firstslot (%s) greater than lastslot (%s) in %s' "$firstslot" "$lastslot" "$configfile"`
76c54e97
TO
206 fi
207-if [ $autoclean -ne 0 -a $cleanslot -lt 0 ]; then
208+if [ "$autoclean" -ne 0 -a "$cleanslot" -lt 0 ]; then
209 Exit 2 \
b1d5b2b9
JR
210 `_ '<none>'` \
211 `_ 'autoclean set but cleanslot not valid (%s)' "$cleanslot"`
212@@ -865,10 +865,10 @@
76c54e97
TO
213
214 currentslot=`cat $slotfile`
215 if IsNumeric "$currentslot" ; then
216- if [ $currentslot -lt $firstslot ]; then
217+ if [ "$currentslot" -lt "$firstslot" ]; then
b1d5b2b9 218 Log `_ 'SETUP -> current slot %s less than %s ... resetting to %s' "$currentslot" "$firstslot" "$firstslot"`
76c54e97
TO
219 currentslot=$firstslot
220- elif [ $currentslot -gt $lastslot ]; then
221+ elif [ "$currentslot" -gt "$lastslot" ]; then
b1d5b2b9
JR
222 Log `_ 'SETUP -> current slot %s greater than %s ... resetting to %s' "$currentslot" "$lastslot" "$lastslot"`
223 currentslot=$lastslot
224 fi
225@@ -881,19 +881,19 @@
76c54e97
TO
226 first_slot_in_list=-1
227 next_slot_after_current=-1
228 for slot in $slot_list; do
229- if [ $first_slot_in_list -lt 0 ]; then
b1d5b2b9 230+ if [ "$first_slot_in_list" -lt 0 ]; then
76c54e97
TO
231 first_slot_in_list=$slot # in case $firstslot is missing
232 fi
233- if [ $slot -eq $currentslot ]; then
234+ if [ "$slot" -eq "$currentslot" ]; then
235 found_current=1
236 break
237- elif [ $slot -gt $currentslot ]; then
238+ elif [ "$slot" -gt "$currentslot" ]; then
239 next_slot_after_current=$slot # $currentslot is missing
240 break
241 fi
242 done
243-if [ $found_current -eq 0 ]; then
244- if [ $next_slot_after_current -lt 0 ]; then
245+if [ "$found_current" -eq 0 ]; then
246+ if [ "$next_slot_after_current" -lt 0 ]; then
247 new_currentslot=$first_slot_in_list
248 else
249 new_currentslot=$next_slot_after_current
b1d5b2b9 250@@ -912,9 +912,9 @@
76c54e97 251 test -n "$DEBUG" && set -x
b1d5b2b9 252 Log `_ 'EJECT -> ejecting tape from %s' "$tape"`
76c54e97
TO
253 get_loaded_info
254- if [ $loadedslot -gt 0 ]; then
255+ if [ "$loadedslot" -gt 0 ]; then
b1d5b2b9 256 Log `_ 'EJECT -> moving tape from drive %s to storage slot %s' "$driveslot" "$loadedslot"`
76c54e97
TO
257- if [ $offline_before_unload -ne 0 ]; then
258+ if [ "$offline_before_unload" -ne 0 ]; then
b1d5b2b9 259 Run try_eject_device $tape
76c54e97
TO
260 fi
261 sleep $unloadpause
b1d5b2b9 262@@ -922,7 +922,7 @@
76c54e97 263 status=$?
b1d5b2b9 264 Log `_ ' -> status %s, result "%s"' "$status" "$result"`
76c54e97
TO
265 mtx_status_valid=0
266- if [ $status -ne 0 ]; then
267+ if [ "$status" -ne 0 ]; then
268 answer="$result"
269 code=2
270 else
b1d5b2b9 271@@ -1001,7 +1001,7 @@
76c54e97
TO
272 prev_slot=$1
273 shift
274 while [ $# -gt 0 ]; do
275- if [ $1 -eq $find_slot ]; then
276+ if [ "$1" -eq "$find_slot" ]; then
277 break
278 fi
279 prev_slot=$1
b1d5b2b9 280@@ -1030,15 +1030,15 @@
76c54e97
TO
281 # If the desired slot is already loaded, we are done. Only update
282 # current slot if this is not the cleaning slot.
283 get_loaded_info
284- if [ $loadslot = $loadedslot ]; then
285- if [ $loadslot -ne $cleanslot ]; then
286+ if [ "$loadslot" = "$loadedslot" ]; then
287+ if [ "$loadslot" -ne "$cleanslot" ]; then
288 rm -f $slotfile
289 echo $loadslot > $slotfile
290 fi
b1d5b2b9
JR
291 Exit 0 "$loadedslot" "$rawtape"
292 return $? # in case we are internal
293 fi
294- if [ $loadedslot -eq -2 ]; then
295+ if [ "$loadedslot" -eq -2 ]; then
296 Exit 0 "$loadedslot" "$rawtape"
297 return $? # in case we are internal
298 fi
299@@ -1046,20 +1046,20 @@
76c54e97
TO
300 # If we are loading the cleaning tape, bump the cleaning count
301 # and reset the access count. Otherwise, bump the access count
302 # and see if it is time to do a cleaning.
0adfa9dc
JR
303- if [ $loadslot = $cleanslot ]; then
304+ if [ "$loadslot" = "$cleanslot" ]; then
76c54e97 305 rm -f $cleanfile $accessfile
0adfa9dc
JR
306 expr $cleancount + 1 > $cleanfile
307 echo 0 > $accessfile
308 else
76c54e97 309 rm -f $accessfile
0adfa9dc 310 expr $accesscount + 1 > $accessfile
76c54e97
TO
311- if [ $autoclean -ne 0 -a $accesscount -gt $autocleancount ]
312+ if [ "$autoclean" -ne 0 -a "$accesscount" -gt "$autocleancount" ]
313 then
314 internal_call=`expr $internal_call + 1`
315 loadslot clean > /dev/null 2>&1
316 status=$?
317 internal_call=`expr $internal_call - 1`
318- if [ $status -ne 0 ]; then
319+ if [ "$status" -ne 0 ]; then
320 Exit $status "$loadslot" "$exit_answer"
321 return $? # in case we are internal
322 fi
b1d5b2b9 323@@ -1079,14 +1079,14 @@
76c54e97
TO
324 eject > /dev/null 2>&1
325 status=$?
326 internal_call=`expr $internal_call - 1`
327- if [ $status -gt 1 ]; then
328+ if [ "$status" -gt 1 ]; then
329 Exit $status "$exit_slot" "$exit_answer"
330 return $? # in case we are internal
0adfa9dc
JR
331 fi
332
76c54e97
TO
333 # If we were doing an "advance", we are done.
334- if [ $whichslot = advance ]; then
335- if [ $loadslot -ne $cleanslot ]; then
336+ if [ "$whichslot" = "advance" ]; then
337+ if [ "$loadslot" -ne "$cleanslot" ]; then
338 rm -f $slotfile
339 echo $loadslot > $slotfile
0adfa9dc 340 fi
b1d5b2b9 341@@ -1100,7 +1100,7 @@
76c54e97 342 status=$?
b1d5b2b9 343 Log `_ ' -> status %s, result "%s"' "$status" "$result"`
76c54e97 344 mtx_status_valid=0
0adfa9dc
JR
345- if [ $status -ne 0 ]; then
346+ if [ "$status" -ne 0 ]; then
76c54e97
TO
347 Exit 2 "$loadslot" "$result"
348 return $? # in case we are internal
349 fi
b1d5b2b9 350@@ -1110,7 +1110,7 @@
76c54e97
TO
351 # for "long enough" (as determined empirically by the user),
352 # then return success.
353 ###
354- if [ $loadslot -eq $cleanslot ]; then
355+ if [ "$loadslot" -eq "$cleanslot" ]; then
356 Run sleep $cleancycle
b1d5b2b9 357 Exit 0 "$loadslot" "$rawtape"
76c54e97 358 return $? # in case we are internal
b1d5b2b9
JR
359@@ -1122,7 +1122,7 @@
360 waittime=0
361 ready=0
362 sleep $initial_poll_delay
363- while [ $waittime -lt $max_drive_wait ]; do
364+ while [ "$waittime" -lt "$max_drive_wait" ]; do
365 amdevcheck_status $tape
366 if [ $? -eq 0 ]; then
367 ready=1
368@@ -1131,12 +1131,12 @@
76c54e97
TO
369 sleep $poll_drive_ready
370 waittime=`expr $waittime + $poll_drive_ready`
371 done
372- if [ $ready -eq 0 ]; then
373+ if [ "$ready" -eq 0 ]; then
b1d5b2b9 374 Exit 2 "$loadslot" `_ 'Drive not ready after %s seconds, rewind said "%s"' "$max_drive_wait" "$result"`
76c54e97
TO
375 return $? # in case we are internal
376 fi
0adfa9dc 377
76c54e97
TO
378- if [ $loadslot -ne $cleanslot ]; then
379+ if [ "$loadslot" -ne "$cleanslot" ]; then
380 rm -f $slotfile
381 echo $loadslot > $slotfile
382 fi
b1d5b2b9 383@@ -1167,11 +1167,11 @@
76c54e97
TO
384 # can search based on barcodes.
385 ###
386 reader=
0adfa9dc 387- if [ $havereader -eq 1 ]; then
0adfa9dc 388+ if [ "$havereader" -eq 1 ]; then
76c54e97
TO
389 reader=1
390 fi
0adfa9dc 391
76c54e97
TO
392- if [ $currentslot -lt $firstslot -o $currentslot -gt $lastslot ]; then
393+ if [ "$currentslot" -lt "$firstslot" -o "$currentslot" -gt "$lastslot" ]; then
394 currentslot=$firstslot # what "current" will get
395 fi
b1d5b2b9
JR
396 numslots=`expr $lastslot - $firstslot + 1`
397@@ -1202,7 +1202,7 @@
398 `_ 'Line %s malformed in %s: %s %s %s' "$line" "$labelfile" "$lbl" "$bc" "$junk"`
76c54e97
TO
399 return $? # in case we are internal
400 fi
401- if [ $lbl = "$lbl_search" -o $bc = "$bc_search" ]; then
76c54e97 402+ if [ "$lbl" = "$lbl_search" -o "$bc" = "$bc_search" ]; then
b1d5b2b9
JR
403 if [ $labelfile_entry_found -ne 0 ]; then
404 Log `_ 'ERROR -> Duplicate entries: %s line %s' "$labelfile" "$line"`
405 LogAppend `_ ' -> Remove %s and run "%s %s update"' "$labelfile" "$sbindir/amtape" "$config"`
406@@ -1230,12 +1230,12 @@
76c54e97
TO
407 return $? # in case we are internal
408 fi
409 tapelabel=$1
410- if [ $havereader -eq 0 ]; then
411+ if [ "$havereader" -eq 0 ]; then
b1d5b2b9 412 Exit 2 `_ '<none>'` `_ 'Not configured with barcode reader'`
76c54e97
TO
413 return $? # in case we are internal
414 fi
415 get_loaded_info
416- if [ $loadedslot -lt 0 ]; then
417+ if [ "$loadedslot" -lt 0 ]; then
b1d5b2b9 418 Exit 1 `_ '<none>'` `_ 'No tape currently loaded'`
76c54e97
TO
419 return $? # in case we are internal
420 fi
b1d5b2b9
JR
421@@ -1245,7 +1245,7 @@
422 fi
423 Log `_ 'LABEL -> Adding label "%s" with barcode "%s" for slot %s into %s' "$tapelabel" "$loadedbarcode" "$loadedslot" "$labelfile"`
76c54e97
TO
424 read_labelfile "$tapelabel" "$loadedbarcode" < $labelfile
425- if [ $labelfile_entry_found -ne 0 ]; then
426+ if [ "$labelfile_entry_found" -ne 0 ]; then
427 lf_val=
428 if [ "$labelfile_barcode" != "$loadedbarcode" ]; then
429 lf_type=label
b1d5b2b9 430@@ -1289,13 +1289,13 @@
76c54e97
TO
431 return $? # in case we are internal
432 fi
433 tapelabel=$1
434- if [ $havereader -eq 0 ]; then
435+ if [ "$havereader" -eq 0 ]; then
b1d5b2b9 436 Exit 2 `_ '<none>'` `_ 'Not configured with barcode reader'`
76c54e97
TO
437 return $? # in case we are internal
438 fi
b1d5b2b9 439 Log `_ 'SEARCH -> Hunting for label "%s"' "$tapelabel"`
76c54e97
TO
440 read_labelfile "$tapelabel" "" < $labelfile
441- if [ $labelfile_entry_found -eq 0 ]; then
442+ if [ "$labelfile_entry_found" -eq 0 ]; then
b1d5b2b9
JR
443 LogAppend `_ ' -> !!! label "%s" not found in %s !!!' "$tapelabel" "$labelfile"`
444 LogAppend `_ ' -> Remove %s and run "%s %s update"' "$labelfile" "$sbindir/amtape" "$config"`
445 Exit 2 \
This page took 0.097646 seconds and 4 git commands to generate.