4 echo "USAGE: $0 <CONFIG>"
9 CFGDIR=`amgetconf build.CONFIG_DIR`
10 if test -z "$CFGDIR"; then
11 echo "could not get CONFIG_DIR - is Amanda set up correctly?"
15 # cd into config dir so relative paths work
19 # get the configuration (this is copied directly from chg-zd-mtx)
26 changerfile=`amgetconf $CONFIG changerfile 2>/dev/null`
27 if [ -z "$changerfile" ]; then
28 die "changerfile must be specified in amanda.conf"
30 conf_match=`expr "$changerfile" : .\*\.conf\$`
31 if [ $conf_match -ge 6 ]; then
32 configfile=$changerfile
33 changerfile=`echo $changerfile | sed 's/.conf$//g'`
35 configfile=$changerfile.conf
37 if [ ! -e $configfile ]; then
38 die "configuration file \"$configfile\" doesn't exist"
40 if [ ! -f $configfile ]; then
41 die "configuration file \"$configfile\" is not a file"
43 cleanfile=$changerfile-clean
44 accessfile=$changerfile-access
45 slotfile=$changerfile-slot
46 labelfile=$changerfile-barcodes
49 varlist="$varlist firstslot"
50 varlist="$varlist lastslot"
51 varlist="$varlist cleanslot"
52 varlist="$varlist cleancycle"
53 varlist="$varlist OFFLINE_BEFORE_UNLOAD" # old name
54 varlist="$varlist offline_before_unload"
55 varlist="$varlist unloadpause"
56 varlist="$varlist AUTOCLEAN" # old name
57 varlist="$varlist autoclean"
58 varlist="$varlist autocleancount"
59 varlist="$varlist havereader"
60 varlist="$varlist driveslot"
61 varlist="$varlist poll_drive_ready"
62 varlist="$varlist initial_poll_delay"
63 varlist="$varlist max_drive_wait"
64 varlist="$varlist slotinfofile"
68 val="`cat $configfile 2>/dev/null | sed -n '
69 # Ignore comment lines (anything starting with a #).
71 # Find the first var=val line in the file, print the value and quit.
72 /^[ ]*'$var'[ ]*=[ ]*\([^ ][^ ]*\).*/ {
73 s/^[ ]*'$var'[ ]*=[ ]*\([^ ][^ ]*\).*/\1/p
80 firstslot=${firstslot:-'-1'} # default: mtx status
81 lastslot=${lastslot:-'-1'} # default: mtx status
82 driveslot=${driveslot:-'0'} # default: 0
83 cleanslot=${cleanslot:-'-1'} # default: -1
84 cleancycle=${cleancycle:-'120'} # default: two minutes
85 if [ -z "$offline_before_unload" -a -n "$OFFLINE_BEFORE_UNLOAD" ]; then
86 offline_before_unload=$OFFLINE_BEFORE_UNLOAD # (old name)
88 offline_before_unload=${offline_before_unload:-'0'} # default: 0
89 unloadpause=${unloadpause:-'0'} # default: 0
90 if [ -z "$autoclean" -a -n "$AUTOCLEAN" ]; then
91 autoclean=$AUTOCLEAN # (old name)
93 autoclean=${autoclean:-'0'} # default: 0
94 autocleancount=${autocleancount:-'99'} # default: 99
95 havereader=${havereader:-'0'} # default: 0
96 poll_drive_ready=${poll_drive_ready:-'3'} # default: three seconds
97 initial_poll_delay=${initial_poll_delay:-'0'} # default: zero zeconds
98 max_drive_wait=${max_drive_wait:-'120'} # default: two minutes
100 tapedev=`amgetconf $CONFIG tapedev 2>/dev/null`
101 if [ -z "$tapedev" ]; then
102 die "tapedev may not be empty"
105 changerdev=`amgetconf $CONFIG changerdev 2>/dev/null`
106 if [ -z "$changerdev" ]; then
107 die "changerdev may not be empty"
108 elif [ $changerdev = "/dev/null" ]; then
109 die "changerdev ($changerdev) may not be the null device"
113 # Create the chg-robot config
115 # note that cleaning is not supported by chg-robot, so the cleaning parameters are
119 if test "$1" -ne 0; then
126 echo "Remove the following parameters, if present, from your amanda.conf:"
127 echo " tpchanger changerfile changerdev tapedev"
129 echo "Add the following to amanda.conf (you may want to use a more descriptive name for the changer):"
131 echo "tapedev \"converted-from-chg-zd-mtx\""
132 echo "define changer \"converted-from-chg-zd-mtx\" {"
133 echo " tpchanger \"chg-robot:$changerdev\""
134 echo " changerfile \"$changerfile-state\""
135 echo " property \"tape-device\" \"$driveslot=$tapedev\""
136 echo " property \"eject-before-unload\" \""`showbool $offline_before_unload`"\""
137 if test $firstslot -ge 0 && test $lastslot -ge 0; then
138 echo " property \"use-slots\" \"$firstslot-$lastslot\""
139 elif test $firstslot -ge 0 || test $lastslot -ge 0; then
140 echo " # you may want to set the USE-SLOTS property appropriately"
142 if test "${unloadpause:-0}" -gt 0; then
143 echo " property \"eject-delay\" \"$unloadpause s\""
145 if test $havereader -eq 0; then
146 echo " property \"fast-search\" \"no\""
147 echo " property \"ignore-barcodes\" \"yes\""
149 echo " property \"load-poll\" \"$initial_poll_delay s poll $poll_drive_ready s until $max_drive_wait s\""
154 # and offer suggestions for loading metadata, if slotinfofile is set
156 if test -z "$slotinfofile"; then
157 echo "Once this configuration is in place, run"
158 echo " amtape $CONFIG update"
159 echo "to update the changer's tape database. For a large changer, this may take some time."
161 echo "Run the following commands to initialize the changer's tape database."
162 cat "$slotinfofile" | while read slot label; do
163 echo " amtape $CONFIG update \"$slot=$label\""