/usr/lib/amanda/chg-disk is in amanda-server 1:3.3.3-2ubuntu1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 | #! /bin/bash
#
# Amanda, The Advanced Maryland Automatic Network Disk Archiver
# Copyright (c) 1991-1999 University of Maryland at College Park
# Copyright (c) 2007-2012 Zmanda, Inc. All Rights Reserved.
# All Rights Reserved.
#
# Permission to use, copy, modify, distribute, and sell this software and its
# documentation for any purpose is hereby granted without fee, provided that
# the above copyright notice appear in all copies and that both that
# copyright notice and this permission notice appear in supporting
# documentation, and that the name of U.M. not be used in advertising or
# publicity pertaining to distribution of the software without specific,
# written prior permission. U.M. makes no representations about the
# suitability of this software for any purpose. It is provided "as is"
# without express or implied warranty.
#
# U.M. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL U.M.
# BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
# OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#
# Author: Jean-Christian SIMONETTI, System and Network Engineer
# Wanadoo Portails
# Sophia Antipolis, France
#
# This changer script is based on a directory structure like:
# slot_root_dir -|
# |- info
# |- data -> slot1
# |- slot1
# |- slot2
# |- ...
# |- slotn
# where 'slot_root_dir' is the tapedev 'file:xxx' parameter and 'n'
# 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 (amanda.conf):
# --- cut here ---
# tapedev "file:/BACKUP2/slots/"
# changerdev "/dev/null"
# changerfile "chg-disk"
# tpchanger "chg-disk"
# changerfile "/usr/local/amanda/etc/changer"
# tapetype HARD-DISK
# define tapetype HARD-DISK {
# length 12000 mbytes
# }
# --- cut here ---
#
# 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.
#
prefix="/usr"
exec_prefix="${prefix}"
sbindir="/usr/sbin"
amlibexecdir="/usr/lib/amanda"
. "${amlibexecdir}/amanda-sh-lib.sh"
# add sbin and ucb dirs
PATH="$PATH:/usr/sbin:/sbin:/usr/ucb"
export PATH
MYNAME=$0
TAPE=`amgetconf tapedev`
if test X"$TAPE" = X""; then
echo `_ '<none> tapedev not specified in amanda.conf.'`
exit 2
fi
SLOTDIR=`echo $TAPE | sed 's/^file://'`
isinteger() {
# should be exactly one arg
[ $# = 1 ] || return 1
# if arg is null, no expr needed
[ "${1}" = '' ] && return 1
# expr will return 0 on match
expr "$1" : '[0-9][0-9]*$' > /dev/null 2>&1
}
# Need rwx access to the virtual tape itself.
if ! test -d $SLOTDIR; then
echo `_ '<none> Virtual-tape directory %s does not exist.' "$SLOTDIR"`
exit 2
fi
if ! test -w $SLOTDIR; then
echo `_ '<none> Virtual-tape directory %s is not writable.' "$SLOTDIR"`
exit 2
fi
# need rwx access to directory of changer file
CHANGERFILE=`amgetconf 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 `_ "<none> %s: need 'rwx' access to '%s'" "$MYNAME" "$CFDir"` ; exit 2 ; }
# check or create changer metadata files
ACCESSFILE=$CHANGERFILE-access
[ -f $ACCESSFILE -a -r $ACCESSFILE -a -w $ACCESSFILE ] ||
echo 0 > $ACCESSFILE ||
{ echo `_ "<none> %s: could not access or create '%s'" "$MYNAME" "$ACCESSFILE"` ; exit 2; }
CLEANFILE=$CHANGERFILE-clean
[ -f $CLEANFILE -a -r $CLEANFILE -a -w $CLEANFILE ] ||
echo 0 > $CLEANFILE ||
{ echo `_ "<none> %s: could not access or create '%s'" "$MYNAME" "$CLEANFILE"` ; exit 2 ; }
SLOTFILE=$CHANGERFILE-slot
[ -f $SLOTFILE -a -r $SLOTFILE -a -w $SLOTFILE ] ||
echo 0 > $SLOTFILE ||
{ echo `_ "<none> %s: could not access or create '%s'" "$MYNAME" "$SLOTFILE"` ; exit 2; }
# read and check metadata
ACCESSCOUNT=`cat $ACCESSFILE`
isinteger $ACCESSCOUNT || { ACCESSCOUNT=0 ; echo 0 > $ACCESSFILE ; }
CLEANCOUNT=`cat $CLEANFILE`
isinteger $CLEANCOUNT || { CLEANCOUNT=0 ; echo 0 > $CLEANFILE ; }
FIRSTSLOT=1
LASTSLOT=`amgetconf tapecycle`
if test -r $CONFIGFILE; then
. $CONFIGFILE
fi
CURSLOT=0
CLEANSLOT=$LASTSLOT
NSLOT=`expr $LASTSLOT - $FIRSTSLOT + 1`
load() {
WHICHSLOT=$1;
# unload should have been called, but just in case ...
[ -h $SLOTDIR/data ] && unload
ln -s $SLOTDIR/slot$WHICHSLOT $SLOTDIR/data
echo $WHICHSLOT > $SLOTFILE
}
unload() {
rm -f $SLOTDIR/data
echo "0" > $SLOTFILE
}
readstatus() {
CURSLOT=`cat $SLOTFILE`
}
loadslot() {
WHICHSLOT=$1
TYPE=string # default if not numeric
isinteger $WHICHSLOT && TYPE=digit
readstatus
NEWSLOT=0
if [ $WHICHSLOT = "current" ]; then
if [ $CURSLOT -le 0 ]; then
load $FIRSTSLOT
echo "$FIRSTSLOT $TAPE"
exit 0
else
echo "$CURSLOT $TAPE"
exit 0
fi
elif [ $WHICHSLOT = "next" -o $WHICHSLOT = "advance" ]; then
NEWSLOT=`expr $CURSLOT + 1`
[ $NEWSLOT -gt $LASTSLOT ] && NEWSLOT=$FIRSTSLOT
elif [ $WHICHSLOT = "prev" ]; then
NEWSLOT=`expr $CURSLOT - 1`
[ $NEWSLOT -lt $FIRSTSLOT ] && NEWSLOT=$LASTSLOT
elif [ $WHICHSLOT = "first" ]; then
NEWSLOT=$FIRSTSLOT
elif [ $WHICHSLOT = "last" ]; then
NEWSLOT=$LASTSLOT
elif [ $TYPE = "digit" ]; then
if [ $WHICHSLOT -ge $FIRSTSLOT -a $WHICHSLOT -le $LASTSLOT ]; then
NEWSLOT=$WHICHSLOT
else
echo `_ '%s illegal slot' "$WHICHSLOT"`
exit 1
fi
elif [ $WHICHSLOT = "clean" ]; then
NEWSLOT=$CLEANSLOT
else
echo `_ '%s illegal request' "$WHICHSLOT"`
exit 1
fi
if [ $NEWSLOT = $CURSLOT ]; then
echo "$CURSLOT $TAPE"
exit 0
fi
if [ $NEWSLOT = $CLEANSLOT ]; then
expr ${CLEANCOUNT:=0} + 1 > $CLEANFILE
echo 0 > $ACCESSFILE
else
expr ${ACCESSCOUNT:=0} + 1 > $ACCESSFILE
if [ $ACCESSCOUNT -gt $LASTSLOT ]; then
$MYNAME -slot clean >/dev/null
fi
fi
readstatus
if [ $CURSLOT -ne 0 ]; then
unload
fi
if [ $WHICHSLOT = "advance" ]; then
echo "$NEWSLOT /dev/null"
exit 0
fi
load $NEWSLOT
echo "$NEWSLOT $TAPE"
exit 0
}
info() {
readstatus
echo "$CURSLOT $NSLOT 1"
exit 0
}
reset() {
readstatus
[ $CURSLOT -gt 0 ] && unload
load $FIRSTSLOT
echo "$FIRSTSLOT $tape"
exit 0
}
eject() {
readstatus
if [ $CURSLOT -le 0 ]; then
echo `_ '0 Drive was not loaded'`
exit 1
else
unload
echo $CURSLOT
exit 0
fi
}
while [ $# -ge 1 ];do
case $1 in
-slot)
shift
loadslot $*
;;
-clean)
shift
loadslot clean
;;
-current)
shift
loadslot current
;;
-next)
shift
loadslot next
;;
-advance)
shift
loadslot advance
;;
-prev)
shift
loadslot prev
;;
-first)
shift
loadslot first
;;
-last)
shift
loadslot last
;;
-info)
shift
info
;;
-reset)
shift
reset
;;
-eject)
shift
eject
;;
*)
echo `_ '<none> Unknown option %s' "$1"`
exit 2
;;
esac
done
|