From 258b79c08dc70e02310a3854a0cfd6b74644690c Mon Sep 17 00:00:00 2001 From: Marco van Wieringen Date: Fri, 5 Oct 2012 16:31:39 +0200 Subject: [PATCH] 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. --- bacula/examples/autochangers/chio-changer-openbsd | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) 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}" -- 2.39.5