feat: Replace BBLIB with BBLIBRARY

This commit is contained in:
ge 2022-05-19 08:40:38 +03:00
parent cfc88ae3c5
commit c37803236f

View File

@ -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 <https://nixhacks.net/>
#
# 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