From 02a27f55a1b56825359fd5d9d82aad98045a70b3 Mon Sep 17 00:00:00 2001 From: Asif Bacchus Date: Thu, 26 Mar 2020 03:08:22 -0600 Subject: [PATCH] check borgvars file --- borghelper.sh | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) mode change 100644 => 100755 borghelper.sh diff --git a/borghelper.sh b/borghelper.sh old mode 100644 new mode 100755 index d9acb9a..6058602 --- a/borghelper.sh +++ b/borghelper.sh @@ -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}" = '' ]; then + export BORG_PASSPHRASE="" +else + consoleError 2 "$varsFile: 'borgRepoPassword' must be specified or must be '' 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 +