feat: Code improvements
This commit is contained in:
parent
5310d5ae0f
commit
c2dc7a0729
@ -22,14 +22,10 @@ __verbose=
|
|||||||
__log_file='./log.txt'
|
__log_file='./log.txt'
|
||||||
__log_date_fmt='%d/%b/%Y:%H:%M:%S %z'
|
__log_date_fmt='%d/%b/%Y:%H:%M:%S %z'
|
||||||
__tar_options='-acf'
|
__tar_options='-acf'
|
||||||
__tar_compression='gzip'
|
__tar_exclude=
|
||||||
__name_date_fmt='_%Y%m%d-%H%M'
|
__name_date_fmt='_%Y%m%d-%H%M'
|
||||||
|
__compression='gzip'
|
||||||
if [ -n "$BBLIB" ]; then
|
__library="${BBLIB:-./lib}"
|
||||||
__library="$BBLIB"
|
|
||||||
else
|
|
||||||
__library='./lib'
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Source library
|
# Source library
|
||||||
for file in "$__library"/*; do
|
for file in "$__library"/*; do
|
||||||
@ -125,21 +121,23 @@ log "Scripts to process (${__count}): ${__args[@]}"
|
|||||||
|
|
||||||
|
|
||||||
for script in "${__args[@]}"; do
|
for script in "${__args[@]}"; do
|
||||||
|
# Initialise variables
|
||||||
|
__user_script="$script"
|
||||||
|
backups=() # Array of created backups, contains full pathes
|
||||||
|
errors=() # Array of error messages written by err() function
|
||||||
|
|
||||||
# Source scripts
|
# Source scripts
|
||||||
source_script "$script"
|
source_script "$script"
|
||||||
|
|
||||||
# Config can ovewrite script functions and variables
|
# Config can ovewrite script functions and variables
|
||||||
[ -n "$__config" ] && . "$__config"
|
[ -n "$__config" ] && . "$__config"
|
||||||
|
|
||||||
echo
|
echo
|
||||||
echo -e "\e[1m==> Script: ${__args[__iter-1]##*/} [$__iter/$__count]\e[0m" | log -p
|
echo -e "\e[1m--> Script: ${__args[__iter-1]##*/} [$__iter/$__count]\e[0m" | log -p
|
||||||
|
|
||||||
# Initialise variables
|
|
||||||
__user_script="$script"
|
|
||||||
backups=() # Array of created backups, contains full pathes
|
|
||||||
|
|
||||||
# Run prepare() before all if set
|
# Run prepare() before all if set
|
||||||
if is_function_set prepare; then
|
if is_function_set prepare; then
|
||||||
log -p "Execute prepare() ..."
|
echo -e "Execute \e[1mprepare()\e[0m ..." | log -p
|
||||||
prepare
|
prepare
|
||||||
unset prepare
|
unset prepare
|
||||||
fi
|
fi
|
||||||
@ -165,8 +163,9 @@ for script in "${__args[@]}"; do
|
|||||||
((__iter++)) || true
|
((__iter++)) || true
|
||||||
|
|
||||||
# Unset user defined variables
|
# Unset user defined variables
|
||||||
|
unset compression
|
||||||
unset tar_options
|
unset tar_options
|
||||||
unset tar_compression
|
unset tar_exclude
|
||||||
unset name_date_fmt
|
unset name_date_fmt
|
||||||
done
|
done
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user