2021-01-05 23:41:51 +01:00
#!/bin/bash
2021-01-06 00:37:09 +01:00
if [ "$1" = "-h" ]
2021-01-05 23:41:51 +01:00
then
2021-01-06 21:26:43 +01:00
echo
echo
2021-01-06 21:18:36 +01:00
echo "do-plication <option> <enable/disable Encryprion> <n> [directory to back up] [path to key file] [ key file descriptoin(only if key not alreadey created) ]"
2021-01-05 23:41:51 +01:00
echo
echo "Options:"
echo
2021-01-06 21:18:36 +01:00
echo "-a append arcive to the back of the tape put 0 as n"
echo "-c checks (lists) the contents of the n'th arcive"
echo "-f Override the n'th arcive"
echo "-l Load the n'th arcive"
2021-01-05 23:41:51 +01:00
echo
2021-01-06 21:18:36 +01:00
echo
echo "Enable/Disable Encryprion"
echo "-e Encrypt "
echo "-n noEncrypt"
2021-01-06 21:26:43 +01:00
echo
echo
2021-01-05 23:41:51 +01:00
exit 0
2021-01-06 00:35:07 +01:00
fi
2021-01-05 23:41:51 +01:00
2021-01-06 21:18:36 +01:00
if [ "$2" = "-e" ]
then
2021-01-06 21:30:14 +01:00
sudo ls "$4" > /dev/null
2021-01-06 21:31:20 +01:00
if [$? -gt 0]
2021-01-06 21:18:36 +01:00
then
echo "key not fount creating key"
2021-01-06 21:26:43 +01:00
sudo stenc -g 256 -k "$5" -kd "$6";
sudo stenc -f /dev/nst0 -e on -k "$5" -a 1 --ckod
2021-01-06 21:18:36 +01:00
else
echo "key fount using key"
2021-01-06 21:26:43 +01:00
sudo stenc -f /dev/nst0 -e on -k "$5" -a 1 --ckod
2021-01-06 21:18:36 +01:00
fi
fi
2021-01-05 23:41:51 +01:00
# Going to the right directory
# cd /media
case "$1" in
# overwrite the tape from the begining
-a)
2021-01-06 00:35:07 +01:00
sudo mt -f /dev/nst0 eod;
2021-01-06 00:10:56 +01:00
sudo mt -f /dev/nst0 status;
2021-01-06 00:35:07 +01:00
echo "your arcive will be the file number"
2021-01-06 21:18:36 +01:00
sudo screen -dmS do-plication tar -cvf /dev/nst0 "$3"
2021-01-05 23:41:51 +01:00
true
;;
-c)
2021-01-06 21:18:36 +01:00
sudo mt -f /dev/nst0 asf "$3";
2021-01-05 23:41:51 +01:00
sudo tar tvf /dev/st0
true
;;
-f)
2021-01-06 21:18:36 +01:00
sudo mt -f /dev/nst0 asf "$3";
echo "your arcive wil be $3";
sudo screen -dmS do-plication tar -cvf /dev/nst0 "$4"
2021-01-05 23:41:51 +01:00
true
;;
-l)
2021-01-06 21:18:36 +01:00
sudo mt -f /dev/nst0 asf "$3";
sudo screen -dmS do-plication tar xvf /dev/nst0 -C "$4"
2021-01-05 23:41:51 +01:00
true
esac
exit $?