HEX

Warning: set_time_limit() [function.set-time-limit]: Cannot set time limit - prohibited by configuration in /home/u547966/brikov.ru/www/wp-content/plugins/admin-menu-editor/menu-editor.php on line 745
Server: Apache
System: Linux 4.19.0-0.bpo.9-amd64 x86_64 at red40
User: u547966 (5490)
PHP: 5.3.29-mh2
Disabled: syslog, dl, popen, proc_open, proc_nice, proc_get_status, proc_close, proc_terminate, posix_mkfifo, chown, chgrp, accelerator_reset, opcache_reset, accelerator_get_status, opcache_get_status, pcntl_alarm, pcntl_fork, pcntl_waitpid, pcntl_wait, pcntl_wifexited, pcntl_wifstopped, pcntl_wifsignaled, pcntl_wifcontinued, pcntl_wexitstatus, pcntl_wtermsig, pcntl_wstopsig, pcntl_signal, pcntl_signal_dispatch, pcntl_get_last_error, pcntl_strerror, pcntl_sigprocmask, pcntl_sigwaitinfo, pcntl_sigtimedwait, pcntl_exec, pcntl_getpriority, pcntl_setpriority
Upload Files
File: //usr/share/doc/bacula-common/examples/autochangers/chio-changer
#!/bin/sh
#
# Bacula interface to autoloader
#
#  By Pascal Pederiva <freebsd@paped.com>
#
#  Known to work on FreeBSD 5.2 with a TZ875 changer.
#
#  This script mimics mtx-changer with the following differences
# - it automatically stows the cartridge to the slot it came from when
#   unloading.
# - a load will automatically unload the drive if there is a
#   different cartridge loaded.
# - it uses chio instead of mtx (which is
#   available as a package) 
#
#  If you set in your Device resource
#
#  Changer Command = "path-to-this-script/chio-changer %c %o %S %a"
#    you will have the following input to this script:
#
#  chio-changer "changer-device" "command" "slot" "archive-device"
#
#  for example:
#
#  chio-changer /dev/sg0 load 1 /dev/nst0 (on a Linux system)
#
#  If you need to to an offline, refer to the drive as $4
#    e.g.   mt -f $4 offline
#
#  Many changers need an offline after the unload. Also many
#   changers need a sleep 60 after the chio load.
#
#  N.B. If you change the script, take care to return either 
#   the chio exit code or a 0. If the script exits with a non-zero
#   exit code, Bacula will assume the request failed.
#
# Examples:
# chio-changer load 1                      ; load slot 1 into drive 0 (and unload old cartridge if necessary)
# chio-changer unload N                    ; unload drive into source slot (slot number is ignored)
# chio-changer loaded N                    ; Return loaded slot #
# chio-changer /dev/ch0 loaded N /dev/nsa0 ; has the same effect


#echo `date` "chio:  $*" >>/tmp/changer

# If the first parameter is not a device, assume it is a command
# and you want to use the default changer

if [ -c $1 ]; then
   CHANGER=$1
   shift
else
   CHANGER=/dev/ch0
fi

COMMAND=$1
ELEMENT=$2
DRIVE=$3

MTX=chio

##############################################################################

case "$COMMAND" in 
   unload)

# enable the following line if you need to eject the cartridge
#     mt -f $DRIVE offline
      SOURCE=`${MTX} status -S | grep drive | grep FULL | cut -d: -f 3 | tr -d '<>a-z '`
      if [ ! -z "$SOURCE" ]; then
        echo -n "Unloading Data Transfer Element into Storage Element $ELEMENT..."
        ${MTX} -f $CHANGER move drive 0 slot $SOURCE
        rtn=$?
        echo "done"
        else
        echo "Storage Element $ELEMENT is Already Full"
      fi
      exit $rtn
      ;;

   load)
      if [ -z "$ELEMENT" ]; then
         echo "ERROR: load <element> reguired"
         return 1
      fi
      TARGET=$ELEMENT
      if [ $TARGET -le 0 ]; then
         TARGET=1
      fi
      TARGET=`expr $TARGET - 1`

      SOURCE=`${MTX} status -S | grep drive | grep FULL | cut -d: -f 3 | tr -d '<>a-z '`
      if [ ! -z "$SOURCE" ]; then
        if [ "$SOURCE" != "$TARGET" ]; then
           # Only unload if there is something different in the drive
           ${MTX} -f $CHANGER move drive 0 slot $SOURCE
        fi
      fi

      if [ "$SOURCE" != "$TARGET" ]; then
        ${MTX} -f $CHANGER move slot $TARGET drive 0
        rtn=$? 
      fi
      exit $rtn
      ;;

   list) 
      ${MTX} -f $CHANGER status slot | grep "FULL" | awk '{print $2+1":"}'
      ;;

   loaded)
      SOURCE=`${MTX} status -S | grep drive | grep FULL | cut -d: -f 3 | tr -d '<>a-z '`
      rtn=$?
      if [ -z "$SOURCE" ]; then
         SOURCE=-1
      fi
      echo `expr 1 + ${SOURCE}`
      exit $rtn
      ;;

   slots)
      ${MTX} -f $CHANGER status slot  | wc -l
      ;;
esac