5 # This assumes we have rait-striped drives in several
6 # other amanda changer configs.
8 # so we have a changerfile that lists other changers and
11 # tpchanger_1="chg-mtx"
12 # changerdev_1="/dev/mtx1"
13 # changerfile_1="/some/file1"
14 # tapedev_1="/some/dev"
15 # tpchanger_2="chg-mtx"
16 # changerdev_2="/dev/mtx2"
17 # changerfile_2="/some/file2"
18 # tapedev_2="/some/dev"
19 # tpchanger_3="chg-mtx"
20 # changerdev_3="/dev/mtx3"
21 # changerfile_3="/some/file3"
22 # tapedev_3="/some/dev"
24 # the tapedev_n entries are only needed if the changer script in question
29 exec_prefix="@exec_prefix@"
31 amlibexecdir="@amlibexecdir@"
32 . "${amlibexecdir}/amanda-sh-lib.sh"
34 # add sbin and ucb dirs
35 PATH="$PATH:/usr/sbin:/sbin:/usr/ucb"
41 if [ -d "@AMANDA_DBGDIR@" ]; then
42 DBGFILE=@AMANDA_DBGDIR@/rait-changer.debug
43 KIDDEBUG=@AMANDA_DBGDIR@/changer.debug
44 WORK=@AMANDA_DBGDIR@/chgwork$$
52 echo `_ "arguments: "` $0 $* >&2
55 USE_VERSION_SUFFIXES="@USE_VERSION_SUFFIXES@"
56 if test "$USE_VERSION_SUFFIXES" = "yes"; then
61 getconf=$sbindir/amgetconf$SUF
64 changerfile=`$getconf changerfile`
68 # get config items that other changers use to put in our
69 # fake amanda.conf files.
72 mailto=`$getconf mailto`
75 # make a working directory (with amanda.conf) for each changer, and start the
76 # changer script in background for each one
80 while [ $i -le $nchangers ]
82 eval tpchanger=\$tpchanger_$i
83 eval changerdev=\$changerdev_$i
84 eval changerfile=\$changerfile_$i
85 eval tapedev=\$tapedev_$i
90 cat >> amanda.conf <<EOF
93 tpchanger "$tpchanger"
94 changerdev "$changerdev"
95 changerfile "$changerfile"
98 define tapetype EXABYTE {
99 comment "default tapetype"
109 ) > stdout 2>stderr &
117 # once they've all finished, collect up the results
128 x-slot|x-reset|x-eject|x-search|x-label)
131 # read slot number and device from each
132 # slot numbers must match(?!), and is our resulting slot number
133 # resulting device is {dev1,dev2,...} from each one
136 while [ $i -le $nchangers ]
138 read exitcode < $WORK/$i/exitcode
139 read n dev < $WORK/$i/stdout
140 echo -------------- >&2
141 cat $WORK/$i/stderr >&2
143 echo -------------- >&2
145 if [ "$exitcode" != 0 ]
157 echo `_ 'stackers are out of synch, issue a reset'` >&2
159 mydev="$mydev$mysep$dev"
169 # read info from each
170 # slot numbers must match(?!), and is our resulting slot number
171 # minimum max slots is our resulting max slots
172 # if any can't go backwards, the aggregate can't either
175 while [ $i -le $nchangers ]
177 read exitcode < $WORK/$i/exitcode
178 read n max flag < $WORK/$i/stdout
179 echo -------------- >&2
180 cat $WORK/$i/stderr >&2
182 echo -------------- >&2
184 if [ "$exitcode" != 0 ]
196 echo `_ 'stackers are out of synch, issue a -reset'` >&2
198 if [ $max -lt $mymax ]
208 echo $myslot $mymax $myflag
213 # clean up work directories