-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
---- amanda-2.4.2p2/changer-src/chg-zd-mtx.sh.in Tue Apr 3 02:43:07 2001
-+++ amanda-2.4.2p2.new/changer-src/chg-zd-mtx.sh.in Tue Mar 19 20:06:46 2002
-@@ -158,8 +158,8 @@
- eject() {
- readstatus
- echo "EJECT -> ejecting tape from $tape to slot $usedslot" >> $DBGFILE
-- if [ $usedslot -gt 0 ]; then
-- if [ $OFFLINE_BEFORE_UNLOAD -gt 0 ]; then
-+ if [ "$usedslot" -gt 0 ]; then
-+ if [ "$OFFLINE_BEFORE_UNLOAD" -gt 0 ]; then
- $MT $MTF $tape offline
- fi
- $MTX unload $usedslot $drivenum 2>/dev/null
-@@ -192,7 +192,7 @@
- echo "LOADSLOT -> load tape from slot $whichslot" >> $DBGFILE
- case $whichslot in
- current)
-- if [ $usedslot -lt 0 ]; then
-+ if [ "$usedslot" -lt 0 ]; then
- loadslot=$firstslot
- else
- echo "$usedslot $tape"
-@@ -200,18 +200,18 @@
- fi
- ;;
- next|advance)
-- if [ $usedslot -lt 0 ]; then
-+ if [ "$usedslot" -lt 0 ]; then
- loadslot=$firstslot
- else
- loadslot=`expr $usedslot + 1`
-- if [ $loadslot -gt $lastslot ]; then
-+ if [ "$loadslot" -gt "$lastslot" ]; then
- loadslot=$firstslot
- fi
+--- amanda-2.4.3/changer-src/chg-zd-mtx.sh.in.orig Mon Sep 16 16:36:15 2002
++++ amanda-2.4.3/changer-src/chg-zd-mtx.sh.in Thu Jan 9 23:16:47 2003
+@@ -358,7 +358,7 @@
+
+ internal_call=0
+ Exit() {
+- if [ $internal_call -gt 0 ]; then
++ if [ "$internal_call" -gt 0 ]; then
+ call_type=Return
+ else
+ call_type=Exit
+@@ -370,7 +370,7 @@
+ exit_answer="$@"
+ Log $call_type "($code)" "->" "$exit_slot" "$@"
+ echo "$exit_slot" "$@"
+- if [ $call_type = Return ]; then
++ if [ "$call_type" = "Return" ]; then
+ return $code
+ fi
+ amgetconf$SUF dbclose.$argv0:$DBGFILE > /dev/null 2>&1
+@@ -419,13 +419,13 @@
+ mtx_status_valid=0
+ get_mtx_status() {
+ test -n "$DEBUG" && set -x
+- if [ $mtx_status_valid -ne 0 ]; then
++ if [ "$mtx_status_valid" -ne 0 ]; then
+ return 0
+ fi
+ rm -f $mtx_status
+ Run $MTX status > $mtx_status 2>&1
+ status=$?
+- if [ $status -eq 0 ]; then
++ if [ "$status" -eq 0 ]; then
+ mtx_status_valid=1
+ fi
+ return $status
+@@ -512,27 +512,27 @@
+ }
+ ' < $mtx_status 2>&1 | grep -v "^${cleanslot}\$" | sort -n`
+ slot_list=`echo $slot_list` # remove the newlines
+- if [ $firstslot -lt 0 -o $lastslot -lt 0 ]; then
++ if [ "$firstslot" -lt 0 -o "$lastslot" -lt 0 ]; then
+ last=$lastslot
+ for slot in $slot_list; do
+- if [ $firstslot -lt 0 ]; then
++ if [ "$firstslot" -lt 0 ]; then
+ Log "SLOTLIST -> firstslot set to $slot"
+ firstslot=$slot
fi
- ;;
- prev)
- loadslot=`expr $usedslot - 1`
-- if [ $loadslot -lt $firstslot ]; then
-+ if [ "$loadslot" -lt "$firstslot" ]; then
- loadslot=$lastslot
+- if [ $lastslot -lt 0 ]; then
++ if [ "$lastslot" -lt 0 ]; then
+ last=$slot
fi
- ;;
-@@ -222,7 +222,7 @@
- loadslot=$lastslot
- ;;
- $numeric)
-- if [ $whichslot -gt $lastslot ] || [ $whichslot -lt $firstslot ]; then
-+ if [ "$whichslot" -gt "$lastslot" ] || [ "$whichslot" -lt "$firstslot" ]; then
- echo "0 Slot $whichslot is out of range ($firstslot - $lastslot)"
- exit 1
- else
-@@ -239,18 +239,18 @@
- esac
+ done
+- if [ $lastslot -lt 0 -a $last -ge 0 ]; then
++ if [ "$lastslot" -lt 0 -a "$last" -ge 0 ]; then
+ Log "SLOTLIST -> lastslot set to $last"
+ lastslot=$last
+ fi
+- if [ $firstslot -lt 0 ]; then
++ if [ "$firstslot" -lt 0 ]; then
+ Exit 2 \
+ "<none>" \
+ "cannot determine first slot"
+ return $? # in case we are internal
+- elif [ $lastslot -lt 0 ]; then
++ elif [ "$lastslot" -lt 0 ]; then
+ Exit 2 \
+ "<none>" \
+ "cannot determine last slot"
+@@ -541,7 +541,7 @@
+ fi
+ amanda_slot_list=
+ for slot in $slot_list; do
+- if [ $slot -ge $firstslot -a $slot -le $lastslot ]; then
++ if [ "$slot" -ge "$firstslot" -a "$slot" -le "$lastslot" ]; then
+ amanda_slot_list="$amanda_slot_list $slot"
+ fi
+ done
+@@ -589,7 +589,7 @@
+ Exit 2 \
+ "<none>" \
+ "tapedev may not be empty"
+-elif [ $tape = "/dev/null" -o `expr "$tape" : 'null:'` -eq 5 ]; then
++elif [ "$tape" = "/dev/null" -o `expr "$tape" : 'null:'` -eq 5 ]; then
+ Exit 2 \
+ "<none>" \
+ "tapedev ($tape) may not be the null device"
+@@ -599,7 +599,7 @@
+ Exit 2 \
+ "<none>" \
+ "changerdev may not be empty"
+-elif [ $TAPE = "/dev/null" ]; then
++elif [ "$TAPE" = "/dev/null" ]; then
+ Exit 2 \
+ "<none>" \
+ "changerdev ($TAPE) may not be the null device"
+@@ -674,7 +674,7 @@
+
+ # Get DBGFILE set if it is not already.
+
+-if [ $DBGFILE = /dev/null ]; then
++if [ "$DBGFILE" = /dev/null ]; then
+ if [ -d "$DBGDIR" ]; then
+ DBGFILE=$DBGDIR/changer.debug.drive$driveslot
+ else
+@@ -729,9 +729,9 @@
- # Is this already the current slot?
-- if [ $loadslot = $usedslot ]; then
-+ if [ "$loadslo"t = "$usedslot" ]; then
- echo "$usedslot $tape"
- exit 0
+ Log "Config info:"
+ for var in $varlist; do
+- if [ $var = "OFFLINE_BEFORE_UNLOAD" ]; then
++ if [ "$var" = "OFFLINE_BEFORE_UNLOAD" ]; then
+ continue # old name
+- elif [ $var = "AUTOCLEAN" ]; then
++ elif [ "$var" = "AUTOCLEAN" ]; then
+ continue # old name
fi
+ eval val=\"'$'$var\"
+@@ -752,13 +752,13 @@
- # Is this a cleaning request?
+ # Run the rest of the config file sanity checks.
+
+-if [ $firstslot -gt $lastslot ]; then
++if [ "$firstslot" -gt "$lastslot" ]; then
+ Exit 2 \
+ "<none>" \
+ "firstslot ($firstslot) greater than" \
+ "lastslot ($lastslot) in $configfile"
+ fi
+-if [ $autoclean -ne 0 -a $cleanslot -lt 0 ]; then
++if [ "$autoclean" -ne 0 -a "$cleanslot" -lt 0 ]; then
+ Exit 2 \
+ "<none>" \
+ "autoclean set but cleanslot not valid ($cleanslot)"
+@@ -768,12 +768,12 @@
+
+ currentslot=`cat $slotfile`
+ if IsNumeric "$currentslot" ; then
+- if [ $currentslot -lt $firstslot ]; then
++ if [ "$currentslot" -lt "$firstslot" ]; then
+ Log "SETUP -> current slot $currentslot" \
+ "less than $firstslot ..." \
+ "resetting to $firstslot"
+ currentslot=$firstslot
+- elif [ $currentslot -gt $lastslot ]; then
++ elif [ "$currentslot" -gt "$lastslot" ]; then
+ Log "SETUP -> current slot $currentslot" \
+ "greater than $lastslot ..." \
+ "resetting to $lastslot"
+@@ -789,19 +789,19 @@
+ first_slot_in_list=-1
+ next_slot_after_current=-1
+ for slot in $slot_list; do
+- if [ $first_slot_in_list -lt 0 ]; then
++ if [ "$first_slot"_in_list -lt 0 ]; then
+ first_slot_in_list=$slot # in case $firstslot is missing
+ fi
+- if [ $slot -eq $currentslot ]; then
++ if [ "$slot" -eq "$currentslot" ]; then
+ found_current=1
+ break
+- elif [ $slot -gt $currentslot ]; then
++ elif [ "$slot" -gt "$currentslot" ]; then
+ next_slot_after_current=$slot # $currentslot is missing
+ break
+ fi
+ done
+-if [ $found_current -eq 0 ]; then
+- if [ $next_slot_after_current -lt 0 ]; then
++if [ "$found_current" -eq 0 ]; then
++ if [ "$next_slot_after_current" -lt 0 ]; then
+ new_currentslot=$first_slot_in_list
+ else
+ new_currentslot=$next_slot_after_current
+@@ -821,10 +821,10 @@
+ test -n "$DEBUG" && set -x
+ Log "EJECT -> ejecting tape from $tape"
+ get_loaded_info
+- if [ $loadedslot -gt 0 ]; then
++ if [ "$loadedslot" -gt 0 ]; then
+ Log "EJECT -> moving tape from drive $driveslot" \
+ "to storage slot $loadedslot"
+- if [ $offline_before_unload -ne 0 ]; then
++ if [ "$offline_before_unload" -ne 0 ]; then
+ Run $MT $MTF $tape offline > /dev/null 2>&1
+ fi
+ sleep $unloadpause
+@@ -832,7 +832,7 @@
+ status=$?
+ Log " -> status $status, result \"$result\""
+ mtx_status_valid=0
+- if [ $status -ne 0 ]; then
++ if [ "$status" -ne 0 ]; then
+ answer="$result"
+ code=2
+ else
+@@ -912,7 +912,7 @@
+ prev_slot=$1
+ shift
+ while [ $# -gt 0 ]; do
+- if [ $1 -eq $find_slot ]; then
++ if [ "$1" -eq "$find_slot" ]; then
+ break
+ fi
+ prev_slot=$1
+@@ -942,8 +942,8 @@
+ # If the desired slot is already loaded, we are done. Only update
+ # current slot if this is not the cleaning slot.
+ get_loaded_info
+- if [ $loadslot = $loadedslot ]; then
+- if [ $loadslot -ne $cleanslot ]; then
++ if [ "$loadslot" = "$loadedslot" ]; then
++ if [ "$loadslot" -ne "$cleanslot" ]; then
+ rm -f $slotfile
+ echo $loadslot > $slotfile
+ fi
+@@ -954,20 +954,20 @@
+ # If we are loading the cleaning tape, bump the cleaning count
+ # and reset the access count. Otherwise, bump the access count
+ # and see if it is time to do a cleaning.
- if [ $loadslot = $cleanslot ]; then
+ if [ "$loadslot" = "$cleanslot" ]; then
+ rm -f $cleanfile $accessfile
expr $cleancount + 1 > $cleanfile
echo 0 > $accessfile
else
+ rm -f $accessfile
expr $accesscount + 1 > $accessfile
-- if [ $AUTOCLEAN -gt 0 -a $accesscount -gt $autocleancount ]; then
-+ if [ "$AUTOCLEAN" -gt 0 -a "$accesscount" -gt "$autocleancount" ]; then
- $myname -slot clean >/dev/null
-
- # Slot $cleanslot might contain an ordinary tape rather than a cleaning
-@@ -261,9 +261,9 @@
+- if [ $autoclean -ne 0 -a $accesscount -gt $autocleancount ]
++ if [ "$autoclean" -ne 0 -a "$accesscount" -gt "$autocleancount" ]
+ then
+ internal_call=`expr $internal_call + 1`
+ loadslot clean > /dev/null 2>&1
+ status=$?
+ internal_call=`expr $internal_call - 1`
+- if [ $status -ne 0 ]; then
++ if [ "$status" -ne 0 ]; then
+ Exit $status "$loadslot" "$exit_answer"
+ return $? # in case we are internal
+ fi
+@@ -987,14 +987,14 @@
+ eject > /dev/null 2>&1
+ status=$?
+ internal_call=`expr $internal_call - 1`
+- if [ $status -gt 1 ]; then
++ if [ "$status" -gt 1 ]; then
+ Exit $status "$exit_slot" "$exit_answer"
+ return $? # in case we are internal
fi
- # Unload any previous tape
-- if [ $usedslot -ne "-1" ]; then
-+ if [ "$usedslot" -ne "-1" ]; then
- echo " -> unload $usedslot from $tape" >> $DBGFILE
-- if [ $OFFLINE_BEFORE_UNLOAD -gt 0 ]; then
-+ if [ "$OFFLINE_BEFORE_UNLOAD" -gt 0 ]; then
- $MT $MTF $tape offline
+ # If we were doing an "advance", we are done.
+- if [ $whichslot = advance ]; then
+- if [ $loadslot -ne $cleanslot ]; then
++ if [ "$whichslot" = "advance" ]; then
++ if [ "$loadslot" -ne "$cleanslot" ]; then
+ rm -f $slotfile
+ echo $loadslot > $slotfile
fi
- result=`$MTX unload $usedslot $drivenum 2>&1`
-@@ -282,7 +282,7 @@
- echo " -> status $status, result '$result'" >> $DBGFILE
-
- # If there is an error, abort unless the slot is simply empty
+@@ -1009,7 +1009,7 @@
+ status=$?
+ Log " -> status $status, result \"$result\""
+ mtx_status_valid=0
- if [ $status -ne 0 ]; then
+ if [ "$status" -ne 0 ]; then
- empty=`echo $result | grep "Empty"`
- if [ -z "$empty" ]; then
- echo "$loadslot $result"
-@@ -299,7 +299,7 @@
- #### Don't assume the drive is ready until we get an ONLINE
- #### This is tested by the variable $offlinestatus from the beginning.
+ Exit 2 "$loadslot" "$result"
+ return $? # in case we are internal
+ fi
+@@ -1019,7 +1019,7 @@
+ # for "long enough" (as determined empirically by the user),
+ # then return success.
+ ###
+- if [ $loadslot -eq $cleanslot ]; then
++ if [ "$loadslot" -eq "$cleanslot" ]; then
+ Run sleep $cleancycle
+ Exit 0 "$loadslot" "$tape"
+ return $? # in case we are internal
+@@ -1039,14 +1039,14 @@
+ sleep $poll_drive_ready
+ waittime=`expr $waittime + $poll_drive_ready`
+ done
+- if [ $ready -eq 0 ]; then
++ if [ "$ready" -eq 0 ]; then
+ Exit 2 "$loadslot" "Drive not ready after" \
+ "$max_drive_wait seconds," \
+ "rewind said \"$result\""
+ return $? # in case we are internal
+ fi
-- if [ $offlinestatus -eq 0 ]; then
-+ if [ "$offlinestatus" -eq 0 ]; then
- readyError="offline"
- while [ -n "$readyError" ]; do
- readyStatus=`$MT $MTF $tape status 2>&1`
-@@ -330,8 +330,8 @@
- echo "INFO -> current slot $usedslot, last slot $lastslot, can go backwards 1" >> $DBGFILE
- #### Checks if you have a barcode reader or not. If so, it passes the 4th item in the echo
- #### back to amtape signifying it can search based on barcodes.
+- if [ $loadslot -ne $cleanslot ]; then
++ if [ "$loadslot" -ne "$cleanslot" ]; then
+ rm -f $slotfile
+ echo $loadslot > $slotfile
+ fi
+@@ -1077,11 +1077,11 @@
+ # can search based on barcodes.
+ ###
+ reader=
- if [ $havereader -eq 1 ]; then
-- if [ $usedslot -lt 0 ]; then
+ if [ "$havereader" -eq 1 ]; then
-+ if [ "$usedslot" -lt 0 ]; then
- #### added a variable to the end of the following 2 echos.
- #### This indicates to amtape that it can/cannot read barcodes.
- echo "0 $lastslot 1 1"
-@@ -340,7 +340,7 @@
- fi
- exit 0
- else
-- if [ $usedslot -lt 0 ]; then
-+ if [ "$usedslot" -lt 0 ]; then
- echo "0 $lastslot 1"
- else
- echo "$usedslot $lastslot 1"
-@@ -360,17 +360,17 @@
- case $tapelabel in
- $tapelabel)
- echo "LABEL -> Adding Barcode $barcode and amlabel $tapelabel for Slot $usedslot into $labelfile" >> $DBGFILE
-- if [ $labelfilesize -eq 2 ]; then
-+ if [ "$labelfilesize" -eq 2 ]; then
- echo "$tapelabel $barcode" > $labelfile
- echo "0 $usedslot $tape"
- else
- included=`grep $tapelabel $labelfile | awk '{print $1}'`
-- if [ -z $included ]; then
-+ if [ -z "$included" ]; then
- echo "$tapelabel $barcode" >> $labelfile
- echo "0 $usedslot $tape"
- else
- oldbarcode=`grep $tapelabel $labelfile | awk '{print $2}'`
-- if [ $oldbarcode -eq $barcode ]; then
-+ if [ "$oldbarcode" -eq "$barcode" ]; then
- echo " -> Barcode $barcode $oldbarcode already synced for $tapelabel" >> $DBGFILE
- echo "0 $usedslot $tape"
+ reader=1
+ fi
-@@ -403,7 +403,7 @@
- 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"`
- case $tapelabel in
- $tapelabel)
-- if [ $tapelabel == $includedtag ]; then
-+ if [ "$tapelabel" == "$includedtag" ]; then
- shift
- loadslot $includedslot
- echo "$tape"
+- if [ $currentslot -lt $firstslot -o $currentslot -gt $lastslot ]; then
++ if [ "$currentslot" -lt "$firstslot" -o "$currentslot" -gt "$lastslot" ]; then
+ currentslot=$firstslot # what "current" will get
+ fi
+ set x $slot_list
+@@ -1116,8 +1116,8 @@
+ "Line $line malformed in $labelfile: $lbl $bc $junk"
+ return $? # in case we are internal
+ fi
+- if [ $lbl = "$lbl_search" -o $bc = "$bc_search" ]; then
+- if [ $labelfile_entry_found -ne 0 ]; then
++ if [ "$lbl" = "$lbl_search" -o "$bc" = "$bc_search" ]; then
++ if [ "$labelfile_entry_found" -ne 0 ]; then
+ Log "ERROR -> Duplicate entries: $labelfile line $line"
+ LogAppend " -> Remove $labelfile" \
+ "and run" \
+@@ -1146,12 +1146,12 @@
+ return $? # in case we are internal
+ fi
+ tapelabel=$1
+- if [ $havereader -eq 0 ]; then
++ if [ "$havereader" -eq 0 ]; then
+ Exit 2 "<none>" "Not configured with barcode reader"
+ return $? # in case we are internal
+ fi
+ get_loaded_info
+- if [ $loadedslot -lt 0 ]; then
++ if [ "$loadedslot" -lt 0 ]; then
+ Exit 1 "<none>" "No tape currently loaded"
+ return $? # in case we are internal
+ fi
+@@ -1160,7 +1160,7 @@
+ "for slot $loadedslot" \
+ "into $labelfile"
+ read_labelfile "$tapelabel" "$loadedbarcode" < $labelfile
+- if [ $labelfile_entry_found -ne 0 ]; then
++ if [ "$labelfile_entry_found" -ne 0 ]; then
+ lf_val=
+ if [ "$labelfile_barcode" != "$loadedbarcode" ]; then
+ lf_type=label
+@@ -1212,13 +1212,13 @@
+ return $? # in case we are internal
+ fi
+ tapelabel=$1
+- if [ $havereader -eq 0 ]; then
++ if [ "$havereader" -eq 0 ]; then
+ Exit 2 "<none>" "Not configured with barcode reader"
+ return $? # in case we are internal
+ fi
+ Log "SEARCH -> Hunting for label \"$tapelabel\""
+ read_labelfile "$tapelabel" "" < $labelfile
+- if [ $labelfile_entry_found -eq 0 ]; then
++ if [ "$labelfile_entry_found" -eq 0 ]; then
+ LogAppend " -> !!! label \"$tapelabel\" not found" \
+ "in $labelfile !!!"
+ LogAppend " -> Remove $labelfile" \