From e58da98d30ba8b739bd4f3d05589899673426ca8 Mon Sep 17 00:00:00 2001 From: Wynn Wolf Arbor Date: Thu, 4 Jun 2020 16:33:52 +0200 Subject: Use LIFEBOAT_ROOT directly throughout the script Instead of using another variable name to refer to the value of LIFEBOAT_ROOT or its default, use LIFEBOAT_ROOT directly. --- lifeboat | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lifeboat b/lifeboat index 9d569f5..4ce396c 100755 --- a/lifeboat +++ b/lifeboat @@ -2,6 +2,8 @@ set -e +LIFEBOAT_ROOT=${LIFEBOAT_ROOT:-"/srv/backup/lifeboat"} + errx() { printf "lifeboat: %s\n" "$1" >&2 exit 1 @@ -14,7 +16,7 @@ usage() { run_backup() { ( - cd "$rootdir/$repo" + cd "$LIFEBOAT_ROOT/$repo" for i in run retain clean sync; do if test -x $i; then @@ -64,19 +66,17 @@ sync_single() { rclone sync --transfers 20 --fast-list "$RESTIC_REPOSITORY" "$1/$LIFEBOAT_REPO_NAME" } -rootdir=${LIFEBOAT_ROOT:-"/srv/backup/lifeboat"} - test $# -lt 2 && usage repo=$1 shift -test -d "$rootdir/$repo" || errx "$repo: no such repository" +test -d "$LIFEBOAT_ROOT/$repo" || errx "$repo: no such repository" export PATH="$HOME/bin:$PATH" export LIFEBOAT_REPO_NAME=$repo -export RESTIC_REPOSITORY=$rootdir/$repo/repo -export RESTIC_PASSWORD_FILE=$rootdir/$repo/credentials/restic +export RESTIC_REPOSITORY=$LIFEBOAT_ROOT/$repo/repo +export RESTIC_PASSWORD_FILE=$LIFEBOAT_ROOT/$repo/credentials/restic case "$1" in run) run_backup;; -- cgit v1.2.3-2-gb3c3