From c8ba838f3a28d27d44717b3ded91d8c59bb04f04 Mon Sep 17 00:00:00 2001 From: Jack-Benny Persson Date: Fri, 24 Feb 2012 21:58:06 +0100 Subject: [PATCH] First commit --- autotape.sh | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100755 autotape.sh diff --git a/autotape.sh b/autotape.sh new file mode 100755 index 0000000..04dc215 --- /dev/null +++ b/autotape.sh @@ -0,0 +1,55 @@ +#!/bin/bash + +### Config options ### +DRIVE="/dev/st0" + + +### Functions ### + +Do_backup() +{ + echo "Doing backup" + exit 0 +} + + +Check_drive() +{ + if [ ! -e ${DRIVE} ]; then + echo "No drive connected" + EXIT_STATE=1 + + elif [ -e ${DRIVE} ]; then + echo "Drive connected, contiuing" + EXIT_STATE=0 + + else + echo "Unknown error" + EXIT_STATE=3 + fi +} + + +Check_tape() +{ +TESTTAPE=`mt -f ${DRIVE} status | grep DR_OPEN` + if [ $? == 0 ]; then + echo "No tape in drive, aborting" + exit 1 + + else + echo "Tape seems to exist" + exit 0 + fi +} + + +### Main routine ### + +EXIT_STATE=3 +while [ ${EXIT_STATE} != 0 ]; do + Check_drive + if [ ${EXIT_STATE} != 0 ]; then + sleep 20 + fi +done