7 exec_prefix=@exec_prefix@
9 libexecdir=@libexecdir@
11 ConfigDir=@CONFIG_DIR@
13 PATH=$sbindir:$libexecdir:/usr/bin:/bin:/usr/sbin:/sbin:/usr/ucb
24 if [ "$Config" = "" ]; then
25 log "usage: ${Program} <config> <volume header>"
29 if [ "$VOLHEADER" = "" ]; then
30 log "usage: ${Program} <config> <volume header>"
35 # Check if the configuration directory exists. Make sure that the
36 # necessary files can be found, such as amanda.conf and tapelist.
38 if [ ! -d ${ConfigDir}/${Config} ]; then
39 log "${Program}: configuration directory ${ConfigDir}/${Config} does not exist."
42 (cd ${ConfigDir}/${Config} >/dev/null 2>&1) || exit $?
43 cd ${ConfigDir}/${Config}
44 if [ ! -r amanda.conf ]; then
45 log "${Program}: amanda.conf not found or is not readable in ${ConfigDir}."
49 # Get the location and name of the tapelist filename. If tapelist is not
50 # specified in the amanda.conf file, then use tapelist in the config
52 TapeList=`amgetconf${SUF} tapelist`
53 if [ ! "$TapeList" ]; then
54 TapeList="$ConfigDir/$Config/tapelist"
56 if [ ! -r $TapeList ]; then
57 log "${Program}: $TapeList not found or is not readable."
61 AllTapeList="${TapeList}.all"
63 [ ! -f $AllTapeList ] \
64 && echo "no tapelist $AllTapeList found" >&2 \
65 && cat $TapeList | sed 's/^.* //' | sort -u > $AllTapeList \
66 && echo "$AllTapeList created" >&2
68 cat $TapeList | sed 's/^.* //' > $AllTapeList.n
69 cat $AllTapeList >> $AllTapeList.n
70 sort -u $AllTapeList.n > $AllTapeList && rm -f $AllTapeList.n
72 MAXTAPE=`cat $AllTapeList | sed "s/^$VOLHEADER//" | sort -n | tail -1`
73 NEXTTAPE=`expr $MAXTAPE + 1`
74 echo "last Tape is ${VOLHEADER}${MAXTAPE}" >&2
77 while [ $I -le $MAXTAPE ]; do
78 WRITTEN=`grep "${VOLHEADER}${I}\$" $TapeList`
79 EXISTS=`grep "${VOLHEADER}${I}\$" $AllTapeList`
80 if [ "$EXISTS" = "" -a "$WRITTEN" = "" ]; then
81 echo "missing tape ${VOLHEADER}${I}" >&2
82 echo "${VOLHEADER}${I}" >> $AllTapeList \
83 && echo "added ${VOLHEADER}${I} to $AllTapeList" >&2
84 elif [ "$EXISTS" = "" -a "$WRITTEN" != "" ]; then
85 echo "tape written, but not existing: ${VOLHEADER}${I}" >&2
86 elif [ "$EXISTS" != "" -a "$WRITTEN" = "" ]; then
87 echo "free tape: ${VOLHEADER}${I}" >&2
92 echo "next tape is ${VOLHEADER}${NEXTTAPE}" >&2