Imported Upstream version 2.5.1p3
[debian/amanda] / changer-src / chg-zd-mtx.sh.in
index 1064eb0b66dd2495741eec7edc69076d8f433f10..281112cd5449f16dc734ce8768b214c31f0c9b35 100644 (file)
@@ -1,4 +1,4 @@
-#!/bin/sh 
+#!@SHELL@ 
 #
 # Exit Status:
 # 0 Alles Ok
@@ -68,6 +68,7 @@
 #            Storage Element 7:Full :VolumeTag=SR0007
 #            Storage Element 8:Full :VolumeTag=SR0008
 #            Storage Element 9:Full :VolumeTag=SR0009
+#            Storage Element 10 IMPORT/EXPORT:Full :VolumeTag=SR0009
 #
 #     This says the first storage slot (element) is "1" and the last
 #     is "9".  If you allocate the entire robot to Amanda, you do not need
 # in amanda.conf.  For example, if amanda.conf has:
 #
 #      changerfile="/etc/amanda/Dailyset1/CHANGER"
+#    or changerfile="/etc/amanda/Dailyset1/CHANGER.conf"
 #
 # the variables must be in "/etc/amanda/Dailyset1/CHANGER.conf".
+# The ".conf" is appended only if it's not there".
 #
 # If "changerfile" is a relative path, it is relative to the directory
 # that contains amanda.conf.  That also happens to be the directory Amanda
@@ -500,6 +503,14 @@ get_loaded_info() {
        s/.*Storage Element \([0-9][0-9]*\):Full/-2/p
         q
     }
+    /^.*Storage Element '$currentslot' IMPORT\/EXPORT:Empty/ {
+       s/.*Storage Element \([0-9][0-9]*\) IMPORT\/EXPORT:Empty/\1/p
+        q
+    }
+    /^.*Storage Element '$currentslot' IMPORT\/EXPORT:Full/ {
+       s/.*Storage Element \([0-9][0-9]*\) IMPORT\/EXPORT:Full/-2/p
+        q
+    }
 }
 ' < $mtx_status 2>& 1`
                shift                           # get rid of the "x"
@@ -517,6 +528,10 @@ get_loaded_info() {
        s/.*Storage Element \([0-9][0-9]*\):Empty/\1/p
         q
     }
+    /^.*Storage Element \([0-9][0-9]*\) IMPORT\/EXPORT:Empty/ {
+       s/.*Storage Element \([0-9][0-9]*\) IMPORT\/EXPORT:Empty/\1/p
+        q
+    }
 }
 ' < $mtx_status 2>& 1`
                shift                           # get rid of the "x"
@@ -569,6 +584,9 @@ get_slot_list() {
 /^.*Storage Element \([0-9][0-9]*\):Full/ {
     s/.*Storage Element \([0-9][0-9]*\):Full.*/\1/p
 }
+/^.*Storage Element \([0-9][0-9]*\) IMPORT\/EXPORT:Full/ {
+    s/.*Storage Element \([0-9][0-9]*\) IMPORT\/EXPORT:Full.*/\1/p
+}
 ' < $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
@@ -630,20 +648,20 @@ else
        SUF=
 fi
 
-DBGFILE=`amgetconf$SUF dbopen.$argv0 2>/dev/null | grep -v BUGGY`
+DBGFILE=`amgetconf$SUF dbopen.$argv0 2>/dev/null`
 if [ -z "$DBGFILE" ]
 then
        DBGFILE=/dev/null                       # will try this again below
 fi
 
-changerfile=`amgetconf$SUF changerfile 2>/dev/null | grep -v BUGGY`
+changerfile=`amgetconf$SUF changerfile 2>/dev/null`
 if [ -z "$changerfile" ]; then
        Exit 2 \
             "<none>" \
             "changerfile must be specified in amanda.conf"
 fi
 
-tape=`amgetconf$SUF tapedev 2>/dev/null | grep -v BUGGY`
+tape=`amgetconf$SUF tapedev 2>/dev/null`
 if [ -z "$tape" ]; then
        Exit 2 \
             "<none>" \
@@ -653,7 +671,7 @@ elif [ $tape = "/dev/null" -o `expr "$tape" : 'null:'` -eq 5 ]; then
             "<none>" \
             "tapedev ($tape) may not be the null device"
 fi
-TAPE=`amgetconf$SUF changerdev 2>/dev/null | grep -v BUGGY`
+TAPE=`amgetconf$SUF changerdev 2>/dev/null`
 if [ -z "$TAPE" ]; then
        Exit 2 \
             "<none>" \
@@ -665,9 +683,19 @@ elif [ $TAPE = "/dev/null" ]; then
 fi
 export TAPE                                    # for mtx command
 
+CHANGER=$TAPE
+export CHANGER                                 # for mtx command
+
 #### Set up the various config files.
 
-configfile=$changerfile.conf
+conf_match=`expr "$changerfile" : .\*\.conf\$`
+if [ $conf_match -ge 6 ]; then
+       configfile=$changerfile
+       changerfile=`echo $changerfile | sed 's/.conf$//g'`
+else
+       configfile=$changerfile.conf
+fi
+
 cleanfile=$changerfile-clean
 accessfile=$changerfile-access
 slotfile=$changerfile-slot
@@ -679,6 +707,11 @@ labelfile=$changerfile-barcodes
 cleancount=`cat $cleanfile`
 accesscount=`cat $accessfile`
 
+test -z "$MT" && Exit 2 "<none>" "No mt command defined"
+test ! -f "$MT" && Exit 2 "<none>" "mt command ($MT) doesn't exist"
+test -z "$MTX" && Exit 2 "<none>" "No mtx command defined"
+test ! -f "$MTX" && Exit 2 "<none>" "mtx command ($MTX) doesn't exist"
+
 #### Dig out of the config file what is needed
 
 varlist=
@@ -1139,9 +1172,7 @@ info() {
        if [ $currentslot -lt $firstslot -o $currentslot -gt $lastslot ]; then
                currentslot=$firstslot          # what "current" will get
        fi
-       set x $slot_list
-       shift                                   # get rid of the "x"
-       numslots=$#
+       numslots=`expr $lastslot - $firstslot + 1`
        Exit 0 "$currentslot" "$numslots 1 $reader"
        return $?                               # in case we are internal
 }