X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=changer-src%2Fchg-disk.sh.in;h=5ac3783e110a3da2e0c70f609bbcac47097f2639;hb=ac973066bc508cb82728e46eaf499e9424d4e0f1;hp=72dc98b3e66f7ec5ff87a9af525d349e3dea5f6a;hpb=eefb15c5c04acb3c75f0c704ea664feb1bbae75c;p=debian%2Famanda diff --git a/changer-src/chg-disk.sh.in b/changer-src/chg-disk.sh.in index 72dc98b..5ac3783 100644 --- a/changer-src/chg-disk.sh.in +++ b/changer-src/chg-disk.sh.in @@ -1,4 +1,4 @@ -#! /bin/sh +#! @SHELL@ # # Amanda, The Advanced Maryland Automatic Network Disk Archiver # Copyright (c) 1991-1999 University of Maryland at College Park @@ -34,16 +34,18 @@ # |- ... # |- slotn # where 'slot_root_dir' is the tapedev 'file:xxx' parameter and 'n' -# is the tapecycle parameter. -# +# is the LASTSLOT value of your changerfile config file. If LASTSLOT is +# not defined, the value of the tapecycle parameter is used. +# # To use this driver, just put the line 'tpchanger "chg-disk"' in your # amanda.conf. # -# Example of use: +# Example of use (amanda.conf): # --- cut here --- # tapedev "file:/BACKUP2/slots/" # rawtapedev "file:/BACKUP2/slots/" # changerdev "/dev/null" +# changerfile "chg-disk" # tpchanger "chg-disk" # changerfile "/usr/local/amanda/etc/changer" # tapetype HARD-DISK @@ -52,7 +54,12 @@ # } # --- cut here --- # -# The number of slot is equal to your tapecyle. +# Example changerfile (chg-disk.conf): +# --- cut here --- +# LASTSLOT=12 +# --- cut here --- +# +# The number of slot is equal to your LASTSLOT or tapecycle. # You must create the slots and data directory. # @@ -75,6 +82,10 @@ fi MYNAME=$0 TAPE=`amgetconf$SUF tapedev` +if test X"$TAPE" == X""; then + echo " tapedev not specified in amanda.conf." + exit 2 +fi SLOTDIR=`echo $TAPE | sed 's/^file://'` isinteger() { @@ -86,25 +97,44 @@ isinteger() { expr "$1" : '[0-9][0-9]*$' > /dev/null 2>&1 } +# Need rwx access to the virtual tape itself. +if ! test -d $SLOTDIR; then + echo " Virtual-tape directory $SLOTDIR does not exist." + exit 2 +fi +if ! test -w $SLOTDIR; then + echo " Virtual-tape directory $SLOTDIR is not writable." + exit 2 +fi + + # need rwx access to directory of changer file CHANGERFILE=`amgetconf$SUF changerfile` +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 + CFDir=`dirname ${CHANGERFILE}` [ -d ${CFDir} -a -r ${CFDir} -a -w ${CFDir} -a -x ${CFDir} ] || - { echo "$MYNAME: need 'rwx' access to '$CFDir'" ; exit 2 ; } + { echo " $MYNAME: need 'rwx' access to '$CFDir'"; exit 2 ; } # check or create changer metadata files ACCESSFILE=$CHANGERFILE-access [ -f $ACCESSFILE -a -r $ACCESSFILE -a -w $ACCESSFILE ] || echo 0 > $ACCESSFILE || - { echo "$MYNAME: could not access or create '$ACCESSFILE'" ; exit 2 ; } + { echo " $MYNAME: could not access or create '$ACCESSFILE'" ; exit 2 ; } CLEANFILE=$CHANGERFILE-clean [ -f $CLEANFILE -a -r $CLEANFILE -a -w $CLEANFILE ] || echo 0 > $CLEANFILE || - { echo "$MYNAME: could not access or create '$CLEANFILE'" ; exit 2 ; } + { echo " $MYNAME: could not access or create '$CLEANFILE'" ; exit 2 ; } SLOTFILE=$CHANGERFILE-slot [ -f $SLOTFILE -a -r $SLOTFILE -a -w $SLOTFILE ] || echo 0 > $SLOTFILE || - { echo "$MYNAME: could not access or create '$SLOTFILE'" ; exit 2 ; } + { echo " $MYNAME: could not access or create '$SLOTFILE'" ; exit 2 ; } # read and check metadata ACCESSCOUNT=`cat $ACCESSFILE` @@ -114,8 +144,12 @@ isinteger $CLEANCOUNT || { CLEANCOUNT=0 ; echo 0 > $CLEANFILE ; } FIRSTSLOT=1 LASTSLOT=`amgetconf$SUF tapecycle` +if test -r $CONFIGFILE; then + . $CONFIGFILE +fi CURSLOT=0 CLEANSLOT=$LASTSLOT +NSLOT=`expr $LASTSLOT - $FIRSTSLOT + 1` load() { WHICHSLOT=$1; @@ -165,13 +199,13 @@ loadslot() { if [ $WHICHSLOT -ge $FIRSTSLOT -a $WHICHSLOT -le $LASTSLOT ]; then NEWSLOT=$WHICHSLOT else - echo "0 illegal request" + echo "$WHICHSLOT illegal slot" exit 1 fi elif [ $WHICHSLOT = "clean" ]; then NEWSLOT=$CLEANSLOT else - echo "0 illegal request" + echo "$WHICHSLOT illegal request" exit 1 fi if [ $NEWSLOT = $CURSLOT ]; then @@ -204,7 +238,7 @@ loadslot() { info() { readstatus - echo "$CURSLOT $LASTSLOT $FIRSTSLOT" + echo "$CURSLOT $NSLOT 1" exit 0 } @@ -276,7 +310,7 @@ while [ $# -ge 1 ];do eject ;; *) - echo "Unknown option $1" + echo " Unknown option $1" exit 2 ;; esac