]> git.pld-linux.org Git - packages/amanda.git/blame - convert-zd-mtx-to-robot.sh
- fixed assertion failed: (!g_thread_supported()) issue with newer glib
[packages/amanda.git] / convert-zd-mtx-to-robot.sh
CommitLineData
7ef676da
JR
1#! /bin/sh
2
3if test $# -ne 1; then
4 echo "USAGE: $0 <CONFIG>"
5 exit 1
6fi
7
8CONFIG=$1
9CFGDIR=`amgetconf build.CONFIG_DIR`
10if test -z "$CFGDIR"; then
11 echo "could not get CONFIG_DIR - is Amanda set up correctly?"
12 exit 1;
13fi
14
15# cd into config dir so relative paths work
16cd "$CFGDIR/$CONFIG"
17
18##
19# get the configuration (this is copied directly from chg-zd-mtx)
20
21die() {
22 echo "$*"
23 exit 1
24}
25
26changerfile=`amgetconf $CONFIG changerfile 2>/dev/null`
27if [ -z "$changerfile" ]; then
28 die "changerfile must be specified in amanda.conf"
29fi
30conf_match=`expr "$changerfile" : .\*\.conf\$`
31if [ $conf_match -ge 6 ]; then
32 configfile=$changerfile
33 changerfile=`echo $changerfile | sed 's/.conf$//g'`
34else
35 configfile=$changerfile.conf
36fi
37if [ ! -e $configfile ]; then
38 die "configuration file \"$configfile\" doesn't exist"
39fi
40if [ ! -f $configfile ]; then
41 die "configuration file \"$configfile\" is not a file"
42fi
43cleanfile=$changerfile-clean
44accessfile=$changerfile-access
45slotfile=$changerfile-slot
46labelfile=$changerfile-barcodes
47
48varlist=
49varlist="$varlist firstslot"
50varlist="$varlist lastslot"
51varlist="$varlist cleanslot"
52varlist="$varlist cleancycle"
53varlist="$varlist OFFLINE_BEFORE_UNLOAD" # old name
54varlist="$varlist offline_before_unload"
55varlist="$varlist unloadpause"
56varlist="$varlist AUTOCLEAN" # old name
57varlist="$varlist autoclean"
58varlist="$varlist autocleancount"
59varlist="$varlist havereader"
60varlist="$varlist driveslot"
61varlist="$varlist poll_drive_ready"
62varlist="$varlist initial_poll_delay"
63varlist="$varlist max_drive_wait"
64varlist="$varlist slotinfofile"
65
66for var in $varlist
67do
68 val="`cat $configfile 2>/dev/null | sed -n '
69# Ignore comment lines (anything starting with a #).
70/^[ ]*#/d
71# Find the first var=val line in the file, print the value and quit.
72/^[ ]*'$var'[ ]*=[ ]*\([^ ][^ ]*\).*/ {
73 s/^[ ]*'$var'[ ]*=[ ]*\([^ ][^ ]*\).*/\1/p
74 q
75}
76'`"
77 eval $var=\"$val\"
78done
79
80firstslot=${firstslot:-'-1'} # default: mtx status
81lastslot=${lastslot:-'-1'} # default: mtx status
82driveslot=${driveslot:-'0'} # default: 0
83cleanslot=${cleanslot:-'-1'} # default: -1
84cleancycle=${cleancycle:-'120'} # default: two minutes
85if [ -z "$offline_before_unload" -a -n "$OFFLINE_BEFORE_UNLOAD" ]; then
86 offline_before_unload=$OFFLINE_BEFORE_UNLOAD # (old name)
87fi
88offline_before_unload=${offline_before_unload:-'0'} # default: 0
89unloadpause=${unloadpause:-'0'} # default: 0
90if [ -z "$autoclean" -a -n "$AUTOCLEAN" ]; then
91 autoclean=$AUTOCLEAN # (old name)
92fi
93autoclean=${autoclean:-'0'} # default: 0
94autocleancount=${autocleancount:-'99'} # default: 99
95havereader=${havereader:-'0'} # default: 0
96poll_drive_ready=${poll_drive_ready:-'3'} # default: three seconds
97initial_poll_delay=${initial_poll_delay:-'0'} # default: zero zeconds
98max_drive_wait=${max_drive_wait:-'120'} # default: two minutes
99
100tapedev=`amgetconf $CONFIG tapedev 2>/dev/null`
101if [ -z "$tapedev" ]; then
102 die "tapedev may not be empty"
103fi
104
105changerdev=`amgetconf $CONFIG changerdev 2>/dev/null`
106if [ -z "$changerdev" ]; then
107 die "changerdev may not be empty"
108elif [ $changerdev = "/dev/null" ]; then
109 die "changerdev ($changerdev) may not be the null device"
110fi
111
112####
113# Create the chg-robot config
114
115# note that cleaning is not supported by chg-robot, so the cleaning parameters are
116# not converted.
117
118showbool() {
119 if test "$1" -ne 0; then
120 echo 'yes'
121 else
122 echo 'no'
123 fi
124}
125
126echo "Remove the following parameters, if present, from your amanda.conf:"
127echo " tpchanger changerfile changerdev tapedev"
128echo ""
129echo "Add the following to amanda.conf (you may want to use a more descriptive name for the changer):"
130echo ""
131echo "tapedev \"converted-from-chg-zd-mtx\""
132echo "define changer \"converted-from-chg-zd-mtx\" {"
133echo " tpchanger \"chg-robot:$changerdev\""
134echo " changerfile \"$changerfile-state\""
135echo " property \"tape-device\" \"$driveslot=$tapedev\""
136echo " property \"eject-before-unload\" \""`showbool $offline_before_unload`"\""
137if test $firstslot -ge 0 && test $lastslot -ge 0; then
138 echo " property \"use-slots\" \"$firstslot-$lastslot\""
139elif test $firstslot -ge 0 || test $lastslot -ge 0; then
140 echo " # you may want to set the USE-SLOTS property appropriately"
141fi
142if test "${unloadpause:-0}" -gt 0; then
143 echo " property \"eject-delay\" \"$unloadpause s\""
144fi
145if test $havereader -eq 0; then
146 echo " property \"fast-search\" \"no\""
147 echo " property \"ignore-barcodes\" \"yes\""
148fi
149echo " property \"load-poll\" \"$initial_poll_delay s poll $poll_drive_ready s until $max_drive_wait s\""
150echo "}"
151echo ""
152
153####
154# and offer suggestions for loading metadata, if slotinfofile is set
155
156if 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."
160else
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\""
164 done
165fi
This page took 0.051227 seconds and 4 git commands to generate.