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