Index: head/sysutils/bareos-client/Makefile =================================================================== --- head/sysutils/bareos-client/Makefile (revision 470318) +++ head/sysutils/bareos-client/Makefile (revision 470319) @@ -1,22 +1,22 @@ -# Created by: Alonso Cardenas # $FreeBSD$ PORTNAME= bareos -PORTREVISION= 0 +PORTREVISION= 1 PKGNAMESUFFIX= -client COMMENT= Backup archiving recovery open sourced (client) BROKEN_aarch64= Fails to link: missing sbrk +CONFLICTS= bareos16-client-* + WITH_CLIENT_ONLY=yes USE_RC_SUBR= bareos-fd PLIST= ${PKGDIR}/pkg-plist.client MASTERDIR= ${.CURDIR}/../../sysutils/bareos-server OPTIONS_DEFINE= NLS PYTHON LMDB SCSICRYPTO -OPTIONS_DEFAULT=# LMDB_DESC= Enable build of LMDB support .include "${MASTERDIR}/Makefile" Index: head/sysutils/bareos-client-static/Makefile =================================================================== --- head/sysutils/bareos-client-static/Makefile (revision 470318) +++ head/sysutils/bareos-client-static/Makefile (revision 470319) @@ -1,30 +1,30 @@ -# Created by: Alonso Cardenas # $FreeBSD$ PORTNAME= bareos -PORTREVISION= 0 +PORTREVISION= 1 PKGNAMESUFFIX= -client-static COMMENT= Backup archiving recovery open sourced (static client) +CONFLICTS= bareos16-client-static-* + PLIST= ${.CURDIR}/pkg-plist MASTERDIR= ${.CURDIR}/../../sysutils/bareos-server PLIST_FILES= sbin/bareos-fd-static \ sbin/bconsole-static OPTIONS_DEFINE= NLS LMDB -OPTIONS_DEFAULT=# LMDB_DESC= Enable build of LMDB support CONFIGURE_ARGS+= --enable-client-only \ --enable-static-fd \ --enable-static-cons \ --disable-libtool \ --disable-build-dird \ --disable-build-stored \ --with-jansson=${LOCALBASE} BROKEN_aarch64= Fails to link: missing sbrk .include "${MASTERDIR}/Makefile" Index: head/sysutils/bareos-docs/Makefile =================================================================== --- head/sysutils/bareos-docs/Makefile (revision 470318) +++ head/sysutils/bareos-docs/Makefile (revision 470319) @@ -1,26 +1,25 @@ -# Created by: Alonso CArdenas # $FreeBSD$ PORTNAME= bareos PORTVERSION= 17.2.5 CATEGORIES= sysutils MASTER_SITES= http://doc.bareos.org/master/ PKGNAMESUFFIX= -docs DISTFILES= ${PORTNAME}-manual-main-reference.pdf MAINTAINER= acm@FreeBSD.org COMMENT= Bareos document set (PDF) NO_BUILD= yes PORTDOCS= *.pdf do-extract: ${MKDIR} ${WRKSRC} ${CP} ${DISTDIR}/${PORTNAME}-manual-main-reference.pdf ${WRKSRC} do-install: ${MKDIR} ${STAGEDIR}${DOCSDIR} ${INSTALL_DATA} ${WRKSRC}/${PORTNAME}-manual-main-reference.pdf ${STAGEDIR}${DOCSDIR} .include Index: head/sysutils/bareos-server/Makefile =================================================================== --- head/sysutils/bareos-server/Makefile (revision 470318) +++ head/sysutils/bareos-server/Makefile (revision 470319) @@ -1,229 +1,236 @@ -# Created by: Alonso Cardenas # $FreeBSD$ PORTNAME= bareos DISTVERSIONPREFIX= Release/ DISTVERSION= 17.2.5 -PORTREVISION?= 0 +PORTREVISION?= 1 CATEGORIES?= sysutils PKGNAMEPREFIX?= # PKGNAMESUFFIX?= -server MAINTAINER= acm@FreeBSD.org COMMENT?= Backup archiving recovery open sourced (server) LICENSE= AGPLv3 LGPL3 LICENSE_COMB= multi USE_GITHUB= yes USES+= libtool:keepla pkgconfig readline:port shebangfix -CONFLICTS?= bacula*-server-* +CONFLICTS?= bacula*-server-* bareos16-server-* LIB_DEPENDS+= liblzo2.so:archivers/lzo2 \ libjansson.so:devel/jansson USERS= bareos GROUPS= ${USERS} PLIST_SUB+= LIB_VERSION=${PORTVERSION} GNU_CONFIGURE= yes USE_LDCONFIG= yes SHEBANG_LANG= perl SHEBANG_FILES= ${WRKSRC}/src/cats/make_catalog_backup.pl.in CPPFLAGS+= -I${LOCALBASE}/readline -I${LOCALBASE}/include LDFLAGS+= -L${LOCALBASE}/lib -OPTIONS_DEFINE?= MTX PYTHON NDMP NLS OPENSSL SCSICRYPTO -OPTIONS_DEFAULT?= OPENSSL PGSQL SCSICRYPTO +OPTIONS_DEFAULT= OPENSSL +OPTIONS_SINGLE= CRYPTO +OPTIONS_SINGLE_CRYPTO= OPENSSL GNUTLS OPTIONS_SUB= yes +CRYPTO_DESC= Cryptographic library MTX_DESC= Install mtx for control of autochanger devices NDMP_DESC= Enable build of NDMP support SCSICRYPTO_DESC= Build LTO AME crypto plugin .if ${PKGNAMESUFFIX} == "-server" +OPTIONS_DEFINE= MTX PYTHON NDMP NLS SCSICRYPTO +OPTIONS_DEFAULT+= PGSQL SCSICRYPTO OPTIONS_SINGLE_DATABASE= SQLITE3 MYSQL PGSQL -OPTIONS_SINGLE= DATABASE +OPTIONS_SINGLE+= DATABASE DATABASE_DESC= Database support NDMP_CONFIGURE_ON= --enable-ndmp=yes NDMP_CONFIGURE_OFF= --enable-ndmp=no .endif +GNUTLS_CONFIGURE_WITH= gnutls=${LOCALBASE} +GNUTLS_LIB_DEPENDS= libgnutls.so:security/gnutls + OPENSSL_USES= ssl OPENSSL_CONFIGURE_ON= --with-openssl=${OPENSSLBASE} OPENSSL_CONFIGURE_OFF= --with-openssl="no" SCSICRYPTO_CONFIGURE_ON= --enable-scsi-crypto=yes SCSICRYPTO_CONFIGURE_OFF= --enable-scsi-crypto=no .if ${PKGNAMESUFFIX} == "-client" || ${PKGNAMESUFFIX} == "-server" #Till end of the file PYTHON_USES= python PYTHON_CONFIGURE_ON= --with-python=yes PYTHON_CONFIGURE_OFF= --with-python=no PYTHON_PLUGIN= yes .if !defined(WITH_CLIENT_ONLY) LIB_DEPENDS+= libbareos.so:sysutils/bareos-client USE_RC_SUBR?= bareos-dir bareos-sd .endif .if defined(WITH_CLIENT_ONLY) SUB_FILES+= pkg-install.client pkg-deinstall.client pkg-message.client .else SUB_FILES+= pkg-message.server .endif CONFIGURE_ARGS+=--with-tcp-wrappers=/usr/lib \ --enable-libtool \ --enable-smartalloc \ --sysconfdir=${PREFIX}/etc \ --with-working-dir=${BAREOS_DIR} \ --with-scriptdir=${PREFIX}/share/${PORTNAME} \ --with-logdir=/var/log/bareos \ --with-readline=${LOCALBASE} \ --disable-conio \ --enable-batch-insert \ --with-plugindir=${PREFIX}/lib/bareos/plugins \ --with-scriptdir=${PREFIX}/lib/bareos/scripts \ --with-dump-email=root@localhost \ --with-job-email=root@localhost \ --with-db-name=bareos \ --with-sbin-perm=755 \ --with-db-user=bareos \ --with-baseport=9101 \ --with-pid-dir=/var/run/bareos \ --with-jansson=${LOCALBASE} .if defined(WITH_CLIENT_ONLY) LMDB_CONFIGURE_ON= --enable-lmdb=yes LMDB_CONFIGURE_OFF= --enable-lmdb=no LMDB_CFLAGS= -DMDB_DSYNC=O_SYNC CONFIGURE_ARGS+=--with-fd-user=root \ --with-fd-group=wheel .else CONFIGURE_ARGS+=--with-dir-user=${BAREOS_USER} \ --with-dir-group=${BAREOS_GROUP} \ --with-sd-user=${BAREOS_USER} \ --with-sd-group=operator .endif # The user/group IDs below are registered, see # http://www.freebsd.org/doc/en_US.ISO8859-1/books/porters-handbook/book.html#DADS-UID # BAREOS_USER?= bareos BAREOS_GROUP?= ${BAREOS_USER} BAREOS_UID?= 997 BAREOS_GID?= ${BAREOS_UID} BAREOS_DIR?= /var/db/bareos PLIST_SUB+= BAREOS_DIR=${BAREOS_DIR} SUB_LIST= BAREOS_USER=${BAREOS_USER} \ BAREOS_GROUP=${BAREOS_GROUP} \ BAREOS_UID=${BAREOS_UID} \ BAREOS_GID=${BAREOS_GID} \ BAREOS_DIR=${BAREOS_DIR} NLS_USES= gettext NLS_CONFIGURE_ENABLE= nls # Client only or full server version .if defined(WITH_CLIENT_ONLY) CONFFILES= fd CONFIGURE_ARGS+= --enable-client-only PKGDEINSTALL= ${FILESDIR}/pkg-deinstall.client PKGINSTALL= ${FILESDIR}/pkg-install.client .else # Server only Options CONFFILES= sd dir # Server default database MYSQL_CONFIGURE_ON= --with-mysql=yes MYSQL_USE= MYSQL=yes SQLITE3_CONFIGURE_ON= --with-sqlite3=yes SQLITE3_LIB_DEPENDS= libsqlite3.so:databases/sqlite3 PGSQL_CONFIGURE_ON= --with-postgresql=yes PGSQL_USES= pgsql MTX_RUN_DEPENDS= ${LOCALBASE}/sbin/mtx:misc/mtx .include .if ${PORT_OPTIONS:MMYSQL} DBTYPE= mysql SUB_LIST+= REQ_MYSQL=mysql REQ_PGSQL="" .elif ${PORT_OPTIONS:MSQLITE3} DBTYPE= sqlite3 .else DBTYPE= postgresql SUB_LIST+= REQ_MYSQL="" REQ_PGSQL=postgresql .endif PLIST_SUB+= DBTYPE=${DBTYPE} .endif .if defined(WITH_CLIENT_ONLY) MP1+= bconsole.1 MP8+= bareos-fd.8 .else MP8+= bareos.8 bareos-dir.8 bareos-sd.8 bcopy.8 bextract.8 bls.8 bscan.8 \ btape.8 btraceback.8 bareos-dbcheck.8 MP1+= bsmtp.1 bregex.1 bwild.1 bareos-tray-monitor.1 .endif MAKE_ENV+= MAN8="${MP8}" MAN1="${MP1}" post-patch: # This port does not install docs. See bareos-docs for that ${REINPLACE_CMD} -e '/docdir/d' ${WRKSRC}/Makefile.in # Default bconsole.conf is in ${ETCDIR} @${REINPLACE_CMD} -e 's|^MAN8 =|MAN8 ?=|g' -e 's|^MAN1 =|MAN1 ?=|g' ${WRKSRC}/manpages/Makefile.in @${REINPLACE_CMD} -e 's|_NONSHARED||g' ${WRKSRC}/src/filed/Makefile.in .if defined(WITH_CLIENT_ONLY) @${REINPLACE_CMD} -e 's|^\(fd_subdirs = .*\)scripts\(.*\)|\1\2|g' ${WRKSRC}/Makefile.in @${REINPLACE_CMD} -e 's|\(.*$${MKDIR} $${DESTDIR}$${scriptdir}\)|#\1|g' ${WRKSRC}/Makefile.in .else # In server port don't install filed @${REINPLACE_CMD} -e '/^fd_subdirs = /s|src/filed||' -e 's|src/console||' \ -e 's|src/lib||' -e 's|src/findlib||' -e 's|@FD_PLUGIN_DIR@||' ${WRKSRC}/Makefile.in @${REINPLACE_CMD} -e 's|../lib/|$$(LOCALBASE)/lib/|g' -e 's|../findlib/|$$(LOCALBASE)/lib/|g' ${WRKSRC}/src/dird/Makefile.in \ ${WRKSRC}/src/stored/Makefile.in ${WRKSRC}/src/tools/Makefile.in ${WRKSRC}/src/tests/Makefile.in @${REINPLACE_CMD} -e 's|../../lib/|$$(LOCALBASE)/lib/|g' ${WRKSRC}/src/plugins/dird/Makefile.in ${WRKSRC}/src/plugins/stored/Makefile.in @${REINPLACE_CMD} -e 's|fd_plugins.h|filed/fd_plugins.h|g' -e 's|dir_plugins.h|dird/dir_plugins.h|g' -e 's|stored.h|stored/stored.h|g' \ ${WRKSRC}/src/tools/bpluginfo.c + @${REINPLACE_CMD} -e 's|perl|$(LOCALBASE)/bin/perl|g' ${WRKSRC}/scripts/mtx-changer.in .endif post-extract: .if defined(WITH_CLIENT_ONLY) . if defined(PYTHON_PLUGIN) @${MKDIR} ${STAGEDIR}${ETCDIR}/bareos-dir.d/fileset @${MKDIR} ${STAGEDIR}${ETCDIR}/bareos-dir.d/job . endif .endif @${MV} ${WRKSRC}/src/defaultconfigs/bareos-dir.d/fileset/'Windows All Drives.conf' \ ${WRKSRC}/src/defaultconfigs/bareos-dir.d/fileset/'WindowsAllDrives.conf' .if !target(post-install) post-install: .if defined(WITH_CLIENT_ONLY) ${MKDIR} ${STAGEDIR}${ETCDIR}/bconsole.d/ ${MV} ${STAGEDIR}${ETCDIR}/bconsole.conf ${STAGEDIR}${ETCDIR}/bconsole.d/bconsole.conf.sample .else ${INSTALL_SCRIPT} ${FILESDIR}/chio-bareos ${STAGEDIR}${PREFIX}/sbin ${INSTALL_DATA} ${FILESDIR}/bareos-barcodes ${STAGEDIR}${ETCDIR}/bareos-barcodes.sample ${CHMOD} o+x ${STAGEDIR}${PREFIX}/bin/bsmtp ${MV} ${STAGEDIR}${ETCDIR}/mtx-changer.conf ${STAGEDIR}${ETCDIR}/mtx-changer.conf.sample ${MV} ${STAGEDIR}${ETCDIR}/bareos-regress.conf ${STAGEDIR}${ETCDIR}//bareos-regress.conf.sample .endif @${MKDIR} ${STAGEDIR}/var/run/bareos .endif .else .include "${MASTERDIR}/Makefile.common" .endif # -client and -server are defined .include Index: head/sysutils/bareos-server/files/chio-bareos =================================================================== --- head/sysutils/bareos-server/files/chio-bareos (revision 470318) +++ head/sysutils/bareos-server/files/chio-bareos (revision 470319) @@ -1,200 +1,190 @@ #!/bin/sh # -# Bacula interface to FreeBSD chio autoloader command with -# multiple drive support -# (By Lars Köller, lars+bacula@koellers.net, 2004) +# BAREOS interface to tape libraries and autoloaders for FreeBSD +# (by Rudolf Cejka , v1.2, 2012/11/14) # -# If you set in your Device resource +# 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: +# chio-changer "changer-device" "command" "slot" "tape-device" "drive-index" +# $1 $2 $3 $4 $5 +# for example (on a FreeBSD system): +# chio-changer /dev/ch0 load 1 /dev/nsa0 0 # -# Changer Command = "path-to-this-script/chio-bacula" %c %o %S %a -# you will have the following input to this script: +# 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, BAREOS +# will assume the request failed. # -# chio-bacula "changer-device" "command" "slot" "archive-device" "drive-index" -# $1 $2 $3 $4 $5 -# for example: -# -# chio-bacula /dev/sg0 load 1 /dev/nst0 0 (on a FreeBSD system) -# -# If you need to to an offline, refer to the drive as $4 -# e.g. mt -f $f offline -# -# Many changers need an offline after the unload. Also many -# changers need a sleep 60 after the mtx load. -# -# N.B. If you change the script, take care to return either -# the mtx exit code or a 0. If the script exits with a non-zero -# exit code, Bacula will assume the request failed. -# -me=$(basename $0) -# Debug output, take care this file is writeable for user bacula! -#LOG=/var/db/bacula/chio-bacula.log -#exec 2>>$LOG -#echo "------------------------- $(date) Start $(basename $0) -------------------------" >> $LOG -#set -x +PROGNAME=`basename $0` -# Debug -logger -p user.err "$me $@" +# Uncomment the following line, if you want to log debug output. +#DEBUG=/var/run/bareos/${PROGNAME}.log -# This simulates a barcode reader in the changer. -# The labes of the virtual barcode reader are located in the BARCODE_FILE -SIMULATE_BARCODE=true -BARCODE_FILE=/usr/local/etc/bacula/bacula-barcodes -MTX=/bin/chio -# Set default values (see case statement below for -# free mapping of drive index and tape device -# We have a double drive Qualstar where drive 1 is the default bacula drive -#TAPE=/dev/bacula-tape -TAPE=/dev/nrsa0 -DRIVE=0 -# Time to wait for (un)loading -SLEEP=20 +# Uncomment the following line, if you need to eject a tape before moving +# it from the drive. +#OFFLINE=yes +# Uncomment one or more of the following lines, if you need to wait for +# some time (in seconds) after unloading, loading or transferring a tape. +#OFFLINE_SLEEP=10 +#LOAD_SLEEP=10 +#MOVE_SLEEP=10 + +# Uncomment the following line, if you do not have a changer with volume +# reader. +#FAKE_BARCODES=/usr/local/etc/bareos-barcodes + usage() { - echo "" - echo "The $me script for bacula" - echo "--------------------------------------" - echo "" - echo "usage: $me [slot] [devicename of tapedrive] [drive index]" - echo "" - echo "Valid commands:" - echo "" - echo "unload Unloads a tape into the slot" - echo " from where it was loaded." - echo "load Loads a tape from the slot " - echo " (slot-base is calculated to 1 as first slot)" - echo "list Lists full storage slots" - echo "loaded Gives slot from where the tape was loaded." - echo " 0 means the tape drive is empty." - echo "slots Gives Number of aviable slots." - echo "" - echo "Example:" - echo " $me /dev/changer load 1 loads a tape from slot 1" - echo "" - exit 2 -} + cat < [slot] [tape-device] [drive-index] -# The changer device -if [ -z "$1" ] ; then - usage; -else - CHANGER=$1 -fi -# The command -if [ -z "$2" ] ; then - usage; -else - COMMAND=$2 -fi -# The slot number -if [ ! -z "$3" ]; then - SLOT=$3 - # btape fill says "... slot 1 drive 0" :-( - if [ "$SLOT" = "slot" ]; then - shift - SLOT=$3 - fi -fi -# Set tape device -if [ ! -z "$4" ]; then - TAPE=$4 -fi +Commands (): + unload Unload a tape into the slot from where it was loaded + load Load a tape from the slot (1-based) + transfer Transfer a tape from the slot to + the slot (1-based) + list List full storage slots + listall List all storage slots and drives with source information + loaded Give slot from where the tape was loaded (0 = empty drive) + slots Give number of available slots -# Here you can map bacula drive number to any tape device -# DRIVE is the chio drive number used below by chio! -case $5 in - 0) - # First Drive in Changer is Bacula drive - DRIVE=0 - #TAPE=/dev/bacula-tape - TAPE=/dev/nrsa0 - ;; - 1) - DRIVE=1 - #TAPE=/dev/bacula-tape2 - TAPE=/dev/nrsa1 - ;; -esac +Example: + ${PROGNAME} /dev/ch0 load 1 Load a tape from the slot 1 -# -# Main -# -case ${COMMAND} in - unload) - # enable the following line if you need to eject the cartridge - mt -f ${TAPE} off - sleep 2 - # if we have a slot, try it - if [ ! -z "$SLOT" ]; then - ${MTX} -f ${CHANGER} move drive ${DRIVE} slot $((${SLOT}-1)) - exit $? - fi - # Try other way (works if source element information is valid for drive) - ${MTX} -f ${CHANGER} return drive ${DRIVE} - # If the changer is power cycled with a tape loaded in a drive - # we can compute the slot in case of a complete filled magazine, with - # one slot free. - if [ "$?" != "0" ]; then - free_slot=`${MTX} -f ${CHANGER} stat | grep "^slot " | grep -v "FULL" | awk '{print $2}'` - free_slot=${free_slot%:} - ${MTX} -f ${CHANGER} move drive ${DRIVE} slot $free_slot - fi - ;; +EOF + exit 1 +} - load) - ${MTX} -f ${CHANGER} move slot $((${SLOT}-1)) drive ${DRIVE} - rtn=$? - # Increase the sleep time if you have a slow device - sleep $SLEEP - exit $rtn - ;; +# Default settings +CHANGER=/dev/ch0 +TAPE=/dev/nsa0 +DRIVE=0 - list) - if [ "${SIMULATE_BARCODE}" = "true" ]; then - if [ -f "$BARCODE_FILE" ]; then - cat $BARCODE_FILE | grep -v -e "^#" -e "^$" - exit 0 - else - echo "Barcode file $BARCODE_FILE missing ... exiting!" - exit 1 - fi - else - ${MTX} -f ${CHANGER} status | grep "^slot .*: .*FULL>" | awk '{print $2}' | awk -F: '{print $1+1" "}' | tr -d "[\r\n]" - fi - ;; +CHIO=/bin/chio +MT=/usr/bin/mt - loaded) - # echo "Request loaded" - ${MTX} -f ${CHANGER} status -S > /tmp/mtx.$$ - rtn=$? - # Try to get chio slot source from drive entry - SLOT=$(cat /tmp/mtx.$$ | grep "^drive ${DRIVE}: .*slot" | awk '{print $6+1}' | tr -d ">") - if [ -z "$SLOT" ]; then - # This handles the case a source slot is not available (power on - # of the changer with a drive loaded) and all other slots are - # occupied with a tape! - SLOT=$(cat /tmp/mtx.$$ | grep "^slot .*: " | awk '{print $2+1}') - if [ -z "$SLOT" ]; then - echo 0 - else - echo $SLOT - fi - else - echo $SLOT - fi - # All tapes are in the slots - #cat /tmp/mtx.$$ | grep "^drive ${DRIVE}: .* source: <>" | awk "{print 0}" - rm -f /tmp/mtx.$$ - exit $rtn - ;; +if [ -n "${DEBUG}" ]; then + MSG=$0 + for PAR; do MSG="${MSG} \"${PAR}\""; done + echo `date +"%Y/%m/%d %H:%M:%S"` ${MSG} >> ${DEBUG} +fi - slots) - # echo "Request slots" - ${MTX} -f ${CHANGER} status | grep "^slot " | tail -1 | awk '{print $2+1}' | tr -d ":" - ;; +if [ -n "$1" ]; then + CHANGER=$1; +fi +COMMAND=$2 +SLOT=$3 +SLOTDST=$4 +if [ -n "$4" ]; then + TAPE=$4 +fi +if [ -n "$5" ]; then + DRIVE=$5 +fi - *) - usage - ;; +case ${COMMAND} in +unload) + if [ "${OFFLINE}" = yes ]; then + ${MT} -f ${TAPE} offline + if [ $? = 0 -a -n "${OFFLINE_SLEEP}" ]; then + sleep ${OFFLINE_SLEEP} + fi + fi + if [ -z "${SLOT}" ]; then + ${CHIO} -f ${CHANGER} return drive ${DRIVE} + else + ${CHIO} -f ${CHANGER} move drive ${DRIVE} slot $((${SLOT} - 1)) + fi + if [ $? -ne 0 ]; then + # In case of an error, try to unload the cartridge to the first free slot + FREE=`${CHIO} -f ${CHANGER} status slot | \ + sed -ne '/FULL/d;s/^slot *\([0-9]*\):.*/\1/p' | \ + awk 'BEGIN { n = 0 } { n = $1 + 1; exit } END { print n }'` + if [ ${FREE} -gt 0 ]; then + ${CHIO} -f ${CHANGER} move drive ${DRIVE} slot $((${FREE} - 1)) + else + exit 1 + fi + fi + ;; +load) + if [ -z "${SLOT}" ]; then + usage + fi + ${CHIO} -f ${CHANGER} move slot $((${SLOT} - 1)) drive ${DRIVE} + if [ $? -ne 0 ]; then + exit 1 + fi + if [ -n "${LOAD_SLEEP}" ]; then + sleep ${LOAD_SLEEP} + fi + ;; +transfer) + if [ -z "${SLOT}" -o -z "${SLOTDST}" ]; then + usage + fi + ${CHIO} -f ${CHANGER} move slot $((${SLOT} - 1)) slot $((${SLOTDST} - 1)) + if [ $? -ne 0 ]; then + exit 1 + fi + if [ -n "${MOVE_SLEEP}" ]; then + sleep ${MOVE_SLEEP} + fi + ;; +list) + if [ -z "${FAKE_BARCODES}" ]; then + ${CHIO} -f ${CHANGER} status -v slot | \ + sed -ne 's/^slot *\([0-9]*\):.*FULL.*voltag.*<\([^:]*\):.*/\1:\2/p' | \ + awk -F: '{ print $1 + 1 ":" $2 }' + else + if [ -f "${FAKE_BARCODES}" ]; then + grep -v -e "^#" -e "^$" < ${FAKE_BARCODES} + else + echo "${PROGNAME}: Barcode file ${FAKE_BARCODES} is missing" + exit 1 + fi + fi + ;; +listall) + if [ -z "${FAKE_BARCODES}" ]; then + ${CHIO} -f ${CHANGER} status -vS | \ + sed -ne ' + s/^slot *\([0-9]*\):.*ENAB.*FULL.*voltag.*<\([^:]*\):.*/I:\1:F:\2/p;t + s/^slot *\([0-9]*\):.*FULL.*voltag.*<\([^:]*\):.*/S:\1:F:\2/p;t + s/^drive *\([0-9]*\):.*FULL.*voltag.*<\([^:]*\):.*source.*<[^0-9]*\([0-9]*\)>.*/D:\1:F:\3:\2/p;t + s/^slot *\([0-9]*\):.*ENAB.*voltag.*<\([^:]*\):.*/I:\1:E/p;t + s/^slot *\([0-9]*\):.*voltag.*<\([^:]*\):.*/S:\1:E/p;t + s/^drive *\([0-9]*\):.*voltag.*<\([^:]*\):.*/D:\1:E/p' | \ + awk -F: '{ for (n = 1; n <= NF; n++) printf "%s%s", + (n == ($1 == "D" ? 4 : 2)) ? ($n == "" ? 0 : $n + 1) : $n, + (n == NF) ? "\n" : ":" }' + else + if [ -f "${FAKE_BARCODES}" ]; then + grep -v -e "^#" -e "^$" < ${FAKE_BARCODES} | \ + awk -F: '{ print "S:" $1 (match($2, "^ *$") ? ":E" : ":F:" $2) }' + else + echo "${PROGNAME}: Barcode file ${FAKE_BARCODES} is missing" + exit 1 + fi + fi + ;; +loaded) + # If a tape is loaded, but the source slot is unknown (for example, + # after library reboot), try to report the first free slot + FREE=`${CHIO} -f ${CHANGER} status slot | \ + sed -ne '/FULL/d;s/^slot *\([0-9]*\):.*/\1/p' | \ + awk 'BEGIN { n = 0 } { n = $1 + 1; exit } END { print n }'` + ${CHIO} -f ${CHANGER} status -S drive | \ + sed -ne 's/^drive *'${DRIVE}':.*FULL.*source.*<[^0-9]*\([0-9]*\)>.*/\1/p' \ + | awk 'BEGIN { n = 0 } { n = ($1 == "") ? '${FREE}' : $1 + 1 } \ + END { print n }' + ;; +slots) + ${CHIO} -f ${CHANGER} status | grep -c "^slot " + ;; +*) + usage + ;; esac Index: head/sysutils/bareos-traymonitor/Makefile =================================================================== --- head/sysutils/bareos-traymonitor/Makefile (revision 470318) +++ head/sysutils/bareos-traymonitor/Makefile (revision 470319) @@ -1,36 +1,32 @@ -# Created by: Alonso Cardenas Marquez # $FreeBSD$ PORTNAME= bareos PKGNAMESUFFIX= -traymonitor -PORTREVISION= 0 +PORTREVISION= 1 COMMENT= Backup archiving recovery open sourced (traymonitor) LIB_DEPENDS+= libqwt.so:x11-toolkits/qwt5 \ libbareos.so:sysutils/bareos-client -CONFLICTS= bacula*-bat-* +CONFLICTS= bacula*-bat-* bareos16-traymonitor-* USES= pkgconfig gettext-runtime desktop-file-utils USE_QT4= qmake_build uic_build moc_build rcc_build gui corelib WITH_BAT= yes PLIST= ${.CURDIR}/pkg-plist MAKE_ENV+= MAKEOBJDIRPREFIX=/ MASTERDIR= ${.CURDIR}/../../sysutils/bareos-server CONFIGURE_ARGS+= --enable-traymonitor=yes \ --with-qwt=${LOCALBASE}/lib \ --disable-build-dird \ --disable-build-stored \ --enable-client-only \ --with-jansson=${LOCALBASE} \ --enable-nls=yes - -OPTIONS_DEFINE= OPENSSL -OPTIONS_DEFAULT=OPENSSL .include "${MASTERDIR}/Makefile" Index: head/sysutils/bareos16-bat/Makefile =================================================================== --- head/sysutils/bareos16-bat/Makefile (revision 470318) +++ head/sysutils/bareos16-bat/Makefile (revision 470319) @@ -1,32 +1,29 @@ # $FreeBSD$ PORTNAME= bareos16 PKGNAMESUFFIX= -bat -PORTREVISION= 0 +PORTREVISION= 1 COMMENT= Backup archiving recovery open sourced (GUI) LIB_DEPENDS+= libqwt.so:x11-toolkits/qwt5 \ libbareos.so:sysutils/bareos16-client -CONFLICTS= bacula*-bat-* bareos-bat-* +CONFLICTS= bacula*-bat-* USES= pkgconfig desktop-file-utils USE_QT4= qmake_build uic_build moc_build rcc_build WITH_BAT= yes PLIST= ${.CURDIR}/pkg-plist MAKE_ENV+= MAKEOBJDIRPREFIX=/ MASTERDIR= ${.CURDIR}/../../sysutils/bareos16-server CONFIGURE_ARGS+= --enable-bat \ --with-qwt=${LOCALBASE}/lib \ --disable-build-dird \ --disable-build-stored \ --enable-client-only - -OPTIONS_DEFINE= OPENSSL -OPTIONS_DEFAULT=OPENSSL .include "${MASTERDIR}/Makefile" Index: head/sysutils/bareos16-client/Makefile =================================================================== --- head/sysutils/bareos16-client/Makefile (revision 470318) +++ head/sysutils/bareos16-client/Makefile (revision 470319) @@ -1,21 +1,22 @@ # $FreeBSD$ PORTNAME= bareos16 -PORTREVISION= 0 +PORTREVISION= 1 PKGNAMESUFFIX= -client COMMENT= Backup archiving recovery open sourced (client) BROKEN_aarch64= Fails to link: missing sbrk +CONFLICTS= bareos-client-* + WITH_CLIENT_ONLY=yes USE_RC_SUBR= bareos-fd PLIST= ${PKGDIR}/pkg-plist.client MASTERDIR= ${.CURDIR}/../../sysutils/bareos16-server OPTIONS_DEFINE= NLS PYTHON LMDB SCSICRYPTO -OPTIONS_DEFAULT=# LMDB_DESC= Enable build of LMDB support .include "${MASTERDIR}/Makefile" Index: head/sysutils/bareos16-client-static/Makefile =================================================================== --- head/sysutils/bareos16-client-static/Makefile (revision 470318) +++ head/sysutils/bareos16-client-static/Makefile (revision 470319) @@ -1,29 +1,30 @@ # $FreeBSD$ PORTNAME= bareos16 -PORTREVISION= 0 +PORTREVISION= 1 PKGNAMESUFFIX= -client-static COMMENT= Backup archiving recovery open sourced (static client) +CONFLICTS= bareos-client-static-* + PLIST= ${.CURDIR}/pkg-plist MASTERDIR= ${.CURDIR}/../../sysutils/bareos16-server PLIST_FILES= sbin/bareos-fd-static \ sbin/bconsole-static OPTIONS_DEFINE= NLS LMDB -OPTIONS_DEFAULT=# LMDB_DESC= Enable build of LMDB support CONFIGURE_ARGS+= --enable-client-only \ --enable-static-fd \ --enable-static-cons \ --disable-libtool \ --disable-build-dird \ --disable-build-stored \ --with-jansson=${LOCALBASE} BROKEN_aarch64= Fails to link: missing sbrk .include "${MASTERDIR}/Makefile" Index: head/sysutils/bareos16-server/Makefile =================================================================== --- head/sysutils/bareos16-server/Makefile (revision 470318) +++ head/sysutils/bareos16-server/Makefile (revision 470319) @@ -1,231 +1,239 @@ # $FreeBSD$ PORTNAME= bareos16 DISTVERSIONPREFIX= Release/ DISTVERSION= 16.2.7 -PORTREVISION?= 0 +PORTREVISION?= 1 CATEGORIES?= sysutils PKGNAMEPREFIX?= # PKGNAMESUFFIX?= -server MAINTAINER= acm@FreeBSD.org COMMENT?= Backup archiving recovery open sourced (server) LICENSE= AGPLv3 LGPL3 LICENSE_COMB= multi USE_GITHUB= yes GH_ACCOUNT= ${PORTNAME:S/16//} GH_PROJECT= ${PORTNAME:S/16//} USES+= libtool:keepla pkgconfig readline:port shebangfix -CONFLICTS?= bacula*-server-* bareos-server* +CONFLICTS?= bacula*-server-* bareos-server-* LIB_DEPENDS+= liblzo2.so:archivers/lzo2 \ libjansson.so:devel/jansson USERS= bareos GROUPS= ${USERS} PLIST_SUB+= LIB_VERSION=${PORTVERSION} GNU_CONFIGURE= yes USE_LDCONFIG= yes SHEBANG_LANG= perl SHEBANG_FILES= ${WRKSRC}/src/cats/make_catalog_backup.pl.in CPPFLAGS+= -I${LOCALBASE}/readline -I${LOCALBASE}/include LDFLAGS+= -L${LOCALBASE}/lib ETCDIR= ${PREFIX}/etc/${PORTNAME:S/16//} -OPTIONS_DEFINE?= MTX PYTHON NDMP NLS OPENSSL SCSICRYPTO -OPTIONS_DEFAULT?= OPENSSL PGSQL SCSICRYPTO +OPTIONS_DEFAULT= OPENSSL +OPTIONS_SINGLE= CRYPTO +OPTIONS_SINGLE_CRYPTO= OPENSSL GNUTLS OPTIONS_SUB= yes +CRYPTO_DESC= Cryptographic library MTX_DESC= Install mtx for control of autochanger devices NDMP_DESC= Enable build of NDMP support SCSICRYPTO_DESC= Build LTO AME crypto plugin .if ${PKGNAMESUFFIX} == "-server" +OPTIONS_DEFINE= MTX PYTHON NDMP NLS SCSICRYPTO +OPTIONS_DEFAULT+= PGSQL SCSICRYPTO OPTIONS_SINGLE_DATABASE= SQLITE3 MYSQL PGSQL -OPTIONS_SINGLE= DATABASE +OPTIONS_SINGLE+= DATABASE DATABASE_DESC= Database support NDMP_CONFIGURE_ON= --enable-ndmp=yes NDMP_CONFIGURE_OFF= --enable-ndmp=no .endif +GNUTLS_CONFIGURE_WITH= gnutls=${LOCALBASE} +GNUTLS_LIB_DEPENDS= libgnutls.so:security/gnutls + OPENSSL_USES= ssl OPENSSL_CONFIGURE_ON= --with-openssl=${OPENSSLBASE} OPENSSL_CONFIGURE_OFF= --with-openssl="no" SCSICRYPTO_CONFIGURE_ON= --enable-scsi-crypto=yes SCSICRYPTO_CONFIGURE_OFF= --enable-scsi-crypto=no .if ${PKGNAMESUFFIX} == "-client" || ${PKGNAMESUFFIX} == "-server" #Till end of the file PYTHON_USES= python PYTHON_CONFIGURE_ON= --with-python=yes PYTHON_CONFIGURE_OFF= --with-python=no PYTHON_PLUGIN= yes .if !defined(WITH_CLIENT_ONLY) LIB_DEPENDS+= libbareos.so:sysutils/bareos16-client USE_RC_SUBR?= bareos-dir bareos-sd .endif .if defined(WITH_CLIENT_ONLY) SUB_FILES+= pkg-install.client pkg-deinstall.client pkg-message.client .else SUB_FILES+= pkg-message.server .endif CONFIGURE_ARGS+=--with-tcp-wrappers=/usr/lib \ --enable-libtool \ --enable-smartalloc \ --sysconfdir=${PREFIX}/etc \ --with-working-dir=${BAREOS_DIR} \ --with-scriptdir=${PREFIX}/share/${PORTNAME} \ --with-logdir=/var/log/bareos \ --with-readline=${LOCALBASE} \ --disable-conio \ --enable-batch-insert \ --with-plugindir=${PREFIX}/lib/bareos/plugins \ --with-scriptdir=${PREFIX}/lib/bareos/scripts \ --with-dump-email=root@localhost \ --with-job-email=root@localhost \ --with-db-name=bareos \ --with-sbin-perm=755 \ --with-db-user=bareos \ --with-baseport=9101 \ --with-pid-dir=/var/run/bareos \ --with-jansson=${LOCALBASE} .if defined(WITH_CLIENT_ONLY) LMDB_CONFIGURE_ON= --enable-lmdb=yes LMDB_CONFIGURE_OFF= --enable-lmdb=no LMDB_CFLAGS= -DMDB_DSYNC=O_SYNC CONFIGURE_ARGS+=--with-fd-user=root \ --with-fd-group=wheel .else CONFIGURE_ARGS+=--with-dir-user=${BAREOS_USER} \ --with-dir-group=${BAREOS_GROUP} \ --with-sd-user=${BAREOS_USER} \ --with-sd-group=operator .endif # The user/group IDs below are registered, see # http://www.freebsd.org/doc/en_US.ISO8859-1/books/porters-handbook/book.html#DADS-UID # BAREOS_USER?= bareos BAREOS_GROUP?= ${BAREOS_USER} BAREOS_UID?= 997 BAREOS_GID?= ${BAREOS_UID} BAREOS_DIR?= /var/db/bareos PLIST_SUB+= BAREOS_DIR=${BAREOS_DIR} SUB_LIST= BAREOS_USER=${BAREOS_USER} \ BAREOS_GROUP=${BAREOS_GROUP} \ BAREOS_UID=${BAREOS_UID} \ BAREOS_GID=${BAREOS_GID} \ BAREOS_DIR=${BAREOS_DIR} NLS_USES= gettext NLS_CONFIGURE_ENABLE= nls # Client only or full server version .if defined(WITH_CLIENT_ONLY) CONFFILES= fd CONFIGURE_ARGS+= --enable-client-only PKGDEINSTALL= ${FILESDIR}/pkg-deinstall.client PKGINSTALL= ${FILESDIR}/pkg-install.client .else # Server only Options CONFFILES= sd dir # Server default database MYSQL_CONFIGURE_ON= --with-mysql=yes MYSQL_USE= MYSQL=yes SQLITE3_CONFIGURE_ON= --with-sqlite3=yes SQLITE3_LIB_DEPENDS= libsqlite3.so:databases/sqlite3 PGSQL_CONFIGURE_ON= --with-postgresql=yes PGSQL_USES= pgsql MTX_RUN_DEPENDS= ${LOCALBASE}/sbin/mtx:misc/mtx .include .if ${PORT_OPTIONS:MMYSQL} DBTYPE= mysql SUB_LIST+= REQ_MYSQL=mysql REQ_PGSQL="" .elif ${PORT_OPTIONS:MSQLITE3} DBTYPE= sqlite3 .else DBTYPE= postgresql SUB_LIST+= REQ_MYSQL="" REQ_PGSQL=postgresql .endif PLIST_SUB+= DBTYPE=${DBTYPE} .endif .if defined(WITH_CLIENT_ONLY) MP1+= bconsole.1 MP8+= bareos-fd.8 .else MP8+= bareos.8 bareos-dir.8 bareos-sd.8 bcopy.8 bextract.8 bls.8 bscan.8 \ btape.8 btraceback.8 bareos-dbcheck.8 MP1+= bsmtp.1 bregex.1 bwild.1 bareos-tray-monitor.1 .endif MAKE_ENV+= MAN8="${MP8}" MAN1="${MP1}" post-patch: # This port does not install docs. See bareos-docs for that ${REINPLACE_CMD} -e '/docdir/d' ${WRKSRC}/Makefile.in # Default bconsole.conf is in ${ETCDIR} @${REINPLACE_CMD} -e 's|^MAN8 =|MAN8 ?=|g' -e 's|^MAN1 =|MAN1 ?=|g' ${WRKSRC}/manpages/Makefile.in @${REINPLACE_CMD} -e 's|_NONSHARED||g' ${WRKSRC}/src/filed/Makefile.in .if defined(WITH_CLIENT_ONLY) @${REINPLACE_CMD} -e 's|^\(fd_subdirs = .*\)scripts\(.*\)|\1\2|g' ${WRKSRC}/Makefile.in @${REINPLACE_CMD} -e 's|\(.*$${MKDIR} $${DESTDIR}$${scriptdir}\)|#\1|g' ${WRKSRC}/Makefile.in .else # In server port don't install filed @${REINPLACE_CMD} -e '/^fd_subdirs = /s|src/filed||' -e 's|src/console||' \ -e 's|src/lib||' -e 's|src/findlib||' -e 's|@FD_PLUGIN_DIR@||' ${WRKSRC}/Makefile.in @${REINPLACE_CMD} -e 's|../lib/|$$(LOCALBASE)/lib/|g' -e 's|../findlib/|$$(LOCALBASE)/lib/|g' ${WRKSRC}/src/dird/Makefile.in \ ${WRKSRC}/src/stored/Makefile.in ${WRKSRC}/src/tools/Makefile.in @${REINPLACE_CMD} -e 's|../../lib/|$$(LOCALBASE)/lib/|g' ${WRKSRC}/src/plugins/dird/Makefile.in ${WRKSRC}/src/plugins/stored/Makefile.in @${REINPLACE_CMD} -e 's|fd_plugins.h|filed/fd_plugins.h|g' -e 's|dir_plugins.h|dird/dir_plugins.h|g' -e 's|stored.h|stored/stored.h|g' \ ${WRKSRC}/src/tools/bpluginfo.c + @${REINPLACE_CMD} -e 's|perl|$(LOCALBASE)/bin/perl|g' ${WRKSRC}/scripts/mtx-changer.in .endif post-extract: .if defined(WITH_CLIENT_ONLY) . if defined(PYTHON_PLUGIN) @${MKDIR} ${STAGEDIR}${ETCDIR}/bareos-dir.d/fileset @${MKDIR} ${STAGEDIR}${ETCDIR}/bareos-dir.d/job . endif .endif @${MV} ${WRKSRC}/src/defaultconfigs/bareos-dir.d/fileset/'Windows All Drives.conf' \ ${WRKSRC}/src/defaultconfigs/bareos-dir.d/fileset/'WindowsAllDrives.conf' .if !target(post-install) post-install: .if defined(WITH_CLIENT_ONLY) ${MKDIR} ${STAGEDIR}${ETCDIR}/bconsole.d/ ${MV} ${STAGEDIR}${ETCDIR}/bconsole.conf ${STAGEDIR}${ETCDIR}/bconsole.d/bconsole.conf.sample .else ${INSTALL_SCRIPT} ${FILESDIR}/chio-bareos ${STAGEDIR}${PREFIX}/sbin ${INSTALL_DATA} ${FILESDIR}/bareos-barcodes ${STAGEDIR}${ETCDIR}/bareos-barcodes.sample ${CHMOD} o+x ${STAGEDIR}${PREFIX}/bin/bsmtp ${MV} ${STAGEDIR}${ETCDIR}/mtx-changer.conf ${STAGEDIR}${ETCDIR}/mtx-changer.conf.sample .endif @${MKDIR} ${STAGEDIR}/var/run/bareos .endif .else .include "${MASTERDIR}/Makefile.common" .endif # -client and -server are defined .include Index: head/sysutils/bareos16-server/files/chio-bareos =================================================================== --- head/sysutils/bareos16-server/files/chio-bareos (revision 470318) +++ head/sysutils/bareos16-server/files/chio-bareos (revision 470319) @@ -1,200 +1,190 @@ #!/bin/sh # -# Bacula interface to FreeBSD chio autoloader command with -# multiple drive support -# (By Lars Köller, lars+bacula@koellers.net, 2004) +# BAREOS interface to tape libraries and autoloaders for FreeBSD +# (by Rudolf Cejka , v1.2, 2012/11/14) # -# If you set in your Device resource +# 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: +# chio-changer "changer-device" "command" "slot" "tape-device" "drive-index" +# $1 $2 $3 $4 $5 +# for example (on a FreeBSD system): +# chio-changer /dev/ch0 load 1 /dev/nsa0 0 # -# Changer Command = "path-to-this-script/chio-bacula" %c %o %S %a -# you will have the following input to this script: +# 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, BAREOS +# will assume the request failed. # -# chio-bacula "changer-device" "command" "slot" "archive-device" "drive-index" -# $1 $2 $3 $4 $5 -# for example: -# -# chio-bacula /dev/sg0 load 1 /dev/nst0 0 (on a FreeBSD system) -# -# If you need to to an offline, refer to the drive as $4 -# e.g. mt -f $f offline -# -# Many changers need an offline after the unload. Also many -# changers need a sleep 60 after the mtx load. -# -# N.B. If you change the script, take care to return either -# the mtx exit code or a 0. If the script exits with a non-zero -# exit code, Bacula will assume the request failed. -# -me=$(basename $0) -# Debug output, take care this file is writeable for user bacula! -#LOG=/var/db/bacula/chio-bacula.log -#exec 2>>$LOG -#echo "------------------------- $(date) Start $(basename $0) -------------------------" >> $LOG -#set -x +PROGNAME=`basename $0` -# Debug -logger -p user.err "$me $@" +# Uncomment the following line, if you want to log debug output. +#DEBUG=/var/run/bareos/${PROGNAME}.log -# This simulates a barcode reader in the changer. -# The labes of the virtual barcode reader are located in the BARCODE_FILE -SIMULATE_BARCODE=true -BARCODE_FILE=/usr/local/etc/bacula/bacula-barcodes -MTX=/bin/chio -# Set default values (see case statement below for -# free mapping of drive index and tape device -# We have a double drive Qualstar where drive 1 is the default bacula drive -#TAPE=/dev/bacula-tape -TAPE=/dev/nrsa0 -DRIVE=0 -# Time to wait for (un)loading -SLEEP=20 +# Uncomment the following line, if you need to eject a tape before moving +# it from the drive. +#OFFLINE=yes +# Uncomment one or more of the following lines, if you need to wait for +# some time (in seconds) after unloading, loading or transferring a tape. +#OFFLINE_SLEEP=10 +#LOAD_SLEEP=10 +#MOVE_SLEEP=10 + +# Uncomment the following line, if you do not have a changer with volume +# reader. +#FAKE_BARCODES=/usr/local/etc/bareos-barcodes + usage() { - echo "" - echo "The $me script for bacula" - echo "--------------------------------------" - echo "" - echo "usage: $me [slot] [devicename of tapedrive] [drive index]" - echo "" - echo "Valid commands:" - echo "" - echo "unload Unloads a tape into the slot" - echo " from where it was loaded." - echo "load Loads a tape from the slot " - echo " (slot-base is calculated to 1 as first slot)" - echo "list Lists full storage slots" - echo "loaded Gives slot from where the tape was loaded." - echo " 0 means the tape drive is empty." - echo "slots Gives Number of aviable slots." - echo "" - echo "Example:" - echo " $me /dev/changer load 1 loads a tape from slot 1" - echo "" - exit 2 -} + cat < [slot] [tape-device] [drive-index] -# The changer device -if [ -z "$1" ] ; then - usage; -else - CHANGER=$1 -fi -# The command -if [ -z "$2" ] ; then - usage; -else - COMMAND=$2 -fi -# The slot number -if [ ! -z "$3" ]; then - SLOT=$3 - # btape fill says "... slot 1 drive 0" :-( - if [ "$SLOT" = "slot" ]; then - shift - SLOT=$3 - fi -fi -# Set tape device -if [ ! -z "$4" ]; then - TAPE=$4 -fi +Commands (): + unload Unload a tape into the slot from where it was loaded + load Load a tape from the slot (1-based) + transfer Transfer a tape from the slot to + the slot (1-based) + list List full storage slots + listall List all storage slots and drives with source information + loaded Give slot from where the tape was loaded (0 = empty drive) + slots Give number of available slots -# Here you can map bacula drive number to any tape device -# DRIVE is the chio drive number used below by chio! -case $5 in - 0) - # First Drive in Changer is Bacula drive - DRIVE=0 - #TAPE=/dev/bacula-tape - TAPE=/dev/nrsa0 - ;; - 1) - DRIVE=1 - #TAPE=/dev/bacula-tape2 - TAPE=/dev/nrsa1 - ;; -esac +Example: + ${PROGNAME} /dev/ch0 load 1 Load a tape from the slot 1 -# -# Main -# -case ${COMMAND} in - unload) - # enable the following line if you need to eject the cartridge - mt -f ${TAPE} off - sleep 2 - # if we have a slot, try it - if [ ! -z "$SLOT" ]; then - ${MTX} -f ${CHANGER} move drive ${DRIVE} slot $((${SLOT}-1)) - exit $? - fi - # Try other way (works if source element information is valid for drive) - ${MTX} -f ${CHANGER} return drive ${DRIVE} - # If the changer is power cycled with a tape loaded in a drive - # we can compute the slot in case of a complete filled magazine, with - # one slot free. - if [ "$?" != "0" ]; then - free_slot=`${MTX} -f ${CHANGER} stat | grep "^slot " | grep -v "FULL" | awk '{print $2}'` - free_slot=${free_slot%:} - ${MTX} -f ${CHANGER} move drive ${DRIVE} slot $free_slot - fi - ;; +EOF + exit 1 +} - load) - ${MTX} -f ${CHANGER} move slot $((${SLOT}-1)) drive ${DRIVE} - rtn=$? - # Increase the sleep time if you have a slow device - sleep $SLEEP - exit $rtn - ;; +# Default settings +CHANGER=/dev/ch0 +TAPE=/dev/nsa0 +DRIVE=0 - list) - if [ "${SIMULATE_BARCODE}" = "true" ]; then - if [ -f "$BARCODE_FILE" ]; then - cat $BARCODE_FILE | grep -v -e "^#" -e "^$" - exit 0 - else - echo "Barcode file $BARCODE_FILE missing ... exiting!" - exit 1 - fi - else - ${MTX} -f ${CHANGER} status | grep "^slot .*: .*FULL>" | awk '{print $2}' | awk -F: '{print $1+1" "}' | tr -d "[\r\n]" - fi - ;; +CHIO=/bin/chio +MT=/usr/bin/mt - loaded) - # echo "Request loaded" - ${MTX} -f ${CHANGER} status -S > /tmp/mtx.$$ - rtn=$? - # Try to get chio slot source from drive entry - SLOT=$(cat /tmp/mtx.$$ | grep "^drive ${DRIVE}: .*slot" | awk '{print $6+1}' | tr -d ">") - if [ -z "$SLOT" ]; then - # This handles the case a source slot is not available (power on - # of the changer with a drive loaded) and all other slots are - # occupied with a tape! - SLOT=$(cat /tmp/mtx.$$ | grep "^slot .*: " | awk '{print $2+1}') - if [ -z "$SLOT" ]; then - echo 0 - else - echo $SLOT - fi - else - echo $SLOT - fi - # All tapes are in the slots - #cat /tmp/mtx.$$ | grep "^drive ${DRIVE}: .* source: <>" | awk "{print 0}" - rm -f /tmp/mtx.$$ - exit $rtn - ;; +if [ -n "${DEBUG}" ]; then + MSG=$0 + for PAR; do MSG="${MSG} \"${PAR}\""; done + echo `date +"%Y/%m/%d %H:%M:%S"` ${MSG} >> ${DEBUG} +fi - slots) - # echo "Request slots" - ${MTX} -f ${CHANGER} status | grep "^slot " | tail -1 | awk '{print $2+1}' | tr -d ":" - ;; +if [ -n "$1" ]; then + CHANGER=$1; +fi +COMMAND=$2 +SLOT=$3 +SLOTDST=$4 +if [ -n "$4" ]; then + TAPE=$4 +fi +if [ -n "$5" ]; then + DRIVE=$5 +fi - *) - usage - ;; +case ${COMMAND} in +unload) + if [ "${OFFLINE}" = yes ]; then + ${MT} -f ${TAPE} offline + if [ $? = 0 -a -n "${OFFLINE_SLEEP}" ]; then + sleep ${OFFLINE_SLEEP} + fi + fi + if [ -z "${SLOT}" ]; then + ${CHIO} -f ${CHANGER} return drive ${DRIVE} + else + ${CHIO} -f ${CHANGER} move drive ${DRIVE} slot $((${SLOT} - 1)) + fi + if [ $? -ne 0 ]; then + # In case of an error, try to unload the cartridge to the first free slot + FREE=`${CHIO} -f ${CHANGER} status slot | \ + sed -ne '/FULL/d;s/^slot *\([0-9]*\):.*/\1/p' | \ + awk 'BEGIN { n = 0 } { n = $1 + 1; exit } END { print n }'` + if [ ${FREE} -gt 0 ]; then + ${CHIO} -f ${CHANGER} move drive ${DRIVE} slot $((${FREE} - 1)) + else + exit 1 + fi + fi + ;; +load) + if [ -z "${SLOT}" ]; then + usage + fi + ${CHIO} -f ${CHANGER} move slot $((${SLOT} - 1)) drive ${DRIVE} + if [ $? -ne 0 ]; then + exit 1 + fi + if [ -n "${LOAD_SLEEP}" ]; then + sleep ${LOAD_SLEEP} + fi + ;; +transfer) + if [ -z "${SLOT}" -o -z "${SLOTDST}" ]; then + usage + fi + ${CHIO} -f ${CHANGER} move slot $((${SLOT} - 1)) slot $((${SLOTDST} - 1)) + if [ $? -ne 0 ]; then + exit 1 + fi + if [ -n "${MOVE_SLEEP}" ]; then + sleep ${MOVE_SLEEP} + fi + ;; +list) + if [ -z "${FAKE_BARCODES}" ]; then + ${CHIO} -f ${CHANGER} status -v slot | \ + sed -ne 's/^slot *\([0-9]*\):.*FULL.*voltag.*<\([^:]*\):.*/\1:\2/p' | \ + awk -F: '{ print $1 + 1 ":" $2 }' + else + if [ -f "${FAKE_BARCODES}" ]; then + grep -v -e "^#" -e "^$" < ${FAKE_BARCODES} + else + echo "${PROGNAME}: Barcode file ${FAKE_BARCODES} is missing" + exit 1 + fi + fi + ;; +listall) + if [ -z "${FAKE_BARCODES}" ]; then + ${CHIO} -f ${CHANGER} status -vS | \ + sed -ne ' + s/^slot *\([0-9]*\):.*ENAB.*FULL.*voltag.*<\([^:]*\):.*/I:\1:F:\2/p;t + s/^slot *\([0-9]*\):.*FULL.*voltag.*<\([^:]*\):.*/S:\1:F:\2/p;t + s/^drive *\([0-9]*\):.*FULL.*voltag.*<\([^:]*\):.*source.*<[^0-9]*\([0-9]*\)>.*/D:\1:F:\3:\2/p;t + s/^slot *\([0-9]*\):.*ENAB.*voltag.*<\([^:]*\):.*/I:\1:E/p;t + s/^slot *\([0-9]*\):.*voltag.*<\([^:]*\):.*/S:\1:E/p;t + s/^drive *\([0-9]*\):.*voltag.*<\([^:]*\):.*/D:\1:E/p' | \ + awk -F: '{ for (n = 1; n <= NF; n++) printf "%s%s", + (n == ($1 == "D" ? 4 : 2)) ? ($n == "" ? 0 : $n + 1) : $n, + (n == NF) ? "\n" : ":" }' + else + if [ -f "${FAKE_BARCODES}" ]; then + grep -v -e "^#" -e "^$" < ${FAKE_BARCODES} | \ + awk -F: '{ print "S:" $1 (match($2, "^ *$") ? ":E" : ":F:" $2) }' + else + echo "${PROGNAME}: Barcode file ${FAKE_BARCODES} is missing" + exit 1 + fi + fi + ;; +loaded) + # If a tape is loaded, but the source slot is unknown (for example, + # after library reboot), try to report the first free slot + FREE=`${CHIO} -f ${CHANGER} status slot | \ + sed -ne '/FULL/d;s/^slot *\([0-9]*\):.*/\1/p' | \ + awk 'BEGIN { n = 0 } { n = $1 + 1; exit } END { print n }'` + ${CHIO} -f ${CHANGER} status -S drive | \ + sed -ne 's/^drive *'${DRIVE}':.*FULL.*source.*<[^0-9]*\([0-9]*\)>.*/\1/p' \ + | awk 'BEGIN { n = 0 } { n = ($1 == "") ? '${FREE}' : $1 + 1 } \ + END { print n }' + ;; +slots) + ${CHIO} -f ${CHANGER} status | grep -c "^slot " + ;; +*) + usage + ;; esac Index: head/sysutils/bareos16-traymonitor/Makefile =================================================================== --- head/sysutils/bareos16-traymonitor/Makefile (revision 470318) +++ head/sysutils/bareos16-traymonitor/Makefile (revision 470319) @@ -1,35 +1,32 @@ # $FreeBSD$ PORTNAME= bareos16 PKGNAMESUFFIX= -traymonitor -PORTREVISION= 0 +PORTREVISION= 1 COMMENT= Backup archiving recovery open sourced (traymonitor) LIB_DEPENDS+= libqwt.so:x11-toolkits/qwt5 \ libbareos.so:sysutils/bareos16-client -CONFLICTS= bacula*-bat-* bareos-traymonitor +CONFLICTS= bacula*-bat-* bareos-traymonitor-* USES= pkgconfig gettext-runtime desktop-file-utils USE_QT4= qmake_build uic_build moc_build rcc_build gui corelib WITH_BAT= yes PLIST= ${.CURDIR}/pkg-plist MAKE_ENV+= MAKEOBJDIRPREFIX=/ MASTERDIR= ${.CURDIR}/../../sysutils/bareos16-server CONFIGURE_ARGS+= --enable-traymonitor=yes \ --with-qwt=${LOCALBASE}/lib \ --disable-build-dird \ --disable-build-stored \ --enable-client-only \ --with-jansson=${LOCALBASE} \ --enable-nls=yes - -OPTIONS_DEFINE= OPENSSL -OPTIONS_DEFAULT=OPENSSL .include "${MASTERDIR}/Makefile"