diff --git a/seqs/aria2.sh b/seqs/aria2.sh index 1013a1f..8d24c9d 100755 --- a/seqs/aria2.sh +++ b/seqs/aria2.sh @@ -6,7 +6,7 @@ toolUser=aria2 # Get script working directory # (when called from a different directory) -WDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >>/dev/null 2>&1 && pwd)" +WDIR="$(cd "$(dirname -- "${BASH_SOURCE[0]}")" >>/dev/null 2>&1 && pwd)" CONFIG=0 SCRIPT_NAME=$(basename -- $0) SCRIPT_NAME=${SCRIPT_NAME%%.*} @@ -15,7 +15,7 @@ CONFIG_FILE_TEMPLATE="$WDIR/${CONFIG_FILE_NAME}.example" aptOpt= -step_config() { +seq_config() { #echo "Called once before executing steps." ## e.g. to source a config file manually: #. "$CONFIG_FILE" @@ -27,14 +27,14 @@ step_config() { CONFIG=1 else # End if no configuration file exists - [ $DRY -eq 0 ] && return 1 + dry || return 1 fi - [ $QUIET -ne 0 ] && aptOpt="-y" + quiet && aptOpt="-y" return 0 } step_1_info() { echo "Install $toolName"; } -step_1_alias() { ALIAS="install"; } +step_1_alias() { echo "install"; } step_1() { exe apt update exe apt install $toolDeps $aptOpt @@ -54,11 +54,11 @@ ariaConfLoc="/etc/aria2/aria2.conf" step_3_info() { echo "Create $toolName service"; } -step_3_alias() { ALIAS="service"; } +step_3_alias() { echo "service"; } step_3() { addConf -s "$ariaService" "$ariaServiceLoc" exe systemctl daemon-reload - echoseq " [I] Serive not started or enabled" + info "Service not started or enabled" } ariaServiceLoc="/etc/systemd/system/aria2.service" ariaService="[Unit] @@ -76,10 +76,11 @@ Restart=on-failure WantedBy=multi-user.target" step_10_info() { echo "Add ufw rule for rpc port 6800"; } -step_10_alias() { ALIAS="ufw"; } +step_10_alias() { echo "ufw"; } step_10() { exe ufw allow in on eth0 to any port 6800 proto tcp comment "Aria2 rpc" } -VERSION_SEQREV=12 +readonly sqr_minVersion=16 . /usr/local/bin/sequencer.sh + diff --git a/seqs/backup.sh b/seqs/backup.sh index 3919270..b4c428b 100755 --- a/seqs/backup.sh +++ b/seqs/backup.sh @@ -11,17 +11,17 @@ CONFIG=0 CONFIG_FILE_NAME="${toolName}.cfg" CONFIG_FILE_TEMPLATE="$WDIR/${CONFIG_FILE_NAME}.example" -step_config() { +seq_config() { initSeqConfig -t "$CONFIG_FILE_NAME" "$CONFIG_FILE_TEMPLATE" if [ $? -eq 0 ] ; then CONFIG=1 else - echoerr " [E] Check output for errors" + error -e "Check output for errors" # End if no configuration file exists - [ $DRY -eq 0 ] && return -1 + dry || return -1 fi - [ $QUIET -ne 0 ] && APTOPT="-y" + quiet && APTOPT="-y" return 0 } @@ -31,12 +31,12 @@ step_1_info() { echoinfo "Essential excludes are provided in the configuration template." echoinfo "($CONFIG_FILE_TEMPLATE)" } -step_1_alias() { ALIAS="buroot"; } +step_1_alias() { echo "buroot"; } step_1() { local buTarget="/backup" if [ $CONFIG -eq 0 ] ; then - echoerr " [E] Cannot backup root without properly configured excludes" - echoerr " (expected config: $SEQ_CONFIG_HOME/$CONFIG_FILE_NAME)" + error -e "Cannot backup root without properly configured excludes" + error -e " (expected config: $SEQ_CONFIG_HOME/$CONFIG_FILE_NAME)" else buTarget="$BACKUP_TARGET" fi @@ -81,7 +81,7 @@ step_3_info() { echoinfo "e.g. to exclude $dir/a:" echoinfo " $0 budir $dir $tar /a" } -step_3_alias() { ALIAS="budir"; } +step_3_alias() { echo "budir"; } step_3() { local arg local configTarget=0 @@ -105,7 +105,7 @@ step_3() { done if [ -z "$1" ] ; then - echoerr " [E] Nothing found to backup $1" + error -e "Nothing found to backup $1" exit 1 fi @@ -125,7 +125,7 @@ step_3() { buTarget=$(echo "$BACKUP_TARGET" | sed 's:/*$::') else if [ -z "$1" ] ; then - echoerr " [E] No valid target found" + error -e "No valid target found" exit 1 fi buTarget=$(echo "$1" | sed 's:/*$::') @@ -133,7 +133,7 @@ step_3() { fi if [ ! -d "${buTarget}" ] && [ ! -L "${buTarget}" ] then - echoerr " [E] Backup target (${buTarget}) doesn't exist" + error -e "Backup target (${buTarget}) doesn't exist" exit 1 fi @@ -141,9 +141,9 @@ step_3() { buExcludes+=("--exclude='$exclu'") done - echoseq " [I] Source : $buSource" - echoseq " [I] Target : $buTarget" - echoseq " [I] Excludes: $@" + info "Source : $buSource" + info "Target : $buTarget" + info "Excludes: $@" #fix doubling trailing slash on verbose output when backing up root local tmpSource="$buSource/" @@ -160,7 +160,7 @@ step_3() { fi if [ ! -w "${buTarget}" ] ; then - echoerr " [E] Backup target (${buTarget}) is not writable" + error -e "Backup target (${buTarget}) is not writable" exit 1 fi @@ -174,7 +174,7 @@ step_3() { } step_100_info() { echo "Install $toolBin"; } -step_100_alias() { ALIAS="install"; } +step_100_alias() { echo "install"; } step_100() { exe apt update exe apt install $toolBin $APTOPT @@ -188,6 +188,6 @@ checkInstalled() { toolBin="$(command -v $toolBin)" } -VERSION_SEQREV=14 +readonly sqr_minVersion=16 . /usr/local/bin/sequencer.sh diff --git a/seqs/basics.sh b/seqs/basics.sh index f7eafed..749d33d 100755 --- a/seqs/basics.sh +++ b/seqs/basics.sh @@ -15,7 +15,7 @@ WSUBDIR="${WDIR}/basics" #} step_10_info() { echo "ssmtp installation"; } -step_10_alias() { ALIAS="ssmtp"; } +step_10_alias() { echo "ssmtp"; } step_10() { exe apt update && apt install "$SSMTP_DEPS" endReturn -o $? "ssmtp installation failed" @@ -23,19 +23,19 @@ step_10() { SSMTP_DEPS="ssmtp" step_11_info() { echo "ssmtp setup"; } -step_11_alias() { ALIAS="ssmtpSetup"; } +step_11_alias() { echo "ssmtpSetup"; } step_11() { if [ ! -f "$CONFIG_FILE_SSMTP" ] ; then - echoerr " [E] User config ($CONFIG_FILE_SSMTP) not found" - echoerr " See $CONFIG_FILE_SSMTP_TEMPLATE" + error -e "User config ($CONFIG_FILE_SSMTP) not found" + error -e " See $CONFIG_FILE_SSMTP_TEMPLATE" return 1 fi addConf -c -f "$CONFIG_FILE_SSMTP" "$CONFIG_LOC_SSMTP" endReturn -o $? "Could not write ssmtp configuration" if [ ! -f "$CONFIG_FILE_SSMTP_AL" ] ; then - echoerr " [W] User aliases ($CONFIG_FILE_SSMTP_AL) not found" - echoerr " See $CONFIG_FILE_SSMTP_TEMPLATE or modify $CONFIG_LOC_SSMTP_AL directly" + warning -e "User aliases ($CONFIG_FILE_SSMTP_AL) not found" + error -e " See $CONFIG_FILE_SSMTP_TEMPLATE or modify $CONFIG_LOC_SSMTP_AL directly" return 1 fi addConf -c -f "$CONFIG_FILE_SSMTP_AL" "$CONFIG_LOC_SSMTP_AL" @@ -52,17 +52,17 @@ step_13_info() { echo -n "Send test E-Mail to " if [ -z $2 ] ; then echo ""; else echo "$2"; fi } -step_13_alias() { ALIAS="ssmtpTest"; } +step_13_alias() { echo "ssmtpTest"; } step_13() { if [ ! -z "$2" ] || [ "$2" == "" ] ; then - echoerr " [E] No mailaddress provided" + error -e "No mailaddress provided" fi exep "echo \"Subject: sendmail test\" | sendmail -v $2" } step_15_info() { echo "ssmtp help"; } -step_15_alias() { ALIAS="ssmtpHelp"; } +step_15_alias() { echo "ssmtpHelp"; } step_15() { echo " Configuration files expected by this seq:" echo @@ -77,5 +77,5 @@ step_15() { echo " - $CONFIG_LOC_SSMTP_AL" } -VERSION_SEQREV=9 +readonly sqr_minVersion=16 . /usr/local/bin/sequencer.sh diff --git a/seqs/calibreweb.sh b/seqs/calibreweb.sh index 25061a9..6b0b1b1 100755 --- a/seqs/calibreweb.sh +++ b/seqs/calibreweb.sh @@ -15,25 +15,25 @@ SCRIPT_NAME=${SCRIPT_FILE%%.*} CONFIG_FILE_NAME="${SCRIPT_NAME}.cfg" CONFIG_FILE_TEMPLATE="$WDIR/${CONFIG_FILE_NAME}.example" -step_config() { +seq_config() { ## or to use sequencer api with global config file: initSeqConfig "$CONFIG_FILE_NAME" "$CONFIG_FILE_TEMPLATE" if [ $? -eq 0 ] ; then CONFIG=1 else # End if no configuration file exists - [ $DRY -eq 0 ] && return -1 + dry || return -1 fi ## Apt cmdline option to suppress user interaction - [ $QUIET -ne 0 ] && APTOPT="-y" + quiet && APTOPT="-y" ## Return of non zero value will abort the sequence return 0 } step_1_info() { echo "Install dependencies"; } -step_1_alias() { ALIAS="install"; } +step_1_alias() { echo "install"; } step_1() { exe apt install $toolDeps $APTOPT } @@ -44,14 +44,14 @@ step_2() { exe adduser --disabled-password --disabled-login --home-dir "$CALWEB_USER_HOME" --gecos "" $CALWEB_USER exe usermod -aG users $CALWEB_USER else - echoseq " [W] User $CALWEB_USER already exists" + warning "User $CALWEB_USER already exists" fi if [ ! -e "$CALWEB_VENV_ROOT/bin" ]; then exe python3 -m venv "$CALWEB_VENV_ROOT" endReturn -o $? "Creating virtual environment failed" exe chown -R ${CALWEB_USER}: "$CALWEB_BASE" else - echoseq " [W] Virtual env. $CALWEB_VENV_ROOT already exists" + warning "Virtual env. $CALWEB_VENV_ROOT already exists" fi } @@ -70,6 +70,8 @@ step_4() { toolFeatures[$i]="$toolPipName[${toolFeatures[$i]}]" done exe ${CALWEB_VENV_ROOT}/bin/pip install "${toolFeatures[@]}" + # Needed for in-app update + exe chown -R "${CALWEB_USER}": "${CALWEB_VENV_ROOT}/lib/python*/site-packages/calibreweb" } step_5_info() { echo "Install systemd service"; } @@ -86,16 +88,16 @@ step_6() { } step_15_info() { echo "Upgrade python pip"; } -step_15_alias() { ALIAS="upgradepip"; } +step_15_alias() { echo "upgradepip"; } step_15() { exe ${CALWEB_VENV_ROOT}/bin/pip install --upgrade pip } step_100_info() { echo "Setup notes"; } -step_100_alias() { ALIAS="notes"; } +step_100_alias() { echo "notes"; } step_100() { - outColor green + color green cat <>/dev/null endReturn -o $? "SHA256 checksum error" @@ -81,14 +81,14 @@ step_2() { # check if device was confirmed endReturn -o $? "SD card device not found" - echoseq " [I] Writing $(basename "$toolDownFile")" + info "Writing $(basename "$toolDownFile")" exep "xzcat \"$toolDownFile\" | dd of=$SDDEV bs=64k oflag=dsync status=progress" exe sync } step_3_info() { echo "Prepare SD card for first run"; } step_3() { - outColor green + color green cat <>/dev/null; echo $?) -eq 0 ] ; then - echoseq " [I] Hostname $localHostname already defined" + info "Hostname $localHostname already defined" return 0 fi exe hostnamectl set-hostname "$localHostname" @@ -173,14 +173,14 @@ step_14() { hostsLoc="/etc/hosts" step_16_info() { echo "Install cifs mounting requirements"; } -step_16_alias() { ALIAS="cifs"; } +step_16_alias() { echo "cifs"; } step_16() { exe apt install cifs-utils $APTOPT } step_17_info() { echo "Cifs notes"; } step_17() { - outColor green + color green cat <>/dev/null 2>&1 if [ $? -eq 0 ]; then - echoseq " [I] Danted already installed" + info "Danted already installed" return 0 fi exe apt update @@ -419,7 +419,7 @@ DANTED_EOF } step_19_info() { echo "Disable apt-daily activities"; } -step_19_alias() { ALIAS="aptdaily"; } +step_19_alias() { echo "aptdaily"; } step_19() { exe /usr/bin/systemctl stop apt-daily-upgrade.timer exe /usr/bin/systemctl stop apt-daily.timer @@ -430,22 +430,18 @@ step_19() { } step_21_info() { - local pInstallDir="${DLD_DIR}/prowlarr" - case $CONTEXT_HELP in - 0) - if [ -e "$pInstallDir" ]; then - echo -n "Upgrade " - else - echo -n "Install " - fi - ;; - *) - echo -n "Install/Update ";; - esac + local pInstallDir="${DLD_DIR:-}/prowlarr" + if contextHelp ; then + echo -n "Install/Update " + elif [ -e "$pInstallDir" ]; then + echo -n "Upgrade " + else + echo -n "Install " + fi echo "prowlarr for arm64" echoinfo "Default port: 9696" } -step_21_alias() { ALIAS="prowlarr"; } +step_21_alias() { echo "prowlarr"; } step_21() { # local pDownDir="/tmp" local pInstallDir="${DLD_DIR}/prowlarr" @@ -455,10 +451,10 @@ step_21() { if [ -e "$pInstallDir" ]; then prowlarrUpgrade=1 - echoseq " [I] Stopping prowlarr service" - echoseq " Service will not be started automatically after update" + info "Stopping prowlarr service" + info " Service will not be started automatically after update" exe service prowlarr stop - echoseq " [I] Moving existing $pInstallDir as backup" + info "Moving existing $pInstallDir as backup" exe mv "$pInstallDir" "${pInstallDir}_bu_"`date +%Y%m%d-%H%M%S` fi @@ -470,12 +466,12 @@ pTar="/tmp/Prowlarr.tgz" prowlarrUpgrade=0 step_22_info() { echo "Clean prowlarr download"; } -step_22_alias() { ALIAS="prowlarrclean"; } +step_22_alias() { echo "prowlarrclean"; } step_22() { exe rm -rf "$pTar" if [ $prowlarrUpgrade -ne 0 ]; then - echoseq " [I] Stopping sequence here." - echoseq " Following steps only exected for fresh installation." + info "Stopping sequence here." + info " Following steps only exected for fresh installation." exit 0 fi } @@ -512,22 +508,18 @@ step_24() { } step_30_info() { - local pInstallDir="${DLD_DIR}/readarr" - case $CONTEXT_HELP in - 0) - if [ -e "$pInstallDir" ]; then - echo -n "Upgrade " - else - echo -n "Install " - fi - ;; - *) - echo -n "Install/Update ";; - esac + local pInstallDir="${DLD_DIR:-}/readarr" + if contextHelp ; then + echo -n "Install/Update " + elif [ -e "$pInstallDir" ]; then + echo -n "Upgrade " + else + echo -n "Install " + fi echo "readarr for arm64" echoinfo "Default port: 8787" } -step_30_alias() { ALIAS="readarr"; } +step_30_alias() { echo "readarr"; } step_30() { # local pDownDir="/tmp" local lInstallDir="${DLD_DIR}/readarr" @@ -537,10 +529,10 @@ step_30() { if [ -e "$lInstallDir" ]; then readarrUpgrade=1 - echoseq " [I] Stopping readarr service" - echoseq " Service will not be started automatically after update" + info "Stopping readarr service" + info " Service will not be started automatically after update" exe service readarr stop - echoseq " [I] Moving existing $lInstallDir as backup" + info "Moving existing $lInstallDir as backup" exe mv "$lInstallDir" "${lInstallDir}_bu_"`date +%Y%m%d-%H%M%S` fi @@ -552,12 +544,12 @@ readarrTar="/tmp/Readarr.tar.gz" readarrUpgrade=0 step_31_info() { echo "Clean readarr download"; } -step_31_alias() { ALIAS="readarrclean"; } +step_31_alias() { echo "readarrclean"; } step_31() { exe rm -rf "$readarrTar" if [ $readarrUpgrade -ne 0 ]; then - echoseq " [I] Stopping sequence here." - echoseq " Following steps only exected for fresh installation." + info "Stopping sequence here." + info " Following steps only exected for fresh installation." exit 0 fi } @@ -595,7 +587,7 @@ step_33() { } step_50_info() { echo "Upgrade bazarr"; } -step_50_alias() { ALIAS="upgradebazarr"; } +step_50_alias() { echo "upgradebazarr"; } step_50() { local bazarrServiceLoc="/etc/systemd/system/bazarr.service" local lService=`eval "echo \"$bazarrService\""` @@ -610,8 +602,8 @@ step_50() { checkVpn() { ip -br a | grep tun >>/dev/null 2>&1 - [ $? -eq 0 ] && echoseq " [W] A VPN connection is possibly active. Consider deactivating it befor any apt operation." + [ $? -eq 0 ] && warning "A VPN connection is possibly active. Consider deactivating it befor any apt operation." } -VERSION_SEQREV=13 +readonly sqr_minVersion=16 . /usr/local/bin/sequencer.sh diff --git a/seqs/ebackup.sh b/seqs/ebackup.sh index 5f98a4a..0a43062 100755 --- a/seqs/ebackup.sh +++ b/seqs/ebackup.sh @@ -15,19 +15,19 @@ SCRIPT_NAME=$(basename -- $0) SCRIPT_NAME=${SCRIPT_NAME%%.*} CONFIG_FILE_TEMPLATE="$WDIR/${SCRIPT_NAME}.cfg.example" -step_config() { +seq_config() { initSeqConfig -p "$SCRIPT_NAME" "$CONFIG_FILE_TEMPLATE" if [ $? -eq 0 ] ; then CONFIG=1 else - [ $DRY -eq 0 ] && return 1 + dry || return 1 fi toolSyslogTag="${SCRIPT_NAME}-$SEQ_PROFILE_NAME" } step_1_info() { echo -n "Backup " - if [ $CONTEXT_HELP -ne 0 ] ; then + if contextHelp ; then echo -n "selected profile" else echo -n "profile: $SEQ_PROFILE_NAME" @@ -36,7 +36,7 @@ step_1_info() { echoinfo " [OPTIONS]" echoinfo " --no-purge, -n : Do not purge old backups after backup" } -step_1_alias() { ALIAS="backup"; } +step_1_alias() { echo "backup"; } step_1() { shift @@ -89,7 +89,7 @@ step_1() { } step_3_info() { echo "Verify selected backup"; } -step_3_alias() { ALIAS="verify"; } +step_3_alias() { echo "verify"; } step_3() { shift @@ -111,7 +111,7 @@ step_5_info() { echoinfo " (file or folder)" echoinfo " --time, -t