diff options
author | adam <adam@pkgsrc.org> | 2008-11-28 20:24:05 +0000 |
---|---|---|
committer | adam <adam@pkgsrc.org> | 2008-11-28 20:24:05 +0000 |
commit | 0ff53a18800534841df321c1f7b6b16fc69818d2 (patch) | |
tree | 67a0b9b90038d0d28fb69306ae70fa6ee6803d5a | |
parent | 88830b8410498f8767d7ed71caba2cc4e15604b6 (diff) | |
download | pkgsrc-0ff53a18800534841df321c1f7b6b16fc69818d2.tar.gz |
Added support for chio(1) to manipulate an autochanger on NetBSD
-rw-r--r-- | sysutils/bacula/Makefile | 5 | ||||
-rw-r--r-- | sysutils/bacula/PLIST.common | 3 | ||||
-rwxr-xr-x | sysutils/bacula/files/chio-changer | 84 |
3 files changed, 90 insertions, 2 deletions
diff --git a/sysutils/bacula/Makefile b/sysutils/bacula/Makefile index 291c6bd9561..3cd7a8e011e 100644 --- a/sysutils/bacula/Makefile +++ b/sysutils/bacula/Makefile @@ -1,4 +1,6 @@ -# $NetBSD: Makefile,v 1.28 2008/11/21 14:09:30 adam Exp $ +# $NetBSD: Makefile,v 1.29 2008/11/28 20:24:05 adam Exp $ + +PKGREVISION= 1 CONFLICTS+= bacula-client-[0-9]* bacula-clientonly-[0-9]* @@ -37,5 +39,6 @@ PLIST_SRC+= PLIST.common_end post-install: ${INSTALL_DATA} ${WRKSRC}/scripts/dvd-handler ${DESTDIR}${EXAMPLESDIR} + ${INSTALL_DATA} ${FILESDIR}/chio-changer ${DESTDIR}${PREFIX}/libexec/bacula/ .include "../../mk/bsd.pkg.mk" diff --git a/sysutils/bacula/PLIST.common b/sysutils/bacula/PLIST.common index 5cc0295c2d1..b38bb7eff11 100644 --- a/sysutils/bacula/PLIST.common +++ b/sysutils/bacula/PLIST.common @@ -1,4 +1,4 @@ -@comment $NetBSD: PLIST.common,v 1.6 2008/07/10 13:54:56 dmcmahill Exp $ +@comment $NetBSD: PLIST.common,v 1.7 2008/11/28 20:24:05 adam Exp $ libexec/bacula/bacula libexec/bacula/bacula-ctl-dir libexec/bacula/bacula-ctl-fd @@ -6,6 +6,7 @@ libexec/bacula/bacula-ctl-sd libexec/bacula/bconsole libexec/bacula/btraceback.dbx libexec/bacula/btraceback.gdb +libexec/bacula/chio-changer libexec/bacula/disk-changer libexec/bacula/gconsole libexec/bacula/mtx-changer diff --git a/sysutils/bacula/files/chio-changer b/sysutils/bacula/files/chio-changer new file mode 100755 index 00000000000..d477daa0a4f --- /dev/null +++ b/sysutils/bacula/files/chio-changer @@ -0,0 +1,84 @@ +#!/bin/sh +# +# Bacula interface to chio autoloader +# +# If you set in your Device resource +# +# Changer Command = "path-to-this-script/chio-changer %c %o %S %a %d" +# you will have the following input to this script: +# +# So Bacula will always call with all the following arguments, even though +# in come cases, not all are used. +# +# chio-changer "changer-device" "command" "slot" "archive-device" "drive-index" +# $1 $2 $3 $4 $5 +# +# N.B. If you change the script, take care to return either +# the chio exit code or a 0. If the script exits with a non-zero +# exit code, Bacula will assume the request failed. + +CHIO=/bin/chio + +# check parameter count on commandline +check_parm_count() { + pCount=$1 + pCountNeed=$2 + if test $pCount -lt $pCountNeed; then + echo "usage: chio-changer ctl-device command [slot archive-device drive-index]" + echo " Insufficient number of arguments given." + if test $pCount -lt 2; then + echo " Mimimum usage is first two arguments ..." + else + echo " Command expected $pCountNeed arguments" + fi + exit 1 + fi +} + +# Check for special cases where only 2 arguments are needed, +# all others are a minimum of 5 +case $2 in + list) + check_parm_count $# 2 + ;; + slots) + check_parm_count $# 2 + ;; + *) + check_parm_count $# 5 + ;; +esac + + +# Setup arguments +ctl=$1 +cmd="$2" +slot=$3 +device=$4 +drive=$5 + +case $cmd in + unload) + ${CHIO} -f $ctl move drive $drive slot $slot + ;; + + load) + ${CHIO} -f $ctl move slot $slot drive $drive + ;; + + list) + ${CHIO} -f $ctl status slot voltags | awk "/</ { slot=\$2 }\ + /Primary volume tag:/ { tag=\$4 }\ + /From:/ { print slot tag }" + ;; + + loaded) + ${CHIO} -f $ctl status drive $drive | awk "BEGIN { from=0 }\ + /From:/{ from=\$3 }\ + END { print from }" + ;; + + slots) + ${CHIO} -f $ctl params | awk "/slots/{print \$2}" + ;; +esac |