]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/examples/autochangers/locking-mtx-changer
Fix scripts/bacula.in to have awk on an environment variable
[bacula/bacula] / bacula / examples / autochangers / locking-mtx-changer
index 451a36de982a651ee4c5842a1b2721bbdfc4adb2..8c43621b92b9d0ad0c5d110c8fcfe536bb5d98fb 100644 (file)
@@ -10,7 +10,7 @@
 #    you will have the following input to this script:
 #
 #  mtx-changer "changer-device" "command" "slot" "archive-device" "drive-index"
-#                 $1              $2       $3        $4               $5
+#                  $1              $2       $3        $4               $5
 #
 #  for example:
 #
@@ -51,8 +51,8 @@ fi
 
 wait_for_drive() {
     while ! mt -f $1 status >/dev/null 2>/dev/null; do
-#      echo "Device $1 - not ready, retrying..."
-       sleep 5
+#       echo "Device $1 - not ready, retrying..."
+        sleep 5
     done
 }
 
@@ -72,9 +72,10 @@ changer_lock() {
 changer_unlock() {
     LOCKPID="`cat $LOCKFILE 2>/dev/null`"
     if [ "$LOCKPID" != $$ ]; then
-       echo "$0: Invalid lock file (${LOCKFILE}) - not owned by us!"
-       exit 1
+        echo "$0: Invalid lock file (${LOCKFILE}) - not owned by us!"
+        exit 1
     fi
+    rm -f $LOCKFILE
 }
 
 
@@ -93,10 +94,10 @@ case $cmd in
      ;;
    *)
      if test $# -lt 3; then
-       echo "usage: mtx-changer ctl-device command slot archive-device drive"
-       echo "  Insufficient number of arguments arguments given."
-       echo "  Mimimum usage is first three arguments ..."
-       exit 1
+        echo "usage: mtx-changer ctl-device command slot archive-device drive"
+        echo "  Insufficient number of arguments arguments given."
+        echo "  Mimimum usage is first three arguments ..."
+        exit 1
      fi
      ;;
 esac
@@ -110,11 +111,11 @@ case $cmd in
 # enable the following line if you need to eject the cartridge
       mt -f $device offline
       if test x$slot = x; then
-        ${MTX} -f $ctl unload
-        rtn=$?
+         ${MTX} -f $ctl unload
+         rtn=$?
       else
-        ${MTX} -f $ctl unload $slot $drive
-        rtn=$?
+         ${MTX} -f $ctl unload $slot $drive
+         rtn=$?
       fi
       ;;