From c37803236f80beafd3f16e1c0ff4ec2503c6e5db Mon Sep 17 00:00:00 2001 From: ge Date: Thu, 19 May 2022 08:40:38 +0300 Subject: [PATCH] feat: Replace BBLIB with BBLIBRARY --- src/boring-backup | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/boring-backup b/src/boring-backup index 2840f74..37b70be 100755 --- a/src/boring-backup +++ b/src/boring-backup @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# boring-backup -- backup automation micro-framework and library. +# boring-backup -- backup files and databases. # Copyright (c) 2022 ge # # This program is free software: you can redistribute it and/or modify @@ -25,12 +25,15 @@ __tar_options='-acf' __tar_exclude= __name_date_fmt='_%Y%m%d-%H%M' __compression='gzip' -__library="${BBLIB:-./lib}" +BBLIBRARY="${BBLIBRARY:-./lib}" # Source library -for file in "$__library"/*; do - . "$file" -done +if [ -f "$BBLIBRARY/lib.sh" ]; then + . "$BBLIBRARY/lib.sh" +else + echo "Error: Cannot source library from $BBLIBRARY" >&2 + exit 1 +fi print_help() { cat <<- EOF @@ -46,7 +49,7 @@ Options: -V, --version print version and exit. Environment: - BBLIB path to bb library [current: $__library] + BBLIBRARY path to bb library [current: $BBLIBRARY] EOF } @@ -137,24 +140,24 @@ for script in "${__args[@]}"; do # Run prepare() before all if set if is_function_set prepare; then - echo -e "Execute \e[1mprepare()\e[0m ..." | log -p + echo -e "Run \e[1mprepare()\e[0m ..." | log -p prepare unset prepare fi # Run user defined backup() if set or builtin_backup() if is_function_set backup; then - echo -e "Execute \e[1mbackup()\e[0m ..." | log -p + echo -e "Run \e[1mbackup()\e[0m ..." | log -p backup unset backup else - echo -e "Execute \e[1mbuiltin_backup()\e[0m ..." | log -p + echo -e "Run \e[1mbuiltin_backup()\e[0m ..." | log -p builtin_backup fi # Run post backup function if set if is_function_set finalise; then - echo -e "Execute \e[1mfinalise()\e[0m ..." | log -p + echo -e "Run \e[1mfinalise()\e[0m ..." | log -p finalise unset finalise fi