]> git.sur5r.net Git - bacula/bacula/commitdiff
Fix bug #1937 OpenBSD autochanger example script
authorMarco van Wieringen <mvw@planets.elm.net>
Fri, 5 Oct 2012 14:31:39 +0000 (16:31 +0200)
committerKern Sibbald <kern@sibbald.com>
Sat, 20 Apr 2013 12:51:00 +0000 (14:51 +0200)
Make the OpenBSD autochanger script cope with a non fully load
autochanger.

Imported patch in bug report 1937.

bacula/examples/autochangers/chio-changer-openbsd

index d5e83b96f27aa9c16ff91efec0102b3647c4ae6b..fa150fbbb43933802d7f3906f7f2d827759990da 100644 (file)
@@ -95,7 +95,7 @@ case ${cmd} in
        list)
                ${CHIO} -f ${ctl} status -v slot | \
                        sed -ne 's/^slot *\([0-9]*:\).*FULL.*voltag.*<\(.*\):.*/\1\2/p' | \
-                       awk -F: '{print $1 + 1 ":" $2 }'
+                       awk -F: '{ print $1 + 1 ":" $2 }'
                exit $?
                ;;
 
@@ -105,10 +105,13 @@ case ${cmd} in
                ;;
 
        loaded)
-               local _slot=`${CHIO} -f ${ctl} status -v | egrep '^slot.*<ACCESS> voltag: <:[0-9]>$' | awk '{ print $2 }' | awk -F: '{ print $1 + 1 }'`
-               [ -z "${_slot}" ] && _slot=0
-               echo ${_slot}
-               exit $?
+               # XXX output the first empty slot if the drive is loaded
+               _slot=`${CHIO} -f ${ctl} status -v | egrep '^slot.*<ACCESS> voltag: <:[0-9]>$' | awk '{ print $2 }' | awk -F: '{ print $1 + 1 }'`
+               rtn=$?
+               _loaded=`${CHIO} -f ${ctl} status -v | egrep "^drive ${drive}: <ACCESS,FULL> voltag: <.*:[0-9]>"`
+               [ -z "${_slot}" -o -z "${_loaded}" ] && _slot=0
+               echo ${_slot} | awk '{ print $1 }'
+               exit ${rtn}
                ;;
        slots)
                ${CHIO} -f ${ctl} params | awk "/slots/{print \$2}"