From: Marco van Wieringen Date: Fri, 5 Oct 2012 14:31:39 +0000 (+0200) Subject: Fix bug #1937 OpenBSD autochanger example script X-Git-Tag: Release-5.2.13~94 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=dc6815cafdcb14f44d1ce1b8f9977e617f44e614;p=bacula%2Fbacula Fix bug #1937 OpenBSD autochanger example script Make the OpenBSD autochanger script cope with a non fully load autochanger. Imported patch in bug report 1937. --- diff --git a/bacula/examples/autochangers/chio-changer-openbsd b/bacula/examples/autochangers/chio-changer-openbsd index d5e83b96f2..fa150fbbb4 100644 --- a/bacula/examples/autochangers/chio-changer-openbsd +++ b/bacula/examples/autochangers/chio-changer-openbsd @@ -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.* 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.* voltag: <:[0-9]>$' | awk '{ print $2 }' | awk -F: '{ print $1 + 1 }'` + rtn=$? + _loaded=`${CHIO} -f ${ctl} status -v | egrep "^drive ${drive}: 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}"