From e883306fc9b3e6f06242619cf13b02f71a1da0f9 Mon Sep 17 00:00:00 2001 From: Martin Winkler Date: Mon, 13 Jan 2020 11:49:37 +0100 Subject: [PATCH] Making use of new api function to manage configuration in user home --- seqs/backup.cfg.example | 4 ++-- seqs/backup.sh | 25 ++++++++++++------------- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/seqs/backup.cfg.example b/seqs/backup.cfg.example index 92de45e..8f01601 100644 --- a/seqs/backup.cfg.example +++ b/seqs/backup.cfg.example @@ -1,7 +1,6 @@ #!/bin/bash -# Backup sequence definitions template. -# Remove ".example" for customization. +# Backup sequence definitions # A running debian needs at least the following runtime directories created to start up successfully: ## dev @@ -9,6 +8,7 @@ ## sys ## run +BACKUP_TARGET="/backup" # Exclude notation "directory/*" creates the directory but NOT its content BACKUP_EXCLUDES=(\ "backup*"\ diff --git a/seqs/backup.sh b/seqs/backup.sh index f3af497..a4be968 100755 --- a/seqs/backup.sh +++ b/seqs/backup.sh @@ -6,38 +6,37 @@ toolName=backup # (when called from a different directory) WDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >>/dev/null 2>&1 && pwd )" CONFIG=0 -CONFIG_FILE="$WDIR/${toolName}.cfg" -CONFIG_FILE_DEFAULT="${CONFIG_FILE}.example" +CONFIG_FILE_NAME="${toolName}.cfg" +CONFIG_FILE_TEMPLATE="$WDIR/${CONFIG_FILE_NAME}.example" step_config() { - if [ -f "$CONFIG_FILE" ] ; then + initSeqConfig -t "$CONFIG_FILE_NAME" "$CONFIG_FILE_TEMPLATE" + if [ $? -eq 0 ] ; then CONFIG=1 - . "$CONFIG_FILE" - elif [ -f "$CONFIG_FILE_DEFAULT" ] ; then - echoerr " [W] Using default configuration $CONFIG_FILE_DEFAULT" - CONFIG=1 - . "$CONFIG_FILE_DEFAULT" else - echoerr " [W] No Configuration found." + echoerr " [E] Check output for errors" fi } step_1_info() { echo "Backup root [ADDITIONAL_EXCLUDES...]" echoinfo "Essential excludes are provided in the configuration template." - echoinfo "($CONFIG_FILE_DEFAULT)" + echoinfo "($CONFIG_FILE_TEMPLATE)" } step_1_alias() { ALIAS="buroot"; } step_1() { + local buTarget="/backup" if [ $CONFIG -eq 0 ] ; then echoerr " [E] Cannot backup root without properly configured excludes" - echoerr " (expected template: $CONFIG_FILE_DEFAULT)" + echoerr " (expected config: $SEQ_CONFIG_HOME/$CONFIG_FILE_NAME)" + else + buTarget="$BACKUP_TARGET" fi # don't use step number shift - step budir / /backup "${BACKUP_EXCLUDES[@]}" "$@" + step budir / "$buTarget" "${BACKUP_EXCLUDES[@]}" "$@" } step_3_info() { @@ -96,6 +95,6 @@ step_3() { exep "mount -o ro,remount '${BACKUP_TARGET}' >>/dev/null 2>&1" } -VERSION_SEQREV=9 +VERSION_SEQREV=10 . /usr/local/bin/sequencer.sh