check borgvars file

This commit is contained in:
Asif Bacchus 2020-03-26 03:08:22 -06:00
parent 581f69f429
commit 02a27f55a1
1 changed files with 34 additions and 0 deletions

34
borghelper.sh Normal file → Executable file
View File

@ -154,4 +154,38 @@ case "${varsFile}" in
;;
esac
# verify borg base directory
if [ -z "${borgBaseDir}" ]; then
consoleError 2 "$varsFile: 'borgBaseDir' is not specified."
elif [ ! -d "${borgBaseDir}" ]; then
consoleError 2 "$varsFile: 'borgBaseDir' does not exist."
fi
export BORG_BASE_DIR="${borgBaseDir%/}"
## check path to SSH keyfile
if [ -z "${sshKeyFile}" ]; then
consoleError 2 "$varsFile: 'sshKeyFile' is not specified."
elif [ ! -f "${sshKeyFile}" ]; then
consoleError 2 "$varsFile: 'sshKeyFile' does not exist."
fi
export BORG_RSH="ssh -i ${sshKeyFile}"
# check borg repo connect string
if [ -z "${borgRepo}" ]; then
consoleError 2 "$varsFile: 'borgRepo' is not specified."
fi
export BORG_REPO="${borgRepo}"
# check borg repo password
if [ -n "${borgRepoPassword}" ]; then
export BORG_PASSPHRASE="${borgRepoPassword}"
elif [ "${borgRepoPassword}" = '<none>' ]; then
export BORG_PASSPHRASE=""
else
consoleError 2 "$varsFile: 'borgRepoPassword' must be specified or must be '<none>' if no password has been set (VERY INSECURE!)."
fi
# export borg remote path, if specified
if [ -n "${borgRemote}" ]; then export BORG_REMOTE_PATH="${borgRemote}"; fi