]>
Commit | Line | Data |
---|---|---|
76c54e97 TO |
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 | |
3 | @@ -358,7 +358,7 @@ | |
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 | |
12 | @@ -370,7 +370,7 @@ | |
13 | exit_answer="$@" | |
14 | Log $call_type "($code)" "->" "$exit_slot" "$@" | |
15 | echo "$exit_slot" "$@" | |
16 | - if [ $call_type = Return ]; then | |
17 | + if [ "$call_type" = "Return" ]; then | |
18 | return $code | |
19 | fi | |
20 | amgetconf$SUF dbclose.$argv0:$DBGFILE > /dev/null 2>&1 | |
21 | @@ -419,13 +419,13 @@ | |
22 | mtx_status_valid=0 | |
23 | get_mtx_status() { | |
24 | test -n "$DEBUG" && set -x | |
25 | - if [ $mtx_status_valid -ne 0 ]; then | |
26 | + if [ "$mtx_status_valid" -ne 0 ]; then | |
27 | return 0 | |
28 | fi | |
29 | rm -f $mtx_status | |
30 | Run $MTX status > $mtx_status 2>&1 | |
31 | status=$? | |
32 | - if [ $status -eq 0 ]; then | |
33 | + if [ "$status" -eq 0 ]; then | |
34 | mtx_status_valid=1 | |
35 | fi | |
36 | return $status | |
37 | @@ -512,27 +512,27 @@ | |
38 | } | |
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 | |
43 | last=$lastslot | |
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" | |
48 | firstslot=$slot | |
0adfa9dc | 49 | fi |
76c54e97 TO |
50 | - if [ $lastslot -lt 0 ]; then |
51 | + if [ "$lastslot" -lt 0 ]; then | |
52 | last=$slot | |
0adfa9dc | 53 | fi |
76c54e97 TO |
54 | done |
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" | |
58 | lastslot=$last | |
59 | fi | |
60 | - if [ $firstslot -lt 0 ]; then | |
61 | + if [ "$firstslot" -lt 0 ]; then | |
62 | Exit 2 \ | |
63 | "<none>" \ | |
64 | "cannot determine first slot" | |
65 | return $? # in case we are internal | |
66 | - elif [ $lastslot -lt 0 ]; then | |
67 | + elif [ "$lastslot" -lt 0 ]; then | |
68 | Exit 2 \ | |
69 | "<none>" \ | |
70 | "cannot determine last slot" | |
71 | @@ -541,7 +541,7 @@ | |
72 | fi | |
73 | amanda_slot_list= | |
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" | |
78 | fi | |
79 | done | |
80 | @@ -589,7 +589,7 @@ | |
81 | Exit 2 \ | |
82 | "<none>" \ | |
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 | |
86 | Exit 2 \ | |
87 | "<none>" \ | |
88 | "tapedev ($tape) may not be the null device" | |
89 | @@ -599,7 +599,7 @@ | |
90 | Exit 2 \ | |
91 | "<none>" \ | |
92 | "changerdev may not be empty" | |
93 | -elif [ $TAPE = "/dev/null" ]; then | |
94 | +elif [ "$TAPE" = "/dev/null" ]; then | |
95 | Exit 2 \ | |
96 | "<none>" \ | |
97 | "changerdev ($TAPE) may not be the null device" | |
98 | @@ -674,7 +674,7 @@ | |
99 | ||
100 | # Get DBGFILE set if it is not already. | |
101 | ||
102 | -if [ $DBGFILE = /dev/null ]; then | |
103 | +if [ "$DBGFILE" = /dev/null ]; then | |
104 | if [ -d "$DBGDIR" ]; then | |
105 | DBGFILE=$DBGDIR/changer.debug.drive$driveslot | |
106 | else | |
107 | @@ -729,9 +729,9 @@ | |
0adfa9dc | 108 | |
76c54e97 TO |
109 | Log "Config info:" |
110 | for var in $varlist; do | |
111 | - if [ $var = "OFFLINE_BEFORE_UNLOAD" ]; then | |
112 | + if [ "$var" = "OFFLINE_BEFORE_UNLOAD" ]; then | |
113 | continue # old name | |
114 | - elif [ $var = "AUTOCLEAN" ]; then | |
115 | + elif [ "$var" = "AUTOCLEAN" ]; then | |
116 | continue # old name | |
0adfa9dc | 117 | fi |
76c54e97 TO |
118 | eval val=\"'$'$var\" |
119 | @@ -752,13 +752,13 @@ | |
0adfa9dc | 120 | |
76c54e97 TO |
121 | # Run the rest of the config file sanity checks. |
122 | ||
123 | -if [ $firstslot -gt $lastslot ]; then | |
124 | +if [ "$firstslot" -gt "$lastslot" ]; then | |
125 | Exit 2 \ | |
126 | "<none>" \ | |
127 | "firstslot ($firstslot) greater than" \ | |
128 | "lastslot ($lastslot) in $configfile" | |
129 | fi | |
130 | -if [ $autoclean -ne 0 -a $cleanslot -lt 0 ]; then | |
131 | +if [ "$autoclean" -ne 0 -a "$cleanslot" -lt 0 ]; then | |
132 | Exit 2 \ | |
133 | "<none>" \ | |
134 | "autoclean set but cleanslot not valid ($cleanslot)" | |
135 | @@ -768,12 +768,12 @@ | |
136 | ||
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 | |
157 | fi | |
158 | - if [ $slot -eq $currentslot ]; then | |
159 | + if [ "$slot" -eq "$currentslot" ]; then | |
160 | found_current=1 | |
161 | break | |
162 | - elif [ $slot -gt $currentslot ]; then | |
163 | + elif [ "$slot" -gt "$currentslot" ]; then | |
164 | next_slot_after_current=$slot # $currentslot is missing | |
165 | break | |
166 | fi | |
167 | done | |
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 | |
173 | else | |
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" | |
178 | get_loaded_info | |
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 | |
186 | fi | |
187 | sleep $unloadpause | |
188 | @@ -832,7 +832,7 @@ | |
189 | status=$? | |
190 | Log " -> status $status, result \"$result\"" | |
191 | mtx_status_valid=0 | |
192 | - if [ $status -ne 0 ]; then | |
193 | + if [ "$status" -ne 0 ]; then | |
194 | answer="$result" | |
195 | code=2 | |
196 | else | |
197 | @@ -912,7 +912,7 @@ | |
198 | prev_slot=$1 | |
199 | shift | |
200 | while [ $# -gt 0 ]; do | |
201 | - if [ $1 -eq $find_slot ]; then | |
202 | + if [ "$1" -eq "$find_slot" ]; then | |
203 | break | |
204 | fi | |
205 | prev_slot=$1 | |
206 | @@ -942,8 +942,8 @@ | |
207 | # If the desired slot is already loaded, we are done. Only update | |
208 | # current slot if this is not the cleaning slot. | |
209 | get_loaded_info | |
210 | - if [ $loadslot = $loadedslot ]; then | |
211 | - if [ $loadslot -ne $cleanslot ]; then | |
212 | + if [ "$loadslot" = "$loadedslot" ]; then | |
213 | + if [ "$loadslot" -ne "$cleanslot" ]; then | |
214 | rm -f $slotfile | |
215 | echo $loadslot > $slotfile | |
216 | fi | |
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. | |
0adfa9dc JR |
221 | - if [ $loadslot = $cleanslot ]; then |
222 | + if [ "$loadslot" = "$cleanslot" ]; then | |
76c54e97 | 223 | rm -f $cleanfile $accessfile |
0adfa9dc JR |
224 | expr $cleancount + 1 > $cleanfile |
225 | echo 0 > $accessfile | |
226 | else | |
76c54e97 | 227 | rm -f $accessfile |
0adfa9dc | 228 | expr $accesscount + 1 > $accessfile |
76c54e97 TO |
229 | - if [ $autoclean -ne 0 -a $accesscount -gt $autocleancount ] |
230 | + if [ "$autoclean" -ne 0 -a "$accesscount" -gt "$autocleancount" ] | |
231 | then | |
232 | internal_call=`expr $internal_call + 1` | |
233 | loadslot clean > /dev/null 2>&1 | |
234 | status=$? | |
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 | |
240 | fi | |
241 | @@ -987,14 +987,14 @@ | |
242 | eject > /dev/null 2>&1 | |
243 | status=$? | |
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 | |
0adfa9dc JR |
249 | fi |
250 | ||
76c54e97 TO |
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 | |
256 | rm -f $slotfile | |
257 | echo $loadslot > $slotfile | |
0adfa9dc | 258 | fi |
76c54e97 TO |
259 | @@ -1009,7 +1009,7 @@ |
260 | status=$? | |
261 | Log " -> status $status, result \"$result\"" | |
262 | mtx_status_valid=0 | |
0adfa9dc JR |
263 | - if [ $status -ne 0 ]; then |
264 | + if [ "$status" -ne 0 ]; then | |
76c54e97 TO |
265 | Exit 2 "$loadslot" "$result" |
266 | return $? # in case we are internal | |
267 | fi | |
268 | @@ -1019,7 +1019,7 @@ | |
269 | # for "long enough" (as determined empirically by the user), | |
270 | # then return success. | |
271 | ### | |
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` | |
280 | done | |
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 | |
287 | fi | |
0adfa9dc | 288 | |
76c54e97 TO |
289 | - if [ $loadslot -ne $cleanslot ]; then |
290 | + if [ "$loadslot" -ne "$cleanslot" ]; then | |
291 | rm -f $slotfile | |
292 | echo $loadslot > $slotfile | |
293 | fi | |
294 | @@ -1077,11 +1077,11 @@ | |
295 | # can search based on barcodes. | |
296 | ### | |
297 | reader= | |
0adfa9dc | 298 | - if [ $havereader -eq 1 ]; then |
0adfa9dc | 299 | + if [ "$havereader" -eq 1 ]; then |
76c54e97 TO |
300 | reader=1 |
301 | fi | |
0adfa9dc | 302 | |
76c54e97 TO |
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 | |
306 | fi | |
307 | set x $slot_list | |
308 | @@ -1116,8 +1116,8 @@ | |
309 | "Line $line malformed in $labelfile: $lbl $bc $junk" | |
310 | return $? # in case we are internal | |
311 | fi | |
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" \ | |
318 | "and run" \ | |
319 | @@ -1146,12 +1146,12 @@ | |
320 | return $? # in case we are internal | |
321 | fi | |
322 | tapelabel=$1 | |
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 | |
327 | fi | |
328 | get_loaded_info | |
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 | |
333 | fi | |
334 | @@ -1160,7 +1160,7 @@ | |
335 | "for slot $loadedslot" \ | |
336 | "into $labelfile" | |
337 | read_labelfile "$tapelabel" "$loadedbarcode" < $labelfile | |
338 | - if [ $labelfile_entry_found -ne 0 ]; then | |
339 | + if [ "$labelfile_entry_found" -ne 0 ]; then | |
340 | lf_val= | |
341 | if [ "$labelfile_barcode" != "$loadedbarcode" ]; then | |
342 | lf_type=label | |
343 | @@ -1212,13 +1212,13 @@ | |
344 | return $? # in case we are internal | |
345 | fi | |
346 | tapelabel=$1 | |
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 | |
351 | fi | |
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" \ | |
357 | "in $labelfile !!!" | |
358 | LogAppend " -> Remove $labelfile" \ |