From b2e8da1d0b8ae9428544a1c1955d3203643a63e0 Mon Sep 17 00:00:00 2001 From: Leandro Lucarella Date: Sat, 25 Sep 2021 12:19:47 +0200 Subject: [PATCH] Fix overriding config per-host All the config has to be re-evaluated when overriding a host's config. --- bacap | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/bacap b/bacap index db92c50..30983f5 100755 --- a/bacap +++ b/bacap @@ -50,26 +50,27 @@ BACAPRC=$1 # Load configuration files load_config() { + extra_config=$1 source "/etc/bacaprc" 2> /dev/null source "/etc/bacap/bacaprc" 2> /dev/null source "$SCRIPT_DIR/bacaprc" 2> /dev/null test -n "$BACAPRC" && source "$BACAPRC" + test -n "$extra_config" && source "$1" 2> /dev/null + + run= + [ $DRY_RUN -eq 1 ] && + run=echo + [ $VERBOSE -eq 1 ] && + RSYNC_FLAGS="$RSYNC_FLAGS $RSYNC_VERBOSE_FLAGS" + [ $DEBUG -eq 1 ] && + V=-v + exec 3>&2 + [ -n "$LOG_FILE" ] && + exec 1>>"$LOG_FILE" && + exec 2>>"$LOG_FILE" + + export RSYNC_RSH } -load_config - -export RSYNC_RSH - -run= -[ $DRY_RUN -eq 1 ] && - run=echo -[ $VERBOSE -eq 1 ] && - RSYNC_FLAGS="$RSYNC_FLAGS $RSYNC_VERBOSE_FLAGS" -[ $DEBUG -eq 1 ] && - V=-v -exec 3>&2 -[ -n "$LOG_FILE" ] && - exec 1>>"$LOG_FILE" && - exec 2>>"$LOG_FILE" error() { echo "$@" >&3 @@ -99,8 +100,7 @@ for host_path in "$CONFIG_PATH"/* do saved_ret=$ret # Load default config and override config if correspond - load_config - source "$host_path/bacaprc" 2>/dev/null + load_config "$host_path/bacaprc" host=`basename "$host_path"` host_backup_path="$BACKUP_PATH/$host" mkdir -p $host_backup_path -- 2.43.0