ebackup - modernize implementation
This commit is contained in:
@@ -1,28 +1,27 @@
|
||||
#!/bin/bash
|
||||
|
||||
toolName=duplicity
|
||||
readonly toolName=duplicity
|
||||
readonly toolCronDir="/etc/cron.d"
|
||||
readonly toolPrefix="encBackup_"
|
||||
toolBin=
|
||||
toolPpa="ppa:duplicity-team/duplicity-release-git"
|
||||
toolCronDir="/etc/cron.d"
|
||||
toolPrefix="encBackup_"
|
||||
toolSyslogTag=
|
||||
|
||||
# Get script working directory
|
||||
# (when called from a different directory)
|
||||
WDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >>/dev/null 2>&1 && pwd )"
|
||||
CONFIG=0
|
||||
SCRIPT_NAME=$(basename -- $0)
|
||||
SCRIPT_NAME=${SCRIPT_NAME%%.*}
|
||||
CONFIG_FILE_TEMPLATE="$WDIR/${SCRIPT_NAME}.cfg.example"
|
||||
sq_aptOpt=
|
||||
sq_config=0
|
||||
|
||||
seq_config() {
|
||||
initSeqConfig -p "$SCRIPT_NAME" "$CONFIG_FILE_TEMPLATE"
|
||||
if [ $? -eq 0 ] ; then
|
||||
CONFIG=1
|
||||
if initSeqConfig -p "${seq_fileName:?}" "${seq_configTemplate:?}" ; then
|
||||
sq_config=1
|
||||
else
|
||||
dry || return 1
|
||||
fi
|
||||
toolSyslogTag="${SCRIPT_NAME}-$seq_profileName"
|
||||
|
||||
## Apt cmdline option to suppress user interaction
|
||||
interactive || sq_aptOpt="-y"
|
||||
|
||||
toolSyslogTag="${seq_fileName:?}-$seq_profileName"
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
step_1_info() {
|
||||
@@ -213,7 +212,9 @@ step_22() {
|
||||
fi
|
||||
|
||||
checkInstalled
|
||||
setPassphrase
|
||||
exe $toolBin list-current-files "$ebuTarget"
|
||||
unsetPassphrase
|
||||
}
|
||||
|
||||
|
||||
@@ -235,7 +236,7 @@ step_70() {
|
||||
local cronRemove=0
|
||||
local cronScript="$toolCronDir/${toolPrefix}$seq_profileName"
|
||||
local cronLog='>/dev/null'
|
||||
local cronEntry="$EBU_CRONTIME $(whoami) $WDIR/$(basename -- $0) -qq -p $seq_profileName"
|
||||
local cronEntry="$EBU_CRONTIME $(whoami) ${seq_self:?} -qq -p $seq_profileName"
|
||||
|
||||
for arg in "$@" ; do
|
||||
case "$1" in
|
||||
@@ -273,25 +274,20 @@ step_72_info() { echo "Update all profile cron files"; }
|
||||
step_72_alias() { echo "reload"; }
|
||||
step_72() {
|
||||
for seq in "$seq_configRoot/"* ; do
|
||||
seq=$(basename ${seq})
|
||||
$WDIR/$(basename -- $0) $sqr_args -qq -p ${seq%%.*} cron
|
||||
seq="$(basename -- "${seq}")"
|
||||
exe "${seq_self}" -qq -p ${seq%%.*} cron
|
||||
done
|
||||
}
|
||||
|
||||
step_100_info() { echo "Install $toolName $toolPpa"; }
|
||||
step_100_info() { echo "Install $toolName"; }
|
||||
step_100_alias() { echo "install"; }
|
||||
step_100() {
|
||||
local aptOpt=
|
||||
if quiet ; then
|
||||
aptOpt="-y"
|
||||
fi
|
||||
|
||||
exe add-apt-repository $toolPpa $aptOpt
|
||||
exe apt install $toolName $aptOpt
|
||||
exe apt update
|
||||
exe apt install $toolName ${sq_aptOpt}
|
||||
}
|
||||
|
||||
setPassphrase() {
|
||||
if [ -z "${PASSPHRASE:-}" ] && [ ! -z "${EBU_PASSPHRASE:-}" ] ; then
|
||||
if [ -z "${PASSPHRASE:-}" ] && [ -n "${EBU_PASSPHRASE:-}" ] ; then
|
||||
export PASSPHRASE="$EBU_PASSPHRASE"
|
||||
fi
|
||||
}
|
||||
@@ -321,13 +317,14 @@ syslogEntry() {
|
||||
|
||||
checkInstalled() {
|
||||
if [ -z "$toolBin" ] ; then
|
||||
command -v $toolName >>/dev/null
|
||||
if [ $? -ne 0 ] ; then
|
||||
if ! command -v $toolName >>/dev/null ; then
|
||||
step install
|
||||
fi
|
||||
toolBin="${EBU_PRECMD:-} $(escpath "$(command -v $toolName)")"
|
||||
fi
|
||||
}
|
||||
|
||||
# shellcheck disable=SC2034 # Appears unused
|
||||
readonly sqr_minVersion=16
|
||||
# shellcheck disable=SC1091 # Don't follow this source
|
||||
. /usr/local/bin/sequencer.sh
|
||||
|
Reference in New Issue
Block a user