#!/bin/sh # Created by Boris Manojlovic # License: Public Domain # GLOBALS CFGNAME="" TAPENAME="" MAXTAPES="" VTAPESFOLDER="" function usage { echo echo "USAGE:" echo " $0 -h" echo " $0 # if you know your tapename please provide it here as such" echo " $0 # if you don't know tapename it will show you regexp from config" echo echo "Example:" echo " $0 linux-ws LINUXBACKUP-" echo return 0 } function readconfig { CFGNAME=$1 TAPENAME=$2 if [ ! -f /etc/amanda/$CFGNAME/amanda.conf ]; then echo "ERROR:No Config \"${CFGNAME}\" file found" return -1 fi # Get number of tapes in "charger" MAXTAPES=`grep tapecycle /etc/amanda/${CFGNAME}/amanda.conf |grep -v ^#|cut -d " " -f 2` VTAPESFOLDER=`grep tapedev /etc/amanda/${CFGNAME}/amanda.conf|grep -v ^#|cut -d":" -f 2|cut -d '"' -f 1` if [ "x${VTAPESFOLDER}" == "x" ]; then # this really is not needed as it is automatic from 2.6.1 but does not hurt... VTAPESFOLDER=`grep tpchanger /etc/amanda/linux-ws/amanda.conf|grep -v ^#|cut -d":" -f 2|cut -d '"' -f 1` if [ "x${VTAPESFOLDER}" == "x" ]; then echo "ERROR: Could not find Virtual Tapes Folder ??" return -1 fi fi TAPENAMEREGEX=`grep labelstr /etc/amanda/${CFGNAME}/amanda.conf|grep -v ^#|cut -d " " -f 2` if [ "x${TAPENAME}" == "x" ]; then echo "Please type in correct tape label text from " echo -n "configured regular expression: ${TAPENAMEREGEX} : " read TAPENAME echo "Name of tape which will be used is: ${TAPENAME}" fi if [ "x${TAPENAME}" == 'x' ] ; then echo "ERROR:TAPENAME cannot be empty" return -1 fi return 0 } if [ $# -lt 1 ]; then usage else CONFIG=$1 TAPENAME=$2 readconfig ${CONFIG} ${TAPENAME} if [ $? -ne 0 ];then echo "ERROR:Reading configuration Failed Please look above" exit -1 fi echo "DEBUG:CFGNAME=${CFGNAME} TAPENAME=${TAPENAME} MAXTAPES=${MAXTAPES} VTAPESFOLDER=${VTAPESFOLDER}" mkdir -p ${VTAPESFOLDER} cd ${VTAPESFOLDER} for i in `seq 1 ${MAXTAPES}`; do mkdir -p slot$i; done for i in `seq 1 ${MAXTAPES}`; do amlabel ${CONFIG} ${TAPENAME}${i} slot ${i} ; done fi # end of script