#
#
-# Copyright (C) 2000-2015 Kern Sibbald
+# Copyright (C) 2000-2016 Kern Sibbald
# License: BSD 2-Clause; see file LICENSE-FOSS
#
@MCOMMON@
#
# Bacula(R) - The Network Backup Solution
#
-# Copyright (C) 2000-2015 Kern Sibbald
-# Copyright (C) 2000-2014 Free Software Foundation Europe e.V.
+# Copyright (C) 2000-2016 Kern Sibbald
#
# The original author of Bacula is Kern Sibbald, with contributions
# from many others, a complete list can be found in the file AUTHORS.
# Bacula(R) is a registered trademark of Kern Sibbald.
#
# bacula-ctl-dir This shell script takes care of starting and stopping
-# the bacula Director daemon
+# the bacula Director daemon
#
# This is pretty much watered down version of the RedHat script
# that works on Solaris as well as Linux, but it won't work everywhere.
DIR_USER=@dir_user@
DIR_GROUP=@dir_group@
Bacula="@BACULA@"
-PIDOF=@PIDOF@
+PIDOF=@PIDOF@
# A function to stop a program.
killproc() {
# Kill it.
if [ "$pid" != "" ] ; then
if [ "$notset" = "1" ] ; then
- if ${PS} -p "$pid">/dev/null 2>&1; then
- # TERM first, then KILL if not dead
- kill -TERM $pid 2>/dev/null
- sleep 1
- if ${PS} -p "$pid" >/dev/null 2>&1 ; then
- sleep 1
- if ${PS} -p "$pid" >/dev/null 2>&1 ; then
- sleep 3
- if ${PS} -p "$pid" >/dev/null 2>&1 ; then
- kill -KILL $pid 2>/dev/null
- fi
- fi
- fi
- fi
- ${PS} -p "$pid" >/dev/null 2>&1
- RC=$?
- [ $RC -eq 0 ] && failure "$base shutdown" || success "$base shutdown"
+ if ${PS} -p "$pid">/dev/null 2>&1; then
+ # TERM first, then KILL if not dead
+ kill -TERM $pid 2>/dev/null
+ sleep 1
+ if ${PS} -p "$pid" >/dev/null 2>&1 ; then
+ sleep 1
+ if ${PS} -p "$pid" >/dev/null 2>&1 ; then
+ sleep 3
+ if ${PS} -p "$pid" >/dev/null 2>&1 ; then
+ kill -KILL $pid 2>/dev/null
+ fi
+ fi
+ fi
+ fi
+ ${PS} -p "$pid" >/dev/null 2>&1
+ RC=$?
+ [ $RC -eq 0 ] && failure "$base shutdown" || success "$base shutdown"
# RC=$((! $RC))
# use specified level only
else
- if ${PS} -p "$pid" >/dev/null 2>&1; then
- kill $killlevel $pid 2>/dev/null
- RC=$?
- [ $RC -eq 0 ] && success "$base $killlevel" || failure "$base $killlevel"
- fi
+ if ${PS} -p "$pid" >/dev/null 2>&1; then
+ kill $killlevel $pid 2>/dev/null
+ RC=$?
+ [ $RC -eq 0 ] && success "$base $killlevel" || failure "$base $killlevel"
+ fi
fi
else
failure "$base shutdown"
if [ -f ${PIDDIR}/$base.$2.pid ] ; then
pid=`head -n 1 ${PIDDIR}/$base.$2.pid`
if [ "$pid" != "" ] ; then
- echo $pid
- return 0
+ echo $pid
+ return 0
fi
fi
return 0
else
pid=`${PSCMD} | ${AWK} 'BEGIN { prog=ARGV[1]; ARGC=1 }
- { if ((prog == $2) || (("(" prog ")") == $2) ||
- (("[" prog "]") == $2) ||
- ((prog ":") == $2)) { print $1 ; exit 0 } }' $1`
+ { if ((prog == $2) || (("(" prog ")") == $2) ||
+ (("[" prog "]") == $2) ||
+ ((prog ":") == $2)) { print $1 ; exit 0 } }' $1`
if [ "$pid" != "" ] ; then
- echo "$base (pid $pid) is running..."
- return 0
+ echo "$base (pid $pid) is running..."
+ return 0
fi
fi
if [ -f ${PIDDIR}/$base.$2.pid ] ; then
pid=`head -n 1 ${PIDDIR}/$base.$2.pid`
if [ "$pid" != "" ] ; then
- echo "$base dead but pid file exists"
- return 1
+ echo "$base dead but pid file exists"
+ return 1
fi
fi
# See if the subsys lock exists
case "$1" in
start)
[ -x ${BACDIRBIN}/bacula-dir ] && {
- echo "Starting the $Bacula Director daemon"
- OPTIONS=''
- if [ "${DIR_USER}" != '' ]; then
- OPTIONS="${OPTIONS} -u ${DIR_USER}"
- fi
+ echo "Starting the $Bacula Director daemon"
+ OPTIONS=''
+ if [ "${DIR_USER}" != '' ]; then
+ OPTIONS="${OPTIONS} -u ${DIR_USER}"
+ fi
- if [ "${DIR_GROUP}" != '' ]; then
- OPTIONS="${OPTIONS} -g ${DIR_GROUP}"
- fi
+ if [ "${DIR_GROUP}" != '' ]; then
+ OPTIONS="${OPTIONS} -g ${DIR_GROUP}"
+ fi
- if [ "x${VALGRIND_DIR}" = "x1" ]; then
- valgrind --leak-check=full ${BACDIRBIN}/bacula-dir $2 $3 ${OPTIONS} -v -c ${BACDIRCFG}/bacula-dir.conf
- else
- ${BACDIRBIN}/bacula-dir $2 $3 ${OPTIONS} -v -c ${BACDIRCFG}/bacula-dir.conf
- fi
- sleep 1
+ if [ "x${VALGRIND_DIR}" = "x1" ]; then
+ valgrind --leak-check=full ${BACDIRBIN}/bacula-dir $2 $3 ${OPTIONS} -v -c ${BACDIRCFG}/bacula-dir.conf
+ else
+ ${BACDIRBIN}/bacula-dir $2 $3 ${OPTIONS} -v -c ${BACDIRCFG}/bacula-dir.conf
+ fi
+ sleep 1
}
;;
stop)
[ -x ${BACDIRBIN}/bacula-dir ] && {
- echo "Stopping the $Bacula Director daemon"
- killproc ${BACDIRBIN}/bacula-dir ${DIR_PORT} $2
+ echo "Stopping the $Bacula Director daemon"
+ killproc ${BACDIRBIN}/bacula-dir ${DIR_PORT} $2
}
;;
#
# Bacula(R) - The Network Backup Solution
#
-# Copyright (C) 2000-2015 Kern Sibbald
-# Copyright (C) 2000-2014 Free Software Foundation Europe e.V.
+# Copyright (C) 2000-2016 Kern Sibbald
#
# The original author of Bacula is Kern Sibbald, with contributions
# from many others, a complete list can be found in the file AUTHORS.
# Bacula(R) is a registered trademark of Kern Sibbald.
#
# bacula-ctl-fd This shell script takes care of starting and stopping
-# the bacula File daemon.
+# the bacula File daemon.
#
# This is pretty much watered down version of the RedHat script
# that works on Solaris as well as Linux, but it won't work everywhere.
FD_USER=@fd_user@
FD_GROUP=@fd_group@
Bacula="@BACULA@"
-PIDOF=@PIDOF@
+PIDOF=@PIDOF@
# A function to stop a program.
killproc() {
# Kill it.
if [ "$pid" != "" ] ; then
if [ "$notset" = "1" ] ; then
- if ${PS} -p "$pid">/dev/null 2>&1; then
- # TERM first, then KILL if not dead
- kill -TERM $pid 2>/dev/null
- sleep 1
- if ${PS} -p "$pid" >/dev/null 2>&1 ; then
- sleep 1
- if ${PS} -p "$pid" >/dev/null 2>&1 ; then
- sleep 3
- if ${PS} -p "$pid" >/dev/null 2>&1 ; then
- kill -KILL $pid 2>/dev/null
- fi
- fi
- fi
- fi
- ${PS} -p "$pid" >/dev/null 2>&1
- RC=$?
- [ $RC -eq 0 ] && failure "$base shutdown" || success "$base shutdown"
+ if ${PS} -p "$pid">/dev/null 2>&1; then
+ # TERM first, then KILL if not dead
+ kill -TERM $pid 2>/dev/null
+ sleep 1
+ if ${PS} -p "$pid" >/dev/null 2>&1 ; then
+ sleep 1
+ if ${PS} -p "$pid" >/dev/null 2>&1 ; then
+ sleep 3
+ if ${PS} -p "$pid" >/dev/null 2>&1 ; then
+ kill -KILL $pid 2>/dev/null
+ fi
+ fi
+ fi
+ fi
+ ${PS} -p "$pid" >/dev/null 2>&1
+ RC=$?
+ [ $RC -eq 0 ] && failure "$base shutdown" || success "$base shutdown"
# RC=$((! $RC))
# use specified level only
else
- if ${PS} -p "$pid" >/dev/null 2>&1; then
- kill $killlevel $pid 2>/dev/null
- RC=$?
- [ $RC -eq 0 ] && success "$base $killlevel" || failure "$base $killlevel"
- fi
+ if ${PS} -p "$pid" >/dev/null 2>&1; then
+ kill $killlevel $pid 2>/dev/null
+ RC=$?
+ [ $RC -eq 0 ] && success "$base $killlevel" || failure "$base $killlevel"
+ fi
fi
else
failure "$base shutdown"
if [ -f ${PIDDIR}/$base.$2.pid ] ; then
pid=`head -n 1 ${PIDDIR}/$base.$2.pid`
if [ "$pid" != "" ] ; then
- echo $pid
- return 0
+ echo $pid
+ return 0
fi
fi
return 0
else
pid=`${PSCMD} | ${AWK} 'BEGIN { prog=ARGV[1]; ARGC=1 }
- { if ((prog == $2) || (("(" prog ")") == $2) ||
- (("[" prog "]") == $2) ||
- ((prog ":") == $2)) { print $1 ; exit 0 } }' $1`
+ { if ((prog == $2) || (("(" prog ")") == $2) ||
+ (("[" prog "]") == $2) ||
+ ((prog ":") == $2)) { print $1 ; exit 0 } }' $1`
if [ "$pid" != "" ] ; then
- echo "$base (pid $pid) is running..."
- return 0
+ echo "$base (pid $pid) is running..."
+ return 0
fi
fi
if [ -f ${PIDDIR}/$base.$2.pid ] ; then
pid=`head -n 1 ${PIDDIR}/$base.$2.pid`
if [ "$pid" != "" ] ; then
- echo "$base dead but pid file exists"
- return 1
+ echo "$base dead but pid file exists"
+ return 1
fi
fi
# See if the subsys lock exists
case "$1" in
start)
[ -x ${BACFDBIN}/bacula-fd ] && {
- echo "Starting the $Bacula File daemon"
- OPTIONS=''
- if [ "${FD_USER}" != '' ]; then
- OPTIONS="${OPTIONS} -u ${FD_USER}"
- fi
+ echo "Starting the $Bacula File daemon"
+ OPTIONS=''
+ if [ "${FD_USER}" != '' ]; then
+ OPTIONS="${OPTIONS} -u ${FD_USER}"
+ fi
- if [ "${FD_GROUP}" != '' ]; then
- OPTIONS="${OPTIONS} -g ${FD_GROUP}"
- fi
+ if [ "${FD_GROUP}" != '' ]; then
+ OPTIONS="${OPTIONS} -g ${FD_GROUP}"
+ fi
- if [ "x${VALGRIND_FD}" = "x1" ]; then
- valgrind --leak-check=full ${BACFDBIN}/bacula-fd $2 $3 ${OPTIONS} -v -c ${BACFDCFG}/bacula-fd.conf
- else
- ${BACFDBIN}/bacula-fd $2 $3 ${OPTIONS} -v -c ${BACFDCFG}/bacula-fd.conf
- fi
+ if [ "x${VALGRIND_FD}" = "x1" ]; then
+ valgrind --leak-check=full ${BACFDBIN}/bacula-fd $2 $3 ${OPTIONS} -v -c ${BACFDCFG}/bacula-fd.conf
+ else
+ ${BACFDBIN}/bacula-fd $2 $3 ${OPTIONS} -v -c ${BACFDCFG}/bacula-fd.conf
+ fi
}
;;
stop)
# Stop the FD first so that SD will fail jobs and update catalog
[ -x ${BACFDBIN}/bacula-fd ] && {
- echo "Stopping the $Bacula File daemon"
- killproc ${BACFDBIN}/bacula-fd ${FD_PORT} $2
+ echo "Stopping the $Bacula File daemon"
+ killproc ${BACFDBIN}/bacula-fd ${FD_PORT} $2
}
;;
#
# Bacula(R) - The Network Backup Solution
#
-# Copyright (C) 2000-2015 Kern Sibbald
-# Copyright (C) 2000-2014 Free Software Foundation Europe e.V.
+# Copyright (C) 2000-2016 Kern Sibbald
#
# The original author of Bacula is Kern Sibbald, with contributions
# from many others, a complete list can be found in the file AUTHORS.
# Bacula(R) is a registered trademark of Kern Sibbald.
#
# bacula-ctl-sd This shell script takes care of starting and stopping
-# the bacula Storage daemon
+# the bacula Storage daemon
#
# This is pretty much watered down version of the RedHat script
# that works on Solaris as well as Linux, but it won't work everywhere.
SD_USER=@sd_user@
SD_GROUP=@sd_group@
Bacula="@BACULA@"
-PIDOF=@PIDOF@
+PIDOF=@PIDOF@
# A function to stop a program.
killproc() {
# Kill it.
if [ "$pid" != "" ] ; then
if [ "$notset" = "1" ] ; then
- if ${PS} -p "$pid">/dev/null 2>&1; then
- # TERM first, then KILL if not dead
- kill -TERM $pid 2>/dev/null
- sleep 1
- if ${PS} -p "$pid" >/dev/null 2>&1 ; then
- sleep 1
- if ${PS} -p "$pid" >/dev/null 2>&1 ; then
- sleep 3
- if ${PS} -p "$pid" >/dev/null 2>&1 ; then
- kill -KILL $pid 2>/dev/null
- fi
- fi
- fi
- fi
- ${PS} -p "$pid" >/dev/null 2>&1
- RC=$?
- [ $RC -eq 0 ] && failure "$base shutdown" || success "$base shutdown"
+ if ${PS} -p "$pid">/dev/null 2>&1; then
+ # TERM first, then KILL if not dead
+ kill -TERM $pid 2>/dev/null
+ sleep 1
+ if ${PS} -p "$pid" >/dev/null 2>&1 ; then
+ sleep 1
+ if ${PS} -p "$pid" >/dev/null 2>&1 ; then
+ sleep 3
+ if ${PS} -p "$pid" >/dev/null 2>&1 ; then
+ kill -KILL $pid 2>/dev/null
+ fi
+ fi
+ fi
+ fi
+ ${PS} -p "$pid" >/dev/null 2>&1
+ RC=$?
+ [ $RC -eq 0 ] && failure "$base shutdown" || success "$base shutdown"
# RC=$((! $RC))
# use specified level only
else
- if ${PS} -p "$pid" >/dev/null 2>&1; then
- kill $killlevel $pid 2>/dev/null
- RC=$?
- [ $RC -eq 0 ] && success "$base $killlevel" || failure "$base $killlevel"
- fi
+ if ${PS} -p "$pid" >/dev/null 2>&1; then
+ kill $killlevel $pid 2>/dev/null
+ RC=$?
+ [ $RC -eq 0 ] && success "$base $killlevel" || failure "$base $killlevel"
+ fi
fi
else
failure "$base shutdown"
if [ -f ${PIDDIR}/$base.$2.pid ] ; then
pid=`head -n 1 ${PIDDIR}/$base.$2.pid`
if [ "$pid" != "" ] ; then
- echo $pid
- return 0
+ echo $pid
+ return 0
fi
fi
return 0
else
pid=`${PSCMD} | ${AWK} 'BEGIN { prog=ARGV[1]; ARGC=1 }
- { if ((prog == $2) || (("(" prog ")") == $2) ||
- (("[" prog "]") == $2) ||
- ((prog ":") == $2)) { print $1 ; exit 0 } }' $1`
+ { if ((prog == $2) || (("(" prog ")") == $2) ||
+ (("[" prog "]") == $2) ||
+ ((prog ":") == $2)) { print $1 ; exit 0 } }' $1`
if [ "$pid" != "" ] ; then
- echo "$base (pid $pid) is running..."
- return 0
+ echo "$base (pid $pid) is running..."
+ return 0
fi
fi
if [ -f ${PIDDIR}/$base.$2.pid ] ; then
pid=`head -n 1 ${PIDDIR}/$base.$2.pid`
if [ "$pid" != "" ] ; then
- echo "$base dead but pid file exists"
- return 1
+ echo "$base dead but pid file exists"
+ return 1
fi
fi
# See if the subsys lock exists
case "$1" in
start)
[ -x ${BACSDBIN}/bacula-sd ] && {
- echo "Starting the $Bacula Storage daemon"
- OPTIONS=''
- if [ "${SD_USER}" != '' ]; then
- OPTIONS="${OPTIONS} -u ${SD_USER}"
- fi
+ echo "Starting the $Bacula Storage daemon"
+ OPTIONS=''
+ if [ "${SD_USER}" != '' ]; then
+ OPTIONS="${OPTIONS} -u ${SD_USER}"
+ fi
- if [ "${SD_GROUP}" != '' ]; then
- OPTIONS="${OPTIONS} -g ${SD_GROUP}"
- fi
+ if [ "${SD_GROUP}" != '' ]; then
+ OPTIONS="${OPTIONS} -g ${SD_GROUP}"
+ fi
- if [ "x${VALGRIND_SD}" = "x1" ]; then
- valgrind --leak-check=full ${BACSDBIN}/bacula-sd $2 $3 ${OPTIONS} -v -c ${BACSDCFG}/bacula-sd.conf
- else
- ${BACSDBIN}/bacula-sd $2 $3 ${OPTIONS} -v -c ${BACSDCFG}/bacula-sd.conf
- fi
+ if [ "x${VALGRIND_SD}" = "x1" ]; then
+ valgrind --leak-check=full ${BACSDBIN}/bacula-sd $2 $3 ${OPTIONS} -v -c ${BACSDCFG}/bacula-sd.conf
+ else
+ ${BACSDBIN}/bacula-sd $2 $3 ${OPTIONS} -v -c ${BACSDCFG}/bacula-sd.conf
+ fi
}
;;
stop)
[ -x ${BACSDBIN}/bacula-sd ] && {
- echo "Stopping the $Bacula Storage daemon"
- killproc ${BACSDBIN}/bacula-sd ${SD_PORT} $2
+ echo "Stopping the $Bacula Storage daemon"
+ killproc ${BACSDBIN}/bacula-sd ${SD_PORT} $2
}
;;
#
# Bacula(R) - The Network Backup Solution
#
-# Copyright (C) 2000-2015 Kern Sibbald
-# Copyright (C) 2000-2014 Free Software Foundation Europe e.V.
+# Copyright (C) 2000-2016 Kern Sibbald
#
# The original author of Bacula is Kern Sibbald, with contributions
# from many others, a complete list can be found in the file AUTHORS.
# Bacula(R) is a registered trademark of Kern Sibbald.
#
# bacula This shell script takes care of starting and stopping
-# the bacula daemons.
+# the bacula daemons.
#
# This is pretty much watered down version of the RedHat script
# that works on Solaris as well as Linux, but it won't work everywhere.
#
# Bacula(R) - The Network Backup Solution
#
-# Copyright (C) 2000-2015 Kern Sibbald
-# Copyright (C) 2000-2014 Free Software Foundation Europe e.V.
+# Copyright (C) 2000-2016 Kern Sibbald
#
# The original author of Bacula is Kern Sibbald, with contributions
# from many others, a complete list can be found in the file AUTHORS.
#
# Bacula(R) - The Network Backup Solution
#
-# Copyright (C) 2000-2015 Kern Sibbald
+# Copyright (C) 2000-2016 Kern Sibbald
#
# The original author of Bacula is Kern Sibbald, with contributions
# from many others, a complete list can be found in the file AUTHORS.
#
# Bacula(R) - The Network Backup Solution
#
-# Copyright (C) 2000-2015 Kern Sibbald
+# Copyright (C) 2000-2016 Kern Sibbald
# Copyright (C) 2000-2014 Free Software Foundation Europe e.V.
#
# The original author of Bacula is Kern Sibbald, with contributions
#! /bin/sh
#
-# Copyright (C) 2000-2015 Kern Sibbald
+# Copyright (C) 2000-2016 Kern Sibbald
# License: BSD 2-Clause; see file LICENSE-FOSS
#
# bacula This shell script takes care of starting and stopping
#
# Bacula(R) - The Network Backup Solution
#
-# Copyright (C) 2000-2015 Kern Sibbald
-# Copyright (C) 2000-2014 Free Software Foundation Europe e.V.
+# Copyright (C) 2000-2016 Kern Sibbald
#
# The original author of Bacula is Kern Sibbald, with contributions
# from many others, a complete list can be found in the file AUTHORS.
# included.
#
# disk-changer "changer-device" "command" "slot" "archive-device" "drive-index" "volume"
-# $1 $2 $3 $4 $5 $6
+# $1 $2 $3 $4 $5 $6
#
# By default the autochanger has 10 Volumes and 1 Drive.
#
#
# changer-device is the name of a file that overrides the default
# volumes and drives. It may have:
-# maxslot=n where n is one based (default 10)
-# maxdrive=m where m is zero based (default 1 -- i.e. 2 drives)
+# maxslot=n where n is one based (default 10)
+# maxdrive=m where m is zero based (default 1 -- i.e. 2 drives)
#
# This code can also simulate barcodes. You simply put
# a list of the slots and barcodes in the "base" directory/barcodes.
dbgfile="$wd/disk-changer.log"
debug() {
if test -f $dbgfile; then
- echo "`date +\"%Y%m%d-%H:%M:%S\"` $*" >> $dbgfile
+ echo "`date +\"%Y%m%d-%H:%M:%S\"` $*" >> $dbgfile
fi
}
if test x${TMPFILE} = x; then
TMPFILE="$wd/disk-changer.$$"
if test -f ${TMPFILE}; then
- echo "Temp file security problem on: ${TMPFILE}"
- exit 1
+ echo "Temp file security problem on: ${TMPFILE}"
+ exit 1
fi
fi
}
pCount=$1
pCountNeed=$2
if test $pCount -lt $pCountNeed; then
- echo "usage: disk-changer ctl-device command [slot archive-device drive-index]"
- echo " Insufficient number of arguments arguments given."
- if test $pCount -lt 2; then
- echo " Mimimum usage is first two arguments ..."
- else
- echo " Command expected $pCountNeed arguments"
- fi
- exit 1
+ echo "usage: disk-changer ctl-device command [slot archive-device drive-index]"
+ echo " Insufficient number of arguments arguments given."
+ if test $pCount -lt 2; then
+ echo " Mimimum usage is first two arguments ..."
+ else
+ echo " Command expected $pCountNeed arguments"
+ fi
+ exit 1
fi
}
dir=`echo "$device" | sed -e s%/$bn%%g`
if [ ! -d $dir ]; then
echo "ERROR: Autochanger directory \"$dir\" does not exist."
- echo " You must create it."
+ echo " You must create it."
exit 1
fi
}
#
case $2 in
list|listall)
- check_parm_count $# 2
- ;;
+ check_parm_count $# 2
+ ;;
slots)
- check_parm_count $# 2
- ;;
+ check_parm_count $# 2
+ ;;
transfer)
- check_parm_count $# 4
- if [ $slot -gt $maxslot ]; then
- echo "Slot ($slot) out of range (1-$maxslot)"
- debug "Error: Slot ($slot) out of range (1-$maxslot)"
- exit 1
- fi
- ;;
+ check_parm_count $# 4
+ if [ $slot -gt $maxslot ]; then
+ echo "Slot ($slot) out of range (1-$maxslot)"
+ debug "Error: Slot ($slot) out of range (1-$maxslot)"
+ exit 1
+ fi
+ ;;
*)
- check_parm_count $# 5
- if [ $drive -gt $maxdrive ]; then
- echo "Drive ($drive) out of range (0-$maxdrive)"
- debug "Error: Drive ($drive) out of range (0-$maxdrive)"
- exit 1
- fi
- if [ $slot -gt $maxslot ]; then
- echo "Slot ($slot) out of range (1-$maxslot)"
- debug "Error: Slot ($slot) out of range (1-$maxslot)"
- exit 1
- fi
- ;;
+ check_parm_count $# 5
+ if [ $drive -gt $maxdrive ]; then
+ echo "Drive ($drive) out of range (0-$maxdrive)"
+ debug "Error: Drive ($drive) out of range (0-$maxdrive)"
+ exit 1
+ fi
+ if [ $slot -gt $maxslot ]; then
+ echo "Slot ($slot) out of range (1-$maxslot)"
+ debug "Error: Slot ($slot) out of range (1-$maxslot)"
+ exit 1
+ fi
+ ;;
esac
debug "Doing disk -f $ctl unload $slot $device $drive $volume"
get_dir
if [ -f $dir/loaded${drive} ]; then
- ld=`cat $dir/loaded${drive}`
+ ld=`cat $dir/loaded${drive}`
else
- echo "Storage Element $slot is Already Full"
- debug "Unload error: $dir/loaded${drive} is already unloaded"
- exit 1
+ echo "Storage Element $slot is Already Full"
+ debug "Unload error: $dir/loaded${drive} is already unloaded"
+ exit 1
fi
if [ $slot -eq $ld ]; then
- echo "0" >$dir/loaded${drive}
- unlink $device 2>/dev/null >/dev/null
- unlink ${device}.add 2>/dev/null >/dev/null
- rm -f ${device} ${device}.add
+ echo "0" >$dir/loaded${drive}
+ unlink $device 2>/dev/null >/dev/null
+ unlink ${device}.add 2>/dev/null >/dev/null
+ rm -f ${device} ${device}.add
else
- echo "Storage Element $slot is Already Full"
- debug "Unload error: $dir/loaded${drive} slot=$ld is already unloaded"
- exit 1
+ echo "Storage Element $slot is Already Full"
+ debug "Unload error: $dir/loaded${drive} slot=$ld is already unloaded"
+ exit 1
fi
;;
i=0
# Check if slot already in a drive
while [ $i -le $maxdrive ]; do
- if [ -f $dir/loaded${i} ]; then
- ld=`cat $dir/loaded${i}`
- else
- ld=0
- fi
- if [ $ld -eq $slot ]; then
- echo "Drive ${i} Full (Storage element ${ld} loaded)"
- debug "Load error: Cannot load Slot=${ld} in drive=$drive. Already in drive=${i}"
- exit 1
- fi
- i=`expr $i + 1`
+ if [ -f $dir/loaded${i} ]; then
+ ld=`cat $dir/loaded${i}`
+ else
+ ld=0
+ fi
+ if [ $ld -eq $slot ]; then
+ echo "Drive ${i} Full (Storage element ${ld} loaded)"
+ debug "Load error: Cannot load Slot=${ld} in drive=$drive. Already in drive=${i}"
+ exit 1
+ fi
+ i=`expr $i + 1`
done
# Check if we have a Volume name
get_vol
if [ $havevol -eq 0 ]; then
- # check if slot exists
- if [ ! -f $dir/slot${slot} ] ; then
- echo "source Element Address $slot is Empty"
- debug "Load error: source Element Address $slot is Empty"
- exit 1
- fi
+ # check if slot exists
+ if [ ! -f $dir/slot${slot} ] ; then
+ echo "source Element Address $slot is Empty"
+ debug "Load error: source Element Address $slot is Empty"
+ exit 1
+ fi
fi
if [ -f $dir/loaded${drive} ]; then
- ld=`cat $dir/loaded${drive}`
+ ld=`cat $dir/loaded${drive}`
else
- ld=0
+ ld=0
fi
if [ $ld -ne 0 ]; then
- echo "Drive ${drive} Full (Storage element ${ld} loaded)"
- echo "Load error: Drive ${drive} Full (Storage element ${ld} loaded)"
- exit 1
+ echo "Drive ${drive} Full (Storage element ${ld} loaded)"
+ echo "Load error: Drive ${drive} Full (Storage element ${ld} loaded)"
+ exit 1
fi
echo "0" >$dir/loaded${drive}
unlink $device 2>/dev/null >/dev/null
unlink ${device}.add 2>/dev/null >/dev/null
rm -f ${device} ${device}.add
if [ $havevol -ne 0 ]; then
- ln -s $dir/$volume $device
- ln -s $dir/${volume}.add ${device}.add
- rtn=$?
+ ln -s $dir/$volume $device
+ ln -s $dir/${volume}.add ${device}.add
+ rtn=$?
else
- ln -s $dir/slot${slot} $device
- ln -s $dir/slot${slot}.add ${device}.add
- rtn=$?
+ ln -s $dir/slot${slot} $device
+ ln -s $dir/slot${slot}.add ${device}.add
+ rtn=$?
fi
if [ $rtn -eq 0 ]; then
- echo $slot >$dir/loaded${drive}
+ echo $slot >$dir/loaded${drive}
fi
exit $rtn
;;
debug "Doing disk -f $ctl -- to list volumes"
get_dir
if [ -f $dir/barcodes ]; then
- cat $dir/barcodes
+ cat $dir/barcodes
else
- i=1
- while [ $i -le $maxslot ]; do
- slot=$i
- volume=
- get_vol
- if [ $havevol -eq 0 ]; then
- echo "$i:"
- else
- echo "$i:$volume"
- fi
- i=`expr $i + 1`
- done
+ i=1
+ while [ $i -le $maxslot ]; do
+ slot=$i
+ volume=
+ get_vol
+ if [ $havevol -eq 0 ]; then
+ echo "$i:"
+ else
+ echo "$i:$volume"
+ fi
+ i=`expr $i + 1`
+ done
fi
exit 0
;;
debug "Doing disk -f $ctl -- to list volumes"
get_dir
if [ ! -f $dir/barcodes ]; then
- exit 0
+ exit 0
fi
# we print drive content seen by autochanger
# and we also remove loaded media from the barcode list
i=0
while [ $i -le $maxdrive ]; do
- if [ -f $dir/loaded${i} ]; then
- ld=`cat $dir/loaded${i}`
- v=`awk -F: "/^$ld:/"' { print $2 }' $dir/barcodes`
- echo "D:$i:F:$ld:$v"
- echo "^$ld:" >> $TMPFILE
- fi
- i=`expr $i + 1`
+ if [ -f $dir/loaded${i} ]; then
+ ld=`cat $dir/loaded${i}`
+ v=`awk -F: "/^$ld:/"' { print $2 }' $dir/barcodes`
+ echo "D:$i:F:$ld:$v"
+ echo "^$ld:" >> $TMPFILE
+ fi
+ i=`expr $i + 1`
done
# Empty slots are not in barcodes file
grep -v -f $TMPFILE $dir/barcodes | sort -n | \
perl -ne 'BEGIN { $cur=1 }
if (/(\d+):(.+)?/) {
- if ($cur == $1) {
- print "S:$1:F:$2\n"
- } else {
- while ($cur < $1) {
- print "S:$cur:E\n";
- $cur++;
- }
- }
- $cur++;
+ if ($cur == $1) {
+ print "S:$1:F:$2\n"
+ } else {
+ while ($cur < $1) {
+ print "S:$cur:E\n";
+ $cur++;
+ }
+ }
+ $cur++;
}
END { while ($cur < '"$maxslot"') { print "S:$cur:E\n"; $cur++; } } '
make_temp_file
slotdest=$device
if [ -f $dir/slot{$slotdest} ]; then
- echo "destination Element Address $slot is Full"
- exit 1
+ echo "destination Element Address $slot is Full"
+ exit 1
fi
if [ ! -f $dir/slot${slot} ] ; then
- echo "source Element Address $slot is Empty"
- exit 1
+ echo "source Element Address $slot is Empty"
+ exit 1
fi
echo "Transfering $slot to $slotdest"
mv $dir/slot${slot}.add $dir/slot{$slotdest}.add
if [ -f $dir/barcodes ]; then
- sed "s/^$slot:/$slotdest:/" > $TMPFILE
- sort -n $TMPFILE > $dir/barcodes
+ sed "s/^$slot:/$slotdest:/" > $TMPFILE
+ sort -n $TMPFILE > $dir/barcodes
fi
exit 0
;;
debug "Doing disk -f $ctl $drive -- to find what is loaded"
get_dir
if [ -f $dir/loaded${drive} ]; then
- a=`cat $dir/loaded${drive}`
+ a=`cat $dir/loaded${drive}`
else
- a="0"
+ a="0"
fi
debug "Loaded: drive=$drive is $a"
echo $a
#
# Bacula(R) - The Network Backup Solution
#
-# Copyright (C) 2000-2015 Kern Sibbald
-# Copyright (C) 2000-2014 Free Software Foundation Europe e.V.
+# Copyright (C) 2000-2016 Kern Sibbald
#
# The original author of Bacula is Kern Sibbald, with contributions
# from many others, a complete list can be found in the file AUTHORS.
# operations used by Bacula:
#
# free (no arguments)
-# Scan the device and report the available space. It returns:
-# Prints on the first output line the free space available in bytes.
-# If an error occurs, prints a negative number (-errno), followed,
-# on the second line, by an error message.
+# Scan the device and report the available space. It returns:
+# Prints on the first output line the free space available in bytes.
+# If an error occurs, prints a negative number (-errno), followed,
+# on the second line, by an error message.
#
# write op filename
-# Write a part file to disk.
-# This operation needs two additional arguments.
-# The first (op) indicates to
-# 0 -- append
-# 1 -- first write to a blank disk
-# 2 -- blank or truncate a disk
+# Write a part file to disk.
+# This operation needs two additional arguments.
+# The first (op) indicates to
+# 0 -- append
+# 1 -- first write to a blank disk
+# 2 -- blank or truncate a disk
#
-# The second is the filename to write
+# The second is the filename to write
#
# operations available but not used by Bacula:
#
# test Scan the device and report the information found.
-# This operation needs no further arguments.
+# This operation needs no further arguments.
# prepare Prepare a DVD+/-RW for being used by Bacula.
-# Note: This is only useful if you already have some
-# non-Bacula data on a medium, and you want to use
-# it with Bacula. Don't run this on blank media, it
-# is useless.
+# Note: This is only useful if you already have some
+# non-Bacula data on a medium, and you want to use
+# it with Bacula. Don't run this on blank media, it
+# is useless.
#
#
# $Id$
# dvd-writepart doesn't not always need to know the free space).
#
# The following methods are implemented:
-# __init__ we need that...
-# __repr__ this seems to be a good idea to have.
-# Quite minimalistic implementation, though.
-# __str__ For casts to string. Return the current disk information
-# is_empty Returns TRUE if the disk is empty, blank... this needs more
-# work, especially concerning non-RW media and blank vs. no
-# filesystem considerations. Here, we should also look for
-# other filesystems - probably we don't want to silently
-# overwrite UDF or ext2 or anything not mentioned in fstab...
-# (NB: I don't think it is a problem)
-# free Returns the available free space.
-# write Writes one part file to disk, either starting a new file
-# system on disk, or appending to it.
-# This method should also prepare a blank disk so that a
-# certain part of the disk is used to allow detection of a
-# used disk by all / more disk drives.
-# prepare Blank the device
+# __init__ we need that...
+# __repr__ this seems to be a good idea to have.
+# Quite minimalistic implementation, though.
+# __str__ For casts to string. Return the current disk information
+# is_empty Returns TRUE if the disk is empty, blank... this needs more
+# work, especially concerning non-RW media and blank vs. no
+# filesystem considerations. Here, we should also look for
+# other filesystems - probably we don't want to silently
+# overwrite UDF or ext2 or anything not mentioned in fstab...
+# (NB: I don't think it is a problem)
+# free Returns the available free space.
+# write Writes one part file to disk, either starting a new file
+# system on disk, or appending to it.
+# This method should also prepare a blank disk so that a
+# certain part of the disk is used to allow detection of a
+# used disk by all / more disk drives.
+# prepare Blank the device
#
###############################################################################
def __init__(self, devicename):
self.growcmd += " -quiet"
if self.is4gbsupported():
- self.growcmd += " -use-the-force-luke=4gms"
+ self.growcmd += " -use-the-force-luke=4gms"
self.growparams = " -A 'Bacula Data' -input-charset=default -iso-level 3 -pad " + \
- "-p 'dvd-handler / growisofs' -sysid 'BACULADATA' -R"
+ "-p 'dvd-handler / growisofs' -sysid 'BACULADATA' -R"
return
def __str__(self):
if not self.freespace_collected:
- self.collect_freespace();
+ self.collect_freespace();
if not self.mediumtype_collected:
- self.collect_mediumtype();
+ self.collect_mediumtype();
self.me = "Class disk, initialized with device '" + self.device + "'\n"
self.me += "type = '" + self.disktype + "' mode='" + self.diskmode + "' status = '" + self.diskstatus + "'\n"
processi = popen2.Popen4("uname -s -r")
status = processi.wait()
if not os.WIFEXITED(status):
- return 1
+ return 1
if os.WEXITSTATUS(status) != 0:
- return 1
+ return 1
strres = processi.fromchild.readline()[0:-1]
version = re.search(r"Linux (\d+)\.(\d+)\.(\d+)", strres)
if not version: # Non-Linux: allow
- return 1
+ return 1
if (int(version.group(1)) > 2) or (int(version.group(2)) > 6) or ((int(version.group(1)) == 2) and (int(version.group(2)) == 6) and (int(version.group(3)) >= 8)):
- return 1
+ return 1
else:
- return 0
+ return 0
def collect_freespace(self): # Collects current free space
self.cmd = self.growcmd + " -F " + self.device
processi = popen2.Popen4(self.cmd)
status = processi.wait()
if not os.WIFEXITED(status):
- raise DVDError(0, "growisofs process did not exit correctly.")
+ raise DVDError(0, "growisofs process did not exit correctly.")
result = processi.fromchild.read()
if os.WEXITSTATUS(status) != 0:
- if (os.WEXITSTATUS(status) & 0x7F) == errno.ENOSPC:
- # Kludge to force dvd-handler to return a free space of 0
- self.next_session = 1
- self.capacity = 1
- self.freespace_collected = 1
- return
- else:
- raise DVDError(os.WEXITSTATUS(status), "growisofs returned with an error " + result + ". Please check your are using a patched version of dvd+rw-tools.")
+ if (os.WEXITSTATUS(status) & 0x7F) == errno.ENOSPC:
+ # Kludge to force dvd-handler to return a free space of 0
+ self.next_session = 1
+ self.capacity = 1
+ self.freespace_collected = 1
+ return
+ else:
+ raise DVDError(os.WEXITSTATUS(status), "growisofs returned with an error " + result + ". Please check your are using a patched version of dvd+rw-tools.")
next_sess = re.search(r"\snext_session=(\d+)\s", result, re.MULTILINE)
capa = re.search(r"\scapacity=(\d+)\s", result, re.MULTILINE)
if next_sess and capa:
- self.next_session = long(next_sess.group(1))
- self.capacity = long(capa.group(1))
-
- # testing cheat (emulate 4GB boundary at 100MB)
- #if self.next_session > 100000000:
- # self.capacity = self.next_session
+ self.next_session = long(next_sess.group(1))
+ self.capacity = long(capa.group(1))
+
+ # testing cheat (emulate 4GB boundary at 100MB)
+ #if self.next_session > 100000000:
+ # self.capacity = self.next_session
else:
- raise DVDError(0, "Cannot get next_session and capacity from growisofs.\nReturned: " + result)
+ raise DVDError(0, "Cannot get next_session and capacity from growisofs.\nReturned: " + result)
self.freespace_collected = 1
return
processi = popen2.Popen4(cmd)
status = processi.wait()
if not os.WIFEXITED(status):
- raise DVDError(0, self.dvdrwmediainfo + " process did not exit correctly.")
+ raise DVDError(0, self.dvdrwmediainfo + " process did not exit correctly.")
if os.WEXITSTATUS(status) != 0:
- raise DVDError(0, "Cannot get media info from " + self.dvdrwmediainfo)
- return
+ raise DVDError(0, "Cannot get media info from " + self.dvdrwmediainfo)
+ return
result = processi.fromchild.read()
hardware = re.search(r"INQUIRY:\s+(.*)\n", result, re.MULTILINE)
status = re.search(r"\sDisc status:\s+(.*)\n", result, re.MULTILINE)
if hardware:
- self.hardwaredevice = hardware.group(1)
+ self.hardwaredevice = hardware.group(1)
if mediatype:
- self.disktype = mediatype.group(2)
+ self.disktype = mediatype.group(2)
else:
- raise DVDError(0, "Media type not found in " + self.dvdrwmediainfo + " output")
+ raise DVDError(0, "Media type not found in " + self.dvdrwmediainfo + " output")
if self.disktype == "DVD-RW":
- if mediamode:
- self.diskmode = mediamode.group(1)
- else:
- raise DVDError(0, "Media mode not found for DVD-RW in " + self.dvdrwmediainfo + " output")
+ if mediamode:
+ self.diskmode = mediamode.group(1)
+ else:
+ raise DVDError(0, "Media mode not found for DVD-RW in " + self.dvdrwmediainfo + " output")
if status:
- self.diskstatus = status.group(1)
+ self.diskstatus = status.group(1)
else:
- raise DVDError(0, "Disc status not found in " + self.dvdrwmediainfo + " output")
+ raise DVDError(0, "Disc status not found in " + self.dvdrwmediainfo + " output")
self.mediumtype_collected = 1
def is_empty(self):
if not self.freespace_collected:
- self.collect_freespace();
+ self.collect_freespace();
return 0 == self.next_session
def is_RW(self):
if not self.mediumtype_collected:
- self.collect_mediumtype();
+ self.collect_mediumtype();
return "DVD-RW" == self.disktype or "DVD+RW" == self.disktype or "DVD-RAM" == self.disktype
def is_plus_RW(self):
if not self.mediumtype_collected:
- self.collect_mediumtype();
+ self.collect_mediumtype();
return "DVD+RW" == self.disktype
def is_minus_RW(self):
if not self.mediumtype_collected:
- self.collect_mediumtype();
+ self.collect_mediumtype();
return "DVD-RW" == self.disktype
def is_restricted_overwrite(self):
if not self.mediumtype_collected:
- self.collect_mediumtype();
+ self.collect_mediumtype();
return self.diskmode == "Restricted Overwrite"
def is_blank(self):
if not self.mediumtype_collected:
- self.collect_mediumtype();
+ self.collect_mediumtype();
return self.diskstatus == "blank"
def free(self):
if not self.freespace_collected:
- self.collect_freespace();
+ self.collect_freespace();
fr = self.capacity-self.next_session-self.margin
if fr < 0:
- return 0
+ return 0
else:
- return fr
+ return fr
def term_handler(self, signum, frame):
print 'dvd-handler: Signal term_handler called with signal', signum
if self.pid != 0:
- print "dvd-handler: Sending SIGTERM to pid", self.pid
- os.kill(self.pid, signal.SIGTERM)
- time.sleep(10)
- print "dvd-handler: Sending SIGKILL to pid", self.pid
- os.kill(self.pid, signal.SIGKILL)
- sys.exit(1)
+ print "dvd-handler: Sending SIGTERM to pid", self.pid
+ os.kill(self.pid, signal.SIGTERM)
+ time.sleep(10)
+ print "dvd-handler: Sending SIGKILL to pid", self.pid
+ os.kill(self.pid, signal.SIGKILL)
+ sys.exit(1)
def write(self, newvol, partfile):
# Blank DVD+RW when there is no data on it
if newvol and self.is_plus_RW() and self.is_blank():
- print "DVD+RW looks brand-new, blank it to fix some DVD-writers bugs."
- self.blank()
- print "Done, now writing the part file."
+ print "DVD+RW looks brand-new, blank it to fix some DVD-writers bugs."
+ self.blank()
+ print "Done, now writing the part file."
if newvol and self.is_minus_RW() and (not self.is_restricted_overwrite()):
- print "DVD-RW is in " + self.diskmode + " mode, reformating it to Restricted Overwrite"
- self.reformat_minus_RW()
- print "Done, now writing the part file."
+ print "DVD-RW is in " + self.diskmode + " mode, reformating it to Restricted Overwrite"
+ self.reformat_minus_RW()
+ print "Done, now writing the part file."
cmd = self.growcmd + self.growparams
if newvol:
- # Ignore any existing iso9660 filesystem - used for truncate
- if newvol == 2:
- cmd += " -use-the-force-luke=tty"
- cmd += " -Z "
+ # Ignore any existing iso9660 filesystem - used for truncate
+ if newvol == 2:
+ cmd += " -use-the-force-luke=tty"
+ cmd += " -Z "
else:
- cmd += " -M "
+ cmd += " -M "
cmd += self.device + " " + str(partfile)
print "Running " + cmd
oldsig = signal.signal(signal.SIGTERM, self.term_handler)
self.pid = proc.pid
status = proc.poll()
while status == -1:
- line = proc.fromchild.readline()
- while len(line) > 0:
- print line,
- line = proc.fromchild.readline()
- time.sleep(1)
- status = proc.poll()
+ line = proc.fromchild.readline()
+ while len(line) > 0:
+ print line,
+ line = proc.fromchild.readline()
+ time.sleep(1)
+ status = proc.poll()
self.pid = 0
print
signal.signal(signal.SIGTERM, oldsig)
if not os.WIFEXITED(status):
- raise DVDError(0, cmd + " process did not exit correctly, signal/status " + str(status))
+ raise DVDError(0, cmd + " process did not exit correctly, signal/status " + str(status))
if os.WEXITSTATUS(status) != 0:
- raise DVDError(os.WEXITSTATUS(status), cmd + " exited with status " + str(os.WEXITSTATUS(status)) + ", signal/status " + str(status))
+ raise DVDError(os.WEXITSTATUS(status), cmd + " exited with status " + str(os.WEXITSTATUS(status)) + ", signal/status " + str(status))
def prepare(self):
if not self.is_RW():
- raise DVDError(0, "I won't prepare a non-rewritable medium")
+ raise DVDError(0, "I won't prepare a non-rewritable medium")
# Blank DVD+RW when there is no data on it
if self.is_plus_RW() and self.is_blank():
- print "DVD+RW looks brand-new, blank it to fix some DVD-writers bugs."
- self.blank()
- return # It has been completely blanked: Medium is ready to be used by Bacula
+ print "DVD+RW looks brand-new, blank it to fix some DVD-writers bugs."
+ self.blank()
+ return # It has been completely blanked: Medium is ready to be used by Bacula
if self.is_minus_RW() and (not self.is_restricted_overwrite()):
- print "DVD-RW is in " + self.diskmode + " mode, reformating it to Restricted Overwrite"
- self.reformat_minus_RW()
- return # Reformated: Medium is ready to be used by Bacula
+ print "DVD-RW is in " + self.diskmode + " mode, reformating it to Restricted Overwrite"
+ self.reformat_minus_RW()
+ return # Reformated: Medium is ready to be used by Bacula
# TODO: Check if /dev/fd/0 and /dev/zero exists, otherwise, run self.blank()
if not os.path.exists("/dev/fd/0") or not os.path.exists("/dev/zero"):
- print "/dev/fd/0 or /dev/zero doesn't exist, blank the medium completely."
- self.blank()
- return
+ print "/dev/fd/0 or /dev/zero doesn't exist, blank the medium completely."
+ self.blank()
+ return
cmd = self.dd + " if=/dev/zero bs=1024 count=512 | " + self.growcmd + " -Z " + self.device + "=/dev/fd/0"
print "Running " + cmd
self.pid = proc.pid
status = proc.poll()
while status == -1:
- line = proc.fromchild.readline()
- while len(line) > 0:
- print line,
- line = proc.fromchild.readline()
- time.sleep(1)
- status = proc.poll()
+ line = proc.fromchild.readline()
+ while len(line) > 0:
+ print line,
+ line = proc.fromchild.readline()
+ time.sleep(1)
+ status = proc.poll()
self.pid = 0
print
signal.signal(signal.SIGTERM, oldsig)
if os.WEXITSTATUS(status) != 0:
- raise DVDError(os.WEXITSTATUS(status), cmd + " exited with status " + str(os.WEXITSTATUS(status)) + ", signal/status " + str(status))
+ raise DVDError(os.WEXITSTATUS(status), cmd + " exited with status " + str(os.WEXITSTATUS(status)) + ", signal/status " + str(status))
def blank(self):
cmd = self.growcmd + " -Z " + self.device + "=/dev/zero"
self.pid = proc.pid
status = proc.poll()
while status == -1:
- line = proc.fromchild.readline()
- while len(line) > 0:
- print line,
- line = proc.fromchild.readline()
- time.sleep(1)
- status = proc.poll()
+ line = proc.fromchild.readline()
+ while len(line) > 0:
+ print line,
+ line = proc.fromchild.readline()
+ time.sleep(1)
+ status = proc.poll()
self.pid = 0
print
signal.signal(signal.SIGTERM, oldsig)
if os.WEXITSTATUS(status) != 0:
- raise DVDError(os.WEXITSTATUS(status), cmd + " exited with status " + str(os.WEXITSTATUS(status)) + ", signal/status " + str(status))
+ raise DVDError(os.WEXITSTATUS(status), cmd + " exited with status " + str(os.WEXITSTATUS(status)) + ", signal/status " + str(status))
def reformat_minus_RW(self):
cmd = self.dvdrwformat + " -force " + self.device
self.pid = proc.pid
status = proc.poll()
while status == -1:
- line = proc.fromchild.readline()
- while len(line) > 0:
- print line,
- line = proc.fromchild.readline()
- time.sleep(1)
- status = proc.poll()
+ line = proc.fromchild.readline()
+ while len(line) > 0:
+ print line,
+ line = proc.fromchild.readline()
+ time.sleep(1)
+ status = proc.poll()
self.pid = 0
print
signal.signal(signal.SIGTERM, oldsig)
if os.WEXITSTATUS(status) != 0:
- raise DVDError(os.WEXITSTATUS(status), cmd + " exited with status " + str(os.WEXITSTATUS(status)) + ", signal/status " + str(status))
+ raise DVDError(os.WEXITSTATUS(status), cmd + " exited with status " + str(os.WEXITSTATUS(status)) + ", signal/status " + str(status))
# class disk ends here.
self.errno = errno
self.value = value
if self.value[-1] == '\n':
- self.value = self.value[0:-1]
+ self.value = self.value[0:-1]
def __str__(self):
return str(self.value) + " || errno = " + str(self.errno) + " (" + os.strerror(self.errno & 0x7F) + ")"
where DEVICE is a device name like /dev/sr0 or /dev/dvd.
Operations:
-test Scan the device and report the information found.
- This operation needs no further arguments.
-free Scan the device and report the available space.
-write Write a part file to disk.
- This operation needs two additional arguments.
- The first indicates to append (0), restart the
- disk (1) or restart existing disk (2). The second
- is the file to write.
+test Scan the device and report the information found.
+ This operation needs no further arguments.
+free Scan the device and report the available space.
+write Write a part file to disk.
+ This operation needs two additional arguments.
+ The first indicates to append (0), restart the
+ disk (1) or restart existing disk (2). The second
+ is the file to write.
prepare Prepare a DVD+/-RW for being used by Bacula.
- Note: This is only useful if you already have some
- non-Bacula data on a medium, and you want to use
- it with Bacula. Don't run this on blank media, it
- is useless.
+ Note: This is only useful if you already have some
+ non-Bacula data on a medium, and you want to use
+ it with Bacula. Don't run this on blank media, it
+ is useless.
"""
sys.exit(1)
if "free" == sys.argv[2]:
if len(sys.argv) == 3:
try:
- free = dvd.free()
+ free = dvd.free()
except DVDError, e:
- if e.errno != 0:
- print -e.errno
- else:
- print errno.EPIPE
- print str(e)
+ if e.errno != 0:
+ print -e.errno
+ else:
+ print errno.EPIPE
+ print str(e)
else:
- print free
- print "No Error reported."
+ print free
+ print "No Error reported."
else:
print "Wrong number of arguments for free operation. Wanted 3 got", len(sys.argv)
usage()
elif "prepare" == sys.argv[2]:
if len(sys.argv) == 3:
try:
- dvd.prepare()
+ dvd.prepare()
except DVDError, e:
- print "Error while preparing medium: ", str(e)
- if e.errno != 0:
- sys.exit(e.errno & 0x7F)
- else:
- sys.exit(errno.EPIPE)
+ print "Error while preparing medium: ", str(e)
+ if e.errno != 0:
+ sys.exit(e.errno & 0x7F)
+ else:
+ sys.exit(errno.EPIPE)
else:
- print "Medium prepared successfully."
+ print "Medium prepared successfully."
else:
print "Wrong number of arguments for prepare operation. Wanted 3 got", len(sys.argv)
usage()
elif "write" == sys.argv[2]:
if len(sys.argv) == 5:
try:
- dvd.write(long(sys.argv[3]), sys.argv[4])
+ dvd.write(long(sys.argv[3]), sys.argv[4])
except DVDError, e:
- print "Error while writing part file: ", str(e)
- if e.errno != 0:
- sys.exit(e.errno & 0x7F)
- else:
- sys.exit(errno.EPIPE)
+ print "Error while writing part file: ", str(e)
+ if e.errno != 0:
+ sys.exit(e.errno & 0x7F)
+ else:
+ sys.exit(errno.EPIPE)
else:
- print "Part file " + sys.argv[4] + " successfully written to disk."
+ print "Part file " + sys.argv[4] + " successfully written to disk."
else:
print "Wrong number of arguments for write operation. Wanted 5 got", len(sys.argv)
usage()
#
# Bacula(R) - The Network Backup Solution
#
-# Copyright (C) 2000-2015 Kern Sibbald
-# Copyright (C) 2000-2014 Free Software Foundation Europe e.V.
+# Copyright (C) 2000-2016 Kern Sibbald
#
# The original author of Bacula is Kern Sibbald, with contributions
# from many others, a complete list can be found in the file AUTHORS.
# operations used by Bacula:
#
# free (no arguments)
-# Scan the device and report the available space.
+# Scan the device and report the available space.
#
# write op filename
-# Write a part file to disk.
-# This operation needs two additional arguments.
-# The first (op) indicates to
-# 0 -- append
-# 1 -- first write to a blank disk
-# 2 -- blank or truncate a disk
+# Write a part file to disk.
+# This operation needs two additional arguments.
+# The first (op) indicates to
+# 0 -- append
+# 1 -- first write to a blank disk
+# 2 -- blank or truncate a disk
#
-# The second is the filename to write
+# The second is the filename to write
#
# operations available but not used by Bacula:
#
# test Scan the device and report the information found.
-# This operation needs no further arguments.
+# This operation needs no further arguments.
# prepare Prepare a DVD+/-RW for being used by Bacula.
-# Note: This is only useful if you already have some
-# non-Bacula data on a medium, and you want to use
-# it with Bacula. Don't run this on blank media, it
-# is useless.
+# Note: This is only useful if you already have some
+# non-Bacula data on a medium, and you want to use
+# it with Bacula. Don't run this on blank media, it
+# is useless.
#
#
# in case of operation ``free'' returns:
# dvd-writepart doesn't not always need to know the free space).
#
# The following methods are implemented:
-# __init__ we need that...
-# __repr__ this seems to be a good idea to have.
-# Quite minimalistic implementation, though.
-# __str__ For casts to string. Return the current disk information
-# is_empty Returns TRUE if the disk is empty, blank... this needs more
-# work, especially concerning non-RW media and blank vs. no
-# filesystem considerations. Here, we should also look for
-# other filesystems - probably we don't want to silently
-# overwrite UDF or ext2 or anything not mentioned in fstab...
-# (NB: I don't think it is a problem)
-# free Returns the available free space.
-# write Writes one part file to disk, either starting a new file
-# system on disk, or appending to it.
-# This method should also prepare a blank disk so that a
-# certain part of the disk is used to allow detection of a
-# used disk by all / more disk drives.
-# blank Blank the device
+# __init__ we need that...
+# __repr__ this seems to be a good idea to have.
+# Quite minimalistic implementation, though.
+# __str__ For casts to string. Return the current disk information
+# is_empty Returns TRUE if the disk is empty, blank... this needs more
+# work, especially concerning non-RW media and blank vs. no
+# filesystem considerations. Here, we should also look for
+# other filesystems - probably we don't want to silently
+# overwrite UDF or ext2 or anything not mentioned in fstab...
+# (NB: I don't think it is a problem)
+# free Returns the available free space.
+# write Writes one part file to disk, either starting a new file
+# system on disk, or appending to it.
+# This method should also prepare a blank disk so that a
+# certain part of the disk is used to allow detection of a
+# used disk by all / more disk drives.
+# blank Blank the device
#
###############################################################################
def __init__(self, devicename):
self.growcmd += " -quiet"
if self.is4gbsupported():
- self.growcmd += " -use-the-force-luke=4gms"
+ self.growcmd += " -use-the-force-luke=4gms"
self.growparams = " -A 'Bacula Data' -input-charset=default -iso-level 3 -pad " + \
- "-p 'dvd-handler / growisofs' -sysid 'BACULADATA' -R"
+ "-p 'dvd-handler / growisofs' -sysid 'BACULADATA' -R"
return
def __str__(self):
if not self.freespace_collected:
- self.collect_freespace();
+ self.collect_freespace();
if not self.mediumtype_collected:
- self.collect_mediumtype();
+ self.collect_mediumtype();
self.me = "Class disk, initialized with device '" + self.device + "'\n"
self.me += "type = '" + self.disktype + "' mode='" + self.diskmode + "' status = '" + self.diskstatus + "'\n"
processi = popen2.Popen4("uname -s -r")
status = processi.wait()
if not os.WIFEXITED(status):
- return 1
+ return 1
if os.WEXITSTATUS(status) != 0:
- return 1
+ return 1
strres = processi.fromchild.readline()[0:-1]
version = re.search(r"Linux (\d+)\.(\d+)\.(\d+)", strres)
if not version: # Non-Linux: allow
- return 1
+ return 1
if (int(version.group(1)) > 2) or (int(version.group(2)) > 6) or ((int(version.group(1)) == 2) and (int(version.group(2)) == 6) and (int(version.group(3)) >= 8)):
- return 1
+ return 1
else:
- return 0
+ return 0
def collect_freespace(self): # Collects current free space
self.next_session = 0
self.freespace_collected = 1
cmd = "du -sb " + self.device
- processi = popen2.Popen4(cmd)
+ processi = popen2.Popen4(cmd)
status = processi.wait()
if not os.WIFEXITED(status):
- return 1;
+ return 1;
if os.WEXITSTATUS(status) != 0:
- return 1;
+ return 1;
result = processi.fromchild.read()
used = re.search(r"(\d+)\s", result, re.MULTILINE)
self.capacity = self.maxcapacity - long(used.group(1))
if self.capacity < 0:
- self.capacity = 0
+ self.capacity = 0
return 0
processi = popen2.Popen4(cmd)
status = processi.wait()
if not os.WIFEXITED(status):
- raise DVDError(0, self.dvdrwmediainfo + " process did not exit correctly.")
+ raise DVDError(0, self.dvdrwmediainfo + " process did not exit correctly.")
if os.WEXITSTATUS(status) != 0:
- raise DVDError(0, "Cannot get media info from " + self.dvdrwmediainfo)
- return
+ raise DVDError(0, "Cannot get media info from " + self.dvdrwmediainfo)
+ return
result = processi.fromchild.read()
hardware = re.search(r"INQUIRY:\s+(.*)\n", result, re.MULTILINE)
status = re.search(r"\sDisc status:\s+(.*)\n", result, re.MULTILINE)
if hardware:
- self.hardwaredevice = hardware.group(1)
+ self.hardwaredevice = hardware.group(1)
if mediatype:
- self.disktype = mediatype.group(2)
+ self.disktype = mediatype.group(2)
else:
- raise DVDError(0, "Media type not found in " + self.dvdrwmediainfo + " output")
+ raise DVDError(0, "Media type not found in " + self.dvdrwmediainfo + " output")
if self.disktype == "DVD-RW":
- if mediamode:
- self.diskmode = mediamode.group(1)
- else:
- raise DVDError(0, "Media mode not found for DVD-RW in " + self.dvdrwmediainfo + " output")
+ if mediamode:
+ self.diskmode = mediamode.group(1)
+ else:
+ raise DVDError(0, "Media mode not found for DVD-RW in " + self.dvdrwmediainfo + " output")
if status:
- self.diskstatus = status.group(1)
+ self.diskstatus = status.group(1)
else:
- raise DVDError(0, "Disc status not found in " + self.dvdrwmediainfo + " output")
+ raise DVDError(0, "Disc status not found in " + self.dvdrwmediainfo + " output")
self.mediumtype_collected = 1
def is_empty(self):
if not self.freespace_collected:
- self.collect_freespace();
+ self.collect_freespace();
return 0 == self.next_session
def is_RW(self):
if not self.mediumtype_collected:
- self.collect_mediumtype();
+ self.collect_mediumtype();
return "DVD-RW" == self.disktype or "DVD+RW" == self.disktype or "DVD-RAM" == self.disktype
def is_plus_RW(self):
if not self.mediumtype_collected:
- self.collect_mediumtype();
+ self.collect_mediumtype();
return "DVD+RW" == self.disktype
def is_minus_RW(self):
if not self.mediumtype_collected:
- self.collect_mediumtype();
+ self.collect_mediumtype();
return "DVD-RW" == self.disktype
def is_restricted_overwrite(self):
if not self.mediumtype_collected:
- self.collect_mediumtype();
+ self.collect_mediumtype();
return self.diskmode == "Restricted Overwrite"
def is_blank(self):
if not self.mediumtype_collected:
- self.collect_mediumtype();
+ self.collect_mediumtype();
return self.diskstatus == "blank"
def free(self):
if not self.freespace_collected:
- self.collect_freespace();
+ self.collect_freespace();
fr = self.capacity-self.next_session-self.margin
if fr < 0:
- return 0
+ return 0
else:
- return fr
+ return fr
def term_handler(self, signum, frame):
print 'dvd-handler: Signal term_handler called with signal', signum
if self.pid != 0:
- print "dvd-handler: Sending SIGTERM to pid", self.pid
- os.kill(self.pid, signal.SIGTERM)
- time.sleep(10)
- print "dvd-handler: Sending SIGKILL to pid", self.pid
- os.kill(self.pid, signal.SIGKILL)
- sys.exit(1)
+ print "dvd-handler: Sending SIGTERM to pid", self.pid
+ os.kill(self.pid, signal.SIGTERM)
+ time.sleep(10)
+ print "dvd-handler: Sending SIGKILL to pid", self.pid
+ os.kill(self.pid, signal.SIGKILL)
+ sys.exit(1)
def write(self, newvol, partfile):
if newvol:
- print "Newvol", newvol
- print "Zap everything ..."
- os.system("rm -f "+self.device+"/*")
+ print "Newvol", newvol
+ print "Zap everything ..."
+ os.system("rm -f "+self.device+"/*")
print "cp", partfile, self.device
shutil.copy(partfile,self.device)
def prepare(self):
if not self.is_RW():
- raise DVDError(0, "I won't prepare a non-rewritable medium")
+ raise DVDError(0, "I won't prepare a non-rewritable medium")
# Blank DVD+RW when there is no data on it
if self.is_plus_RW() and self.is_blank():
- print "DVD+RW looks brand-new, blank it to fix some DVD-writers bugs."
- self.blank()
- return # It has been completely blanked: Medium is ready to be used by Bacula
+ print "DVD+RW looks brand-new, blank it to fix some DVD-writers bugs."
+ self.blank()
+ return # It has been completely blanked: Medium is ready to be used by Bacula
if self.is_minus_RW() and (not self.is_restricted_overwrite()):
- print "DVD-RW is in " + self.diskmode + " mode, reformating it to Restricted Overwrite"
- self.reformat_minus_RW()
- return # Reformated: Medium is ready to be used by Bacula
+ print "DVD-RW is in " + self.diskmode + " mode, reformating it to Restricted Overwrite"
+ self.reformat_minus_RW()
+ return # Reformated: Medium is ready to be used by Bacula
# TODO: Check if /dev/fd/0 and /dev/zero exists, otherwise, run self.blank()
if not os.path.exists("/dev/fd/0") or not os.path.exists("/dev/zero"):
- print "/dev/fd/0 or /dev/zero doesn't exist, blank the medium completely."
- self.blank()
- return
+ print "/dev/fd/0 or /dev/zero doesn't exist, blank the medium completely."
+ self.blank()
+ return
cmd = self.dd + " if=/dev/zero bs=1024 count=512 | " + self.growcmd + " -Z " + self.device + "=/dev/fd/0"
print "Running " + cmd
self.pid = proc.pid
status = proc.poll()
while status == -1:
- line = proc.fromchild.readline()
- while len(line) > 0:
- print line,
- line = proc.fromchild.readline()
- time.sleep(1)
- status = proc.poll()
+ line = proc.fromchild.readline()
+ while len(line) > 0:
+ print line,
+ line = proc.fromchild.readline()
+ time.sleep(1)
+ status = proc.poll()
self.pid = 0
print
signal.signal(signal.SIGTERM, oldsig)
if os.WEXITSTATUS(status) != 0:
- raise DVDError(os.WEXITSTATUS(status), cmd + " exited with status " + str(os.WEXITSTATUS(status)) + ", signal/status " + str(status))
+ raise DVDError(os.WEXITSTATUS(status), cmd + " exited with status " + str(os.WEXITSTATUS(status)) + ", signal/status " + str(status))
def blank(self):
cmd = self.growcmd + " -Z " + self.device + "=/dev/zero"
self.pid = proc.pid
status = proc.poll()
while status == -1:
- line = proc.fromchild.readline()
- while len(line) > 0:
- print line,
- line = proc.fromchild.readline()
- time.sleep(1)
- status = proc.poll()
+ line = proc.fromchild.readline()
+ while len(line) > 0:
+ print line,
+ line = proc.fromchild.readline()
+ time.sleep(1)
+ status = proc.poll()
self.pid = 0
print
signal.signal(signal.SIGTERM, oldsig)
if os.WEXITSTATUS(status) != 0:
- raise DVDError(os.WEXITSTATUS(status), cmd + " exited with status " + str(os.WEXITSTATUS(status)) + ", signal/status " + str(status))
+ raise DVDError(os.WEXITSTATUS(status), cmd + " exited with status " + str(os.WEXITSTATUS(status)) + ", signal/status " + str(status))
def reformat_minus_RW(self):
cmd = self.dvdrwformat + " -force " + self.device
self.pid = proc.pid
status = proc.poll()
while status == -1:
- line = proc.fromchild.readline()
- while len(line) > 0:
- print line,
- line = proc.fromchild.readline()
- time.sleep(1)
- status = proc.poll()
+ line = proc.fromchild.readline()
+ while len(line) > 0:
+ print line,
+ line = proc.fromchild.readline()
+ time.sleep(1)
+ status = proc.poll()
self.pid = 0
print
signal.signal(signal.SIGTERM, oldsig)
if os.WEXITSTATUS(status) != 0:
- raise DVDError(os.WEXITSTATUS(status), cmd + " exited with status " + str(os.WEXITSTATUS(status)) + ", signal/status " + str(status))
+ raise DVDError(os.WEXITSTATUS(status), cmd + " exited with status " + str(os.WEXITSTATUS(status)) + ", signal/status " + str(status))
# class disk ends here.
self.errno = errno
self.value = value
if self.value[-1] == '\n':
- self.value = self.value[0:-1]
+ self.value = self.value[0:-1]
def __str__(self):
return str(self.value) + " || errno = " + str(self.errno) + " (" + os.strerror(self.errno & 0x7F) + ")"
where DEVICE is a device name like /dev/sr0 or /dev/dvd.
Operations:
-test Scan the device and report the information found.
- This operation needs no further arguments.
-free Scan the device and report the available space.
-write Write a part file to disk.
- This operation needs two additional arguments.
- The first indicates to append (0), restart the
- disk (1) or restart existing disk (2). The second
- is the file to write.
+test Scan the device and report the information found.
+ This operation needs no further arguments.
+free Scan the device and report the available space.
+write Write a part file to disk.
+ This operation needs two additional arguments.
+ The first indicates to append (0), restart the
+ disk (1) or restart existing disk (2). The second
+ is the file to write.
prepare Prepare a DVD+/-RW for being used by Bacula.
- Note: This is only useful if you already have some
- non-Bacula data on a medium, and you want to use
- it with Bacula. Don't run this on blank media, it
- is useless.
+ Note: This is only useful if you already have some
+ non-Bacula data on a medium, and you want to use
+ it with Bacula. Don't run this on blank media, it
+ is useless.
"""
sys.exit(1)
if "free" == sys.argv[2]:
if len(sys.argv) == 3:
try:
- free = dvd.free()
+ free = dvd.free()
except DVDError, e:
- if e.errno != 0:
- print -e.errno
- else:
- print errno.EPIPE
- print str(e)
+ if e.errno != 0:
+ print -e.errno
+ else:
+ print errno.EPIPE
+ print str(e)
else:
- print free
- print "No Error reported."
+ print free
+ print "No Error reported."
else:
print "Wrong number of arguments for free operation. Wanted 3 got", len(sys.argv)
print sys.argv[1], sys.argv[2], sys.argv[3]
elif "prepare" == sys.argv[2]:
if len(sys.argv) == 3:
try:
- dvd.prepare()
+ dvd.prepare()
except DVDError, e:
- print "Error while preparing medium: ", str(e)
- if e.errno != 0:
- sys.exit(e.errno & 0x7F)
- else:
- sys.exit(errno.EPIPE)
+ print "Error while preparing medium: ", str(e)
+ if e.errno != 0:
+ sys.exit(e.errno & 0x7F)
+ else:
+ sys.exit(errno.EPIPE)
else:
- print "Medium prepared successfully."
+ print "Medium prepared successfully."
else:
print "Wrong number of arguments for prepare operation."
usage()
elif "write" == sys.argv[2]:
if len(sys.argv) == 5:
try:
- dvd.write(long(sys.argv[3]), sys.argv[4])
+ dvd.write(long(sys.argv[3]), sys.argv[4])
except DVDError, e:
- print "Error while writing part file: ", str(e)
- if e.errno != 0:
- sys.exit(e.errno & 0x7F)
- else:
- sys.exit(errno.EPIPE)
+ print "Error while writing part file: ", str(e)
+ if e.errno != 0:
+ sys.exit(e.errno & 0x7F)
+ else:
+ sys.exit(errno.EPIPE)
else:
- print "Part file " + sys.argv[4] + " successfully written to disk."
+ print "Part file " + sys.argv[4] + " successfully written to disk."
else:
print "Wrong number of arguments for write operation."
usage()
#
-# Copyright (C) 2000-2015 Kern Sibbald
+# Copyright (C) 2000-2016 Kern Sibbald
# License: BSD 2-Clause; see file LICENSE-FOSS
#
#
#
# Bacula(R) - The Network Backup Solution
#
-# Copyright (C) 2000-2015 Kern Sibbald
-# Copyright (C) 2000-2014 Free Software Foundation Europe e.V.
+# Copyright (C) 2000-2016 Kern Sibbald
#
# The original author of Bacula is Kern Sibbald, with contributions
# from many others, a complete list can be found in the file AUTHORS.
# in come cases, not all are used.
#
# mtx-changer "changer-device" "command" "slot" "archive-device" "drive-index"
-# $1 $2 $3 $4 $5
+# $1 $2 $3 $4 $5
#
# for example:
#
# is /dev/nst0.
#
# The commands are:
-# Command Function
-# unload unload a given slot
-# load load a given slot
-# loaded which slot is loaded?
-# list list Volume names (requires barcode reader)
-# slots how many slots total?
-# listall list all info
+# Command Function
+# unload unload a given slot
+# load load a given slot
+# loaded which slot is loaded?
+# list list Volume names (requires barcode reader)
+# slots how many slots total?
+# listall list all info
# transfer
#
# Slots are numbered from 1 ...
dbgfile="@working_dir@/mtx.log"
debug() {
if test -f $dbgfile -a ${debug_level} -ge $1; then
- echo "`date +%m%d-%H:%M:%S.%N|cut -c1-16` ${chgr_id} $2" >> $dbgfile
+ echo "`date +%m%d-%H:%M:%S.%N|cut -c1-16` ${chgr_id} $2" >> $dbgfile
fi
}
if test x${TMPFILE} = x; then
TMPFILE="@working_dir@/mtx.$$"
if test -f ${TMPFILE}; then
- echo "ERROR: Temp file security problem on: ${TMPFILE}"
- exit 1
+ echo "ERROR: Temp file security problem on: ${TMPFILE}"
+ exit 1
fi
fi
}
if test x${ERRFILE} = x; then
ERRFILE="@working_dir@/mtx.err.$$"
if test -f ${ERRFILE}; then
- echo "ERROR: Temp file security problem on: ${ERRFILE}"
- exit 1
+ echo "ERROR: Temp file security problem on: ${ERRFILE}"
+ exit 1
fi
fi
}
pCount=$1
pCountNeed=$2
if test $pCount -lt $pCountNeed; then
- echo "ERROR: usage: mtx-changer ctl-device command [slot archive-device drive-index]"
- echo " Insufficient number of arguments given."
- if test $pCount -lt 2; then
- echo " Mimimum usage is first two arguments ..."
- else
- echo " Command expected $pCountNeed arguments"
- fi
- exit 1
+ echo "ERROR: usage: mtx-changer ctl-device command [slot archive-device drive-index]"
+ echo " Insufficient number of arguments given."
+ if test $pCount -lt 2; then
+ echo " Mimimum usage is first two arguments ..."
+ else
+ echo " Command expected $pCountNeed arguments"
+ fi
+ exit 1
fi
}
#
case $2 in
list|listall)
- check_parm_count $# 2
- ;;
+ check_parm_count $# 2
+ ;;
slots)
- check_parm_count $# 2
- ;;
+ check_parm_count $# 2
+ ;;
transfer)
- check_parm_count $# 4
- ;;
+ check_parm_count $# 4
+ ;;
*)
- check_parm_count $# 5
- ;;
+ check_parm_count $# 5
+ ;;
esac
unload)
if test ${offline} -eq 1 ; then
- mt -f $device offline
+ mt -f $device offline
fi
if test ${offline_sleep} -ne 0 ; then
- sleep ${offline_sleep}
+ sleep ${offline_sleep}
fi
make_err_file
for i in 1 2 3 4 5 ; do
- debug $idbglvl "Doing mtx -f $ctl unload slot=$slot drv=$drive"
- ${MTX} -f $ctl unload $slot $drive 2>${ERRFILE}
- rtn=$?
- if test $rtn -eq 0 ; then
- break
- fi
- grep "Error Code=" ${ERRFILE} 2>/dev/null 1>/dev/null
- if test $? -ne 0 ; then
- break
- fi
- sleep $i
+ debug $idbglvl "Doing mtx -f $ctl unload slot=$slot drv=$drive"
+ ${MTX} -f $ctl unload $slot $drive 2>${ERRFILE}
+ rtn=$?
+ if test $rtn -eq 0 ; then
+ break
+ fi
+ grep "Error Code=" ${ERRFILE} 2>/dev/null 1>/dev/null
+ if test $? -ne 0 ; then
+ break
+ fi
+ sleep $i
done
cat ${ERRFILE}
rm -f ${ERRFILE} >/dev/null 2>&1
if test $rtn -ne 0 ; then
- debug $idbglvl "FAIL: mtx -f $ctl unload slot=$slot drv=$drive"
+ debug $idbglvl "FAIL: mtx -f $ctl unload slot=$slot drv=$drive"
fi
exit $rtn
;;
load)
make_err_file
for i in 1 2 3 4 5 ; do
- debug $idbglvl "Doing mtx -f $ctl load slot=$slot drv=$drive"
- ${MTX} -f $ctl load $slot $drive 2>${ERRFILE}
- rtn=$?
- if test $rtn -eq 0 ; then
- break
- fi
- grep "Error Code=" ${ERRFILE} 2>/dev/null 1>/dev/null
- if test $? -ne 0 ; then
- break
- fi
- sleep $i
+ debug $idbglvl "Doing mtx -f $ctl load slot=$slot drv=$drive"
+ ${MTX} -f $ctl load $slot $drive 2>${ERRFILE}
+ rtn=$?
+ if test $rtn -eq 0 ; then
+ break
+ fi
+ grep "Error Code=" ${ERRFILE} 2>/dev/null 1>/dev/null
+ if test $? -ne 0 ; then
+ break
+ fi
+ sleep $i
done
if test ${load_sleep} -ne 0 ; then
- sleep ${load_sleep}
+ sleep ${load_sleep}
fi
wait_for_drive $device
cat ${ERRFILE}
rm -f ${ERRFILE} >/dev/null 2>&1
if test $rtn -ne 0 ; then
- debug $idbglvl "FAIL: mtx -f $ctl load slot=$slot drv=$drive"
+ debug $idbglvl "FAIL: mtx -f $ctl load slot=$slot drv=$drive"
fi
exit $rtn
;;
list)
make_temp_file
if test ${inventory} -ne 0 ; then
- ${MTX} -f $ctl inventory
+ ${MTX} -f $ctl inventory
fi
debug $dbglvl "Doing mtx -f $ctl list"
${MTX} -f $ctl status >${TMPFILE}
rtn=$?
if test ${vxa_packetloader} -ne 0 ; then
- cat ${TMPFILE} | grep " *Storage Element [0-9]*:.*Full" | sed "s/ Storage Element //" | sed "s/Full :VolumeTag=//"
+ cat ${TMPFILE} | grep " *Storage Element [0-9]*:.*Full" | sed "s/ Storage Element //" | sed "s/Full :VolumeTag=//"
else
- cat ${TMPFILE} | grep " Storage Element [0-9]*:.*Full" | awk "{print \$3 \$4}" | sed "s/Full *\(:VolumeTag=\)*//"
+ cat ${TMPFILE} | grep " Storage Element [0-9]*:.*Full" | awk "{print \$3 \$4}" | sed "s/Full *\(:VolumeTag=\)*//"
fi
cat ${TMPFILE} | grep "^Data Transfer Element [0-9]*:Full (Storage Element [0-9]" | awk '{printf "%s:%s\n",$7,$10}'
rm -f ${TMPFILE} >/dev/null 2>&1
if test $rtn -ne 0 ; then
- debug $idbglvl "FAIL: mtx -f $ctl list"
+ debug $idbglvl "FAIL: mtx -f $ctl list"
fi
exit $rtn
;;
listall)
-# Drive content: D:Drive num:F:Slot loaded:Volume Name
+# Drive content: D:Drive num:F:Slot loaded:Volume Name
# D:0:F:2:vol2 or D:Drive num:E
# D:1:F:42:vol42
# D:3:E
#
# Slot content:
-# S:1:F:vol1 S:Slot num:F:Volume Name
-# S:2:E or S:Slot num:E
+# S:1:F:vol1 S:Slot num:F:Volume Name
+# S:2:E or S:Slot num:E
# S:3:F:vol4
#
# Import/Export tray slots:
-# I:10:F:vol10 I:Slot num:F:Volume Name
-# I:11:E or I:Slot num:E
+# I:10:F:vol10 I:Slot num:F:Volume Name
+# I:11:E or I:Slot num:E
# I:12:F:vol40
make_temp_file
if test ${inventory} -ne 0 ; then
- ${MTX} -f $ctl inventory
+ ${MTX} -f $ctl inventory
fi
debug $dbglvl "Doing mtx -f $ctl -- to list all"
${MTX} -f $ctl status >${TMPFILE}
${MTX} -f $ctl transfer $slot $slotdest
rtn=$?
if test $rtn -ne 0 ; then
- debug $idbglvl "FAIL: mtx -f $ctl transfer from=$slot to=$slotdest"
+ debug $idbglvl "FAIL: mtx -f $ctl transfer from=$slot to=$slotdest"
fi
exit $rtn
;;
cat ${TMPFILE} | grep "^Data Transfer Element $drive:Empty" | awk "{print 0}"
rm -f ${TMPFILE} >/dev/null 2>&1
if test $rtn -ne 0 ; then
- debug $idbglvl "FAIL: mtx -f $ctl loaded drv=$drive"
+ debug $idbglvl "FAIL: mtx -f $ctl loaded drv=$drive"
fi
exit $rtn
;;
${MTX} -f $ctl status | grep " *Storage Changer" | awk "{print \$5}"
rtn=$?
if test $rtn -ne 0 ; then
- debug $idbglvl "FAIL: mtx -f $ctl slots"
+ debug $idbglvl "FAIL: mtx -f $ctl slots"
fi
;;
esac