pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/sysutils/bacula Added support for chio(1) to manipulat...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/57f93145f498
branches:  trunk
changeset: 550774:57f93145f498
user:      adam <adam%pkgsrc.org@localhost>
date:      Fri Nov 28 20:24:05 2008 +0000

description:
Added support for chio(1) to manipulate an autochanger on NetBSD

diffstat:

 sysutils/bacula/Makefile           |   5 +-
 sysutils/bacula/PLIST.common       |   3 +-
 sysutils/bacula/files/chio-changer |  84 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 90 insertions(+), 2 deletions(-)

diffs (123 lines):

diff -r 8aa1cad5e4f0 -r 57f93145f498 sysutils/bacula/Makefile
--- a/sysutils/bacula/Makefile  Fri Nov 28 18:22:45 2008 +0000
+++ b/sysutils/bacula/Makefile  Fri Nov 28 20:24:05 2008 +0000
@@ -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 @@
 
 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 -r 8aa1cad5e4f0 -r 57f93145f498 sysutils/bacula/PLIST.common
--- a/sysutils/bacula/PLIST.common      Fri Nov 28 18:22:45 2008 +0000
+++ b/sysutils/bacula/PLIST.common      Fri Nov 28 20:24:05 2008 +0000
@@ -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/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 -r 8aa1cad5e4f0 -r 57f93145f498 sysutils/bacula/files/chio-changer
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sysutils/bacula/files/chio-changer        Fri Nov 28 20:24:05 2008 +0000
@@ -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



Home | Main Index | Thread Index | Old Index