modernize multiple seqs and fix deprecated use of endCheckEmpty

This commit is contained in:
2022-12-12 16:42:25 +01:00
parent dbb8cac539
commit 7391de1ddd
18 changed files with 199 additions and 232 deletions

View File

@@ -1,42 +1,36 @@
#!/bin/bash
toolName=backup
toolBin=rsync
readonly toolName=backup
readonly toolBin=rsync
# Get script working directory
# (when called from a different directory)
WDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >>/dev/null 2>&1 && pwd )"
APTOPT=
CONFIG=0
CONFIG_FILE_NAME="${toolName}.cfg"
CONFIG_FILE_TEMPLATE="$WDIR/${CONFIG_FILE_NAME}.example"
sq_aptOpt=
sq_config=0
seq_config() {
initSeqConfig -t "$CONFIG_FILE_NAME" "$CONFIG_FILE_TEMPLATE"
if [ $? -eq 0 ] ; then
CONFIG=1
if initSeqConfig -t "${seq_configName:?}" "${seq_configTemplate:?}" ; then
sq_config=1
else
error -e "Check output for errors"
# End if no configuration file exists
dry || return -1
dry || return 1
fi
quiet && APTOPT="-y"
interactive || sq_aptOpt="-y"
return 0
}
step_1_info() {
echo "Backup root"
echoinfo "Essential excludes are provided in the configuration template."
echoinfo "($CONFIG_FILE_TEMPLATE)"
echoinfo "(${seq_configTemplate})"
}
step_1_options() { echo "[ADDITIONAL_EXCLUDES...]"; }
step_1_alias() { echo "buroot"; }
step_1() {
local buTarget="/backup"
if [ $CONFIG -eq 0 ] ; then
if (( ! sq_config )) ; then
error -e "Cannot backup root without properly configured excludes"
error -e " (expected config: $seq_configRoot/$CONFIG_FILE_NAME)"
error -e " (expected config: ${seq_configFile})"
else
buTarget="$BACKUP_TARGET"
fi
@@ -49,20 +43,19 @@ step_1() {
step_3_info() {
# Backup single directory recursively
local opt="[OPTION]"
local dir="<DIRECTORY>"
local tar="<TARGET>"
local exc="[EXCLUDES...]"
local opt=
local dir=
local tar=
local exc=
shift
if [ "${1:-}" == "-t" ] ; then
opt=" -t "
tar=
shift
fi
if [ -n "${1:-}" ] ; then
dir="$1"
shift
if [ -n $tar ] && [ -n "$1" ] ; then
if [ -z $opt ] && [ -n "$1" ] ; then
tar="$1"
shift
else
@@ -75,12 +68,13 @@ step_3_info() {
fi
fi
echo "Backup $opt $dir $tar $exc"
echoinfo " -t : Using configuration value as TARGET"
echoinfo " <DIRECTORY> [EXCLUDES...]"
echoinfo " -t : Using configuration value as TARGET"
echoinfo " <DIRECTORY> [EXCLUDES...]"
echoinfo "EXCLUDES path notation starts within $dir"
echoinfo "e.g. to exclude $dir/a:"
echoinfo " e.g. to exclude $dir/a:"
echoinfo " $0 budir $dir $tar /a"
}
step_3_options() { echo "[OPTION] <DIRECTORY> [TARGET] [EXCLUDES...]"; }
step_3_alias() { echo "budir"; }
step_3() {
local configTarget=0
@@ -119,7 +113,7 @@ step_3() {
buLog="backup_${buLog}"
shift
if [ $configTarget -ne 0 ] && [ $CONFIG -ne 0 ] ; then
if [ $configTarget -ne 0 ] && (( sq_config )) ; then
# Taking target from config
buTarget=$(echo "$BACKUP_TARGET" | sed 's:/*$::')
else
@@ -176,7 +170,7 @@ step_100_info() { echo "Install $toolBin"; }
step_100_alias() { echo "install"; }
step_100() {
exe apt update
exe apt install $toolBin $APTOPT
exe apt install $toolBin ${sq_aptOpt}
}
checkInstalled() {
@@ -187,6 +181,7 @@ checkInstalled() {
toolBin="$(command -v $toolBin)"
}
# shellcheck disable=SC2034 # Appears unused
readonly sqr_minVersion=16
# shellcheck disable=SC1091 # Don't follow this source
. /usr/local/bin/sequencer.sh

View File

@@ -3,21 +3,20 @@
# Certbot installation and creation supporting Raspbian and Ubuntu.
# Certificate can be created/updated as "certonly" only.
toolName=certbot
readonly toolName=certbot
# Get script working directory
# (when called from a different directory)
WDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >>/dev/null 2>&1 && pwd )"
CONFIG=0
CONFIG_FILE_NAME="${toolName}.cfg"
CONFIG_FILE_TEMPLATE="$WDIR/${CONFIG_FILE_NAME}.example"
sq_aptOpt=
seq_config() {
initSeqConfig "$CONFIG_FILE_NAME" "$CONFIG_FILE_TEMPLATE"
local confReturn=$?
if [ $confReturn -eq 0 ] ; then
CONFIG=1
if ! initSeqConfig "${seq_configName:?}" "${seq_configTemplate:?}" ; then
# End if no configuration file exists
dry || return 1
fi
## Apt cmdline option to suppress user interaction
interactive || sq_aptOpt="-y"
return 0
}
step_1_info() { echo "Install $toolName for letsencrypt"; }
@@ -41,24 +40,17 @@ step_1() {
echo " [I] Detected OS: $osName $distName"
local aptOption=
if quiet ; then
aptOption="-y"
else
aptOption=""
fi
if [ "$osName" == "Ubuntu" ] ; then
exe apt-get update
exe apt-get install software-properties-common $aptOption
exe apt-get install software-properties-common ${sq_aptOpt}
saveReturn $?
exe add-apt-repository universe $aptOption
exe add-apt-repository universe ${sq_aptOpt}
saveReturn $?
exe add-apt-repository ppa:certbot/certbot $aptOption
exe add-apt-repository ppa:certbot/certbot ${sq_aptOpt}
saveReturn $?
exe apt-get update
exe apt-get install $toolName $aptOption
exe apt-get install $toolName ${sq_aptOpt}
saveReturn $?
endReturn "$toolName installation for $osName failed"
elif [ "$osName" == "Raspbian" ] ; then
@@ -71,13 +63,15 @@ step_1() {
step_2_info() { echo "Create or update letsencrypt certificate"; }
step_2_alias() { echo "update"; }
step_2() {
endCheckEmpty CERTBOT_DOMAINS "No domain list found. Check configuration"
endCheckEmpty CERTBOT_WEBROOT "Invalid web root. Check configuration"
endCheckEmpty CERTBOT_MAIL "Invalid mail address. Check configuration"
endIfEmpty CERTBOT_DOMAINS "No domain list found. Check configuration"
endIfEmpty CERTBOT_WEBROOT "Invalid web root. Check configuration"
endIfEmpty CERTBOT_MAIL "Invalid mail address. Check configuration"
exe certbot certonly --webroot -w "$CERTBOT_WEBROOT" --rsa-key-size 4096 --expand --agree-tos \
-m "$CERTBOT_MAIL" ${CERTBOT_DOMAINS[@]/#/-d }
}
# shellcheck disable=SC2034 # Appears unused
readonly sqr_minVersion=16
# shellcheck disable=SC1091 # Don't follow this source
. /usr/local/bin/sequencer.sh

View File

@@ -1,11 +1,11 @@
#!/bin/bash
#toolName=mytool
toolDownSite="https://raspi.debian.net/tested-images"
readonly toolDownSite="https://raspi.debian.net/tested-images"
toolDownUrl=
toolDownFile=
toolEssentialDeps="vim bash-completion man-db locales wget"
readonly toolEssentialDeps="vim bash-completion man-db locales wget"
SDDEV=
SDBOOT=
@@ -14,25 +14,18 @@ SDROOT=
SDROOTDEV=
SDROOTPUUID=
# Get script working directory
# (when called from a different directory)
WDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >>/dev/null 2>&1 && pwd )"
APTOPT=
CONFIG=0
SCRIPT_NAME=$(basename -- $0)
SCRIPT_NAME=${SCRIPT_NAME%%.*}
CONFIG_FILE_NAME="${SCRIPT_NAME}.cfg"
CONFIG_FILE_TEMPLATE="$WDIR/${CONFIG_FILE_NAME}.example"
sq_aptOpt=
seq_config() {
quiet && APTOPT="-y"
interactive || sq_aptOpt="-y"
return 0
}
step_1_info() {
echo "Download latest xz-compressed image [IMAGE FILE URL] [SD CARD DEVICE]"
echo "Download latest xz-compressed image"
echoinfo "$toolDownSite"
}
step_1_options() { echo "[IMAGE FILE URL] [SD CARD DEVICE]"; }
step_1_alias() { echo "install"; }
step_1() {
shift
@@ -71,7 +64,8 @@ step_1() {
endReturn -o $? "SHA256 checksum error"
}
step_2_info() { echo "Write image to device [DEVICE]"; }
step_2_info() { echo "Write image to device"; }
step_2_options() { echo "[DEVICE]"; }
step_2() {
shift
if [ -z "$SDDEV" ] ; then
@@ -130,8 +124,8 @@ step_10() {
fi
exe apt update
exe apt full-upgrade $APTOPT
exe apt install $toolEssentialDeps $APTOPT
exe apt full-upgrade ${sq_aptOpt}
exe apt install $toolEssentialDeps ${sq_aptOpt}
}
step_11_info() { echo "Set timezone"; }
@@ -156,12 +150,13 @@ step_12() {
}
localesConfigLoc="/etc/locale.gen"
step_14_info() { echo "Change hostname [HOSTNAME]"; }
step_14_info() { echo "Change hostname"; }
step_14_options() { echo "[HOSTNAME]"; }
step_14_alias() { echo "hostname"; }
step_14() {
shift
local localHostname=$1
endCheckEmpty localHostname "No hostname provided"
endIfEmpty localHostname "No hostname provided"
if [ $(grep -r "$localHostname" "$hostsLoc">>/dev/null; echo $?) -eq 0 ] ; then
info "Hostname $localHostname already defined"
return 0
@@ -175,7 +170,7 @@ hostsLoc="/etc/hosts"
step_16_info() { echo "Install cifs mounting requirements"; }
step_16_alias() { echo "cifs"; }
step_16() {
exe apt install cifs-utils $APTOPT
exe apt install cifs-utils ${sq_aptOpt}
}
step_17_info() { echo "Cifs notes"; }
@@ -296,5 +291,8 @@ read_sd_dev() {
}
SDBOOTPARTNO=1
SDROOTPARTNO=2
# shellcheck disable=SC2034 # Appears unused
readonly sqr_minVersion=16
# shellcheck disable=SC1091 # Don't follow this source
. /usr/local/bin/sequencer.sh

View File

@@ -1,26 +1,18 @@
#!/bin/bash
# Get script working directory
# (when called from a different directory)
WDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >>/dev/null 2>&1 && pwd)"
APTOPT=
CONFIG=0
SCRIPT_NAME=$(basename -- $0)
SCRIPT_NAME=${SCRIPT_NAME%%.*}
CONFIG_FILE_NAME="${SCRIPT_NAME}.cfg"
CONFIG_FILE_TEMPLATE="$WDIR/${CONFIG_FILE_NAME}.example"
sq_aptOpt=
seq_config() {
checkVpn
initSeqConfig -t "$CONFIG_FILE_NAME" "$CONFIG_FILE_TEMPLATE"
if [ $? -eq 0 ] ; then
CONFIG=1
else
if ! initSeqConfig -t "${seq_configName:?}" "${seq_configTemplate:?}" ; then
# End if no configuration file exists
dry || return -1
dry || return 1
fi
quiet && APTOPT="-y"
## Apt cmdline option to suppress user interaction
interactive || sq_aptOpt="-y"
return 0
}
@@ -227,7 +219,7 @@ step_11() {
exe curl -sL "$lidarrUrl" -o /tmp/Lidarr.tgz
endReturn -o "Download failed"
exe apt install $lidarrDeps $APTOPT
exe apt install $lidarrDeps ${sq_aptOpt}
exe tar xvzf /tmp/Lidarr.tgz -C "${DLD_DIR}/"
exe mv "${DLD_DIR}/Lidarr" "${DLD_DIR}/lidarr"
@@ -273,7 +265,7 @@ step_13() {
local bazarrDeps="python3-pip python3-distutils python3-venv ffmpeg"
#local bazarrDeps+=" libxml2-dev libxslt1-dev python3-libxml2 python3-lxml libatlas-base-dev"
exe apt install $bazarrDeps $APTOPT
exe apt install $bazarrDeps ${sq_aptOpt}
}
step_14_info() { echo "Install bazarr"; }
@@ -352,8 +344,8 @@ step_16() {
exe mkdir -p "$buildPath"
exe cd "$buildPath"
exe apt build-dep unrar-nonfree $APTOPT
exe apt source -b unrar-nonfree $APTOPT
exe apt build-dep unrar-nonfree ${sq_aptOpt}
exe apt source -b unrar-nonfree ${sq_aptOpt}
endReturn -o $? "unrar-nonfree build failed ($buildPath left untouched)"
exe dpkg -i unrar*.deb
endReturn -o $? "unrar-nonfree install failed ($buildPath left untouched)"
@@ -370,7 +362,7 @@ step_17() {
return 0
fi
exe apt update
exe apt install dante-server $APTOPT
exe apt install dante-server ${sq_aptOpt}
exe systemctl stop danted.service
exe systemctl disable danted.service
}
@@ -606,5 +598,7 @@ checkVpn() {
fi
}
# shellcheck disable=SC2034 # Appears unused
readonly sqr_minVersion=16
# shellcheck disable=SC1091 # Don't follow this source
. /usr/local/bin/sequencer.sh

View File

@@ -27,16 +27,15 @@ seq_config() {
step_1_info() {
echo -n "Backup "
if contextHelp ; then
echo -n "selected profile"
echo "selected profile"
else
echo -n "profile: $seq_profileName"
echo "profile: $seq_profileName"
fi
echo " [OPTIONS] [full|incremental]"
echoinfo " [OPTIONS]"
echoinfo " --no-purge, -n : Do not purge old backups after backup"
echoinfo " --allow-source-mismatch, -a : see ${toolName:-} help"
}
step_1_options() { echo '[OPTIONS] [full|incremental]'; }
step_1_alias() { echo "backup"; }
step_1() {
shift
@@ -109,12 +108,13 @@ step_3() {
}
step_5_info() {
echo "Restore [OPTIONS] <LOCAL TARGET> [TARGET]"
echo "Restore files from backup"
echoinfo " [OPTIONS]"
echoinfo " --file-to-restore, -f <RELPATH> : Relative path within backup"
echoinfo " (file or folder)"
echoinfo " --time, -t <TIME> : Age of file to be restored"
}
step_5_options() { echo '[OPTIONS] <LOCAL TARGET> [TARGET]'; }
step_5_alias() { echo "restore"; }
step_5() {
shift
@@ -153,7 +153,8 @@ step_5() {
unsetPassphrase
}
step_7_info() { echo "Purge old backups [TARGET]"; }
step_7_info() { echo "Purge old backups"; }
step_7_options() { echo '[TARGET]'; }
step_7_alias() { echo "purge"; }
step_7() {
shift
@@ -185,13 +186,14 @@ step_20_info() {
local ebuTarget="${EBU_TARGET:-}"
[ ! -z "${1:-}" ] && ebuTarget="$1"
if contextHelp; then
echo "Status of (profile) [TARGET]"
echo "Status of (profile)"
elif [ -n "${1:-}" ]; then
echo "Status of target: $ebuTarget"
else
echo "Status of profile \"$seq_profileName\" target: $ebuTarget"
fi
}
step_20_options() { echo '[TARGET]'; }
step_20_alias() { echo 'status'; }
step_20() {
shift
@@ -202,7 +204,8 @@ step_20() {
exe $toolBin collection-status "$ebuTarget"
}
step_22_info() { echo "List backup files [TARGET]"; }
step_22_info() { echo "List backup files"; }
step_22_options() { echo '[TARGET]'; }
step_22_alias() { echo 'list'; }
step_22() {
shift
@@ -230,6 +233,7 @@ step_70_info() {
echoinfo " --remove, -r : remove cron file"
}
step_70_alias() { echo 'cron'; }
step_70_options() { echo '[OPTIONS]'; }
step_70() {
shift
local arg

View File

@@ -114,7 +114,7 @@ step_14() {
readDomain() {
if [ "$myDomain" == "" ] ; then
read -p "Enter your domain: " myDomain
endCheckEmpty myDomain "$toolName domain"
endIfEmpty myDomain "$toolName domain"
fi
}
@@ -123,7 +123,7 @@ readUser() {
if [ "$myUser" == "" ] ; then
read -p "Enter user name: " myUser
echo
endCheckEmpty myUser "$toolName user name"
endIfEmpty myUser "$toolName user name"
fi
}
@@ -138,7 +138,7 @@ readUserPass() {
echo "[ERROR] Passwords don't match"
return 1;
fi
endCheckEmpty myPass "$toolName user password"
endIfEmpty myPass "$toolName user password"
fi
}

View File

@@ -1,27 +1,21 @@
#!/bin/bash
toolName=element-web
latestUrl="https://api.github.com/repos/vector-im/element-web/releases/latest"
readonly toolName=element-web
readonly latestUrl="https://api.github.com/repos/vector-im/element-web/releases/latest"
# Get script working directory
# (when called from a different directory)
WDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >>/dev/null 2>&1 && pwd )"
CONFIG=0
CONFIG_FILE_NAME="${toolName}.cfg"
CONFIG_FILE_TEMPLATE="$WDIR/${CONFIG_FILE_NAME}.example"
sq_config=0
seq_config() {
initSeqConfig "$CONFIG_FILE_NAME" "$CONFIG_FILE_TEMPLATE"
if [ $? -eq 0 ] ; then
if initSeqConfig "${seq_configName:?}" "${seq_configTemplate:?}" ; then
echo " ${toolName} path: ${ELEMENT_WEB_LOC}"
echo " ${toolName} backup: ${ELEMENT_WEB_BACKUP}"
CONFIG=1
sq_config=1
fi
}
step_18_info() { echo "Check for updates"; }
step_18_alias() { echo "updatecheck"; }
step_18() {
step_1_info() { echo "Check for updates"; }
step_1_alias() { echo "updatecheck"; }
step_1() {
shift
local latestVersion=
if [ ! -z "${1:-}" ] ; then
@@ -30,8 +24,8 @@ step_18() {
latestVersion=$(curl --silent "$latestUrl" | grep -Po '"tag_name": "v\K.*?(?=")')
fi
local isInstalled=$(grep -E "${latestVersion}" "${ELEMENT_WEB_LOC}/version" >>/dev/null && echo "1" || echo "0")
if [ $isInstalled -eq 1 ] ; then
local isInstalled=$(grep -E "${latestVersion}" "${ELEMENT_WEB_LOC:-}/version" >>/dev/null 2>&1 && echo "1" || echo "0")
if (( isInstalled )) ; then
echo " [I] Version $latestVersion is already installed"
return 1
else
@@ -42,18 +36,19 @@ step_18() {
step_20_info() {
echo -n "Create a backup [ELEMENT WEB ROOT]"
if [ $CONFIG -ne 0 ] ; then
echo -n "Create a backup"
if (( sq_config )) ; then
echo " at $ELEMENT_WEB_BACKUP"
else
echo
fi
}
step_20_options() { echo "[ELEMENT WEB ROOT]"; }
step_20_alias() { echo "backup"; }
step_20() {
shift
local tempRoot=
if [ $CONFIG -eq 0 ] ; then
if (( ! sq_config )) ; then
error -e "No configuration file found"
return 1
fi
@@ -79,12 +74,13 @@ step_22_info() {
if ! contextHelp ; then
echo ": $(curl --silent "$latestUrl" | grep -Po '"tag_name": "\K.*?(?=")')"
else
echo " [CUSTOM VERSION]"
echo
fi
else
echo "Get version $1 from github"
fi
}
step_22_options() { echo "[CUSTOM VERSION]"; }
step_22_alias() { echo "upgrade"; }
step_22() {
shift # don't need step number
@@ -160,5 +156,7 @@ step_24() {
exe rm -rf "$tempDown"
}
# shellcheck disable=SC2034 # Appears unused
readonly sqr_minVersion=16
# shellcheck disable=SC1091 # Don't follow this source
. /usr/local/bin/sequencer.sh

View File

@@ -15,7 +15,7 @@ seq_config() {
step_20_info() {
shift
echo -n "Create a backup"
if [ $sq_config -ne 0 ] ; then
if (( sq_config )) ; then
echo " at $FR_BACKUP"
else
echo
@@ -26,7 +26,7 @@ step_20_alias() { echo "backup"; }
step_20() {
shift
local tempRoot=
if [ $sq_config -eq 0 ] ; then
if (( ! sq_config )) ; then
error -e "No configuration file found"
return 1
fi
@@ -61,12 +61,13 @@ step_22_info() {
if ! contextHelp ; then
echo ": $(curl --silent "$latestUrl" | grep -Po '"tag_name": "\K.*?(?=")')"
else
echo " [CUSTOM VERSION]"
echo
fi
else
echo "Get version $1 from github"
fi
}
step_22_options() { echo "[CUSTOM VERSION]"; }
step_22_alias() { echo "upgrade"; }
step_22() {
shift # don't need step number

View File

@@ -3,42 +3,27 @@
#
## Installation of self hosted git service Gitea
toolName="gitea"
# Get script working directory
# (when called from a different directory)
WDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >>/dev/null 2>&1 && pwd)"
APTOPT=
CONFIG=0
SCRIPT_FILE=$(basename -- $0)
SCRIPT_NAME=${SCRIPT_FILE%%.*}
CONFIG_FILE_NAME="${SCRIPT_NAME}.cfg"
CONFIG_FILE_TEMPLATE="$WDIR/${CONFIG_FILE_NAME}.example"
readonly toolName="gitea"
readonly giteaLatestUrl="https://api.github.com/repos/go-gitea/gitea/releases/latest"
readonly giteaVersion=$(curl --silent "$giteaLatestUrl" | grep -Po '"tag_name": "v\K.*?(?=")')
readonly giteaDir="/usr/local/bin"
readonly giteaServiceLoc="/etc/systemd/system/gitea.service"
readonly giteaLogDir="/var/log/gitea"
readonly giteaDownFile="/tmp/giteaDown"
readonly giteaUser="git"
giteaLatestUrl="https://api.github.com/repos/go-gitea/gitea/releases/latest"
giteaVersion=$(curl --silent "$giteaLatestUrl" | grep -Po '"tag_name": "v\K.*?(?=")')
giteaArch=
giteaDownloadEval='https://dl.gitea.io/gitea/${giteaVersion}/gitea-${giteaVersion}-linux-${giteaArch}'
giteaDownload=$(eval echo $giteaDownloadEval)
giteaDir="/usr/local/bin"
giteaServiceLoc="/etc/systemd/system/gitea.service"
giteaLogDir="/var/log/gitea"
giteaIniLoc=
giteaDownFile="/tmp/giteaDown"
giteaUser="git"
versionNow=
seq_config() {
initSeqConfig "$CONFIG_FILE_NAME" "$CONFIG_FILE_TEMPLATE"
if [ $? -eq 0 ] ; then
CONFIG=1
else
if ! initSeqConfig "${seq_configName:?}" "${seq_configTemplate:?}" ; then
# End if no configuration file exists
dry || return -1
dry || return 1
fi
## Apt cmdline option to suppress user interaction
quiet && APTOPT="-y"
if [ -z $giteaVersion ] ; then
error -e "Couldn't determine latest version of $toolName"
fi
@@ -60,12 +45,13 @@ seq_config() {
}
checkArchitecture() {
[ -n "$giteaArch" ] && return 0
[ ! -z "$(command -v dpkg)" ] && giteaArch=$(dpkg --print-architecture)
case $giteaArch in
armhf)
giteaArch="arm-6";;
esac
giteaDownload=$(eval echo $giteaDownloadEval)
giteaDownload="$(eval echo $giteaDownloadEval)"
}
step_1_info() { echo "Updating apt"; }
@@ -75,14 +61,12 @@ step_1() {
}
step_2_info() {
[ -z "$giteaArch" ] && checkArchitecture
checkArchitecture
echo "Downloading $toolName to user home from:"
echoinfo "$giteaDownload"
}
step_2() {
exe wget -O "$giteaDownFile" $giteaDownload
saveReturn $?
endReturn
}
step_3_info() { echo "Adding user for $toolName ($giteaUser)"; }
@@ -95,8 +79,6 @@ step_3() {
--disabled-password \
--home "$SEQ_GITEA_HOME_DIR" \
"$SEQ_GITEA_USER"
saveReturn $?
endReturn
}
step_4_info() { echo "Create required directory structure"; }
@@ -108,9 +90,9 @@ step_4() {
exe chmod 770 $SEQ_GITEA_CONF_DIR
info "Creating $giteaLogDir"
exe install -g $SEQ_GITEA_USER -m 770 -d "$giteaLogDir"
sqr::echo -n "Copying gitea to global location and making it executable..."
exe install -b -m 755 -T "$giteaDownFile" "$SEQ_GITEA_BIN_LOC" && sqr::echo "ok"
endReturn "Failed to install $SEQ_GITEA_BIN_LOC"
info -n "Copying gitea to global location and making it executable..."
exe install -b -m 755 -T "$giteaDownFile" "$SEQ_GITEA_BIN_LOC" && info -d "ok"
endReturn -o $? "Failed to install $SEQ_GITEA_BIN_LOC"
}
step_5_info() { echo "Creating systemd service"; }
@@ -158,7 +140,7 @@ NOTES_END
step_10_info() { echo "Create mysql database for $toolName"; }
step_10() {
exe "$WDIR/mysql.sh" -qq createdb --charset utf8mb4
exe "${seq_origin}/mysql.sh" -qq createdb --charset utf8mb4
}
step_12_info() {
@@ -175,7 +157,7 @@ step_12_info() {
}
step_12_alias() { echo "upgrade"; }
step_12() {
endCheckEmpty versionNow "Please install $toolName first"
endIfEmpty versionNow "Please install $toolName first"
exe wget -O "$giteaDownFile" $giteaDownload
endReturn -o $? "Download failed"
@@ -204,5 +186,7 @@ step_22() {
exe vi "$giteaIniLoc"
}
# shellcheck disable=SC2034 # Appears unused
readonly sqr_minVersion=16
# shellcheck disable=SC1091 # Don't follow this source
. /usr/local/bin/sequencer.sh

View File

@@ -1,29 +1,29 @@
#!/bin/bash
toolName="ldap"
toolDaemon="slapd"
toolDeps="$toolDaemon ldap-utils"
toolUser="openldap"
readonly toolName="ldap"
readonly toolDaemon="slapd"
readonly toolDeps="$toolDaemon ldap-utils"
readonly toolUser="openldap"
# Get script working directory
# (when called from a different directory)
WDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >>/dev/null 2>&1 && pwd )"
CONFIG=0
CONFIG_FILE_NAME="${toolName}.cfg"
CONFIG_FILE_TEMPLATE="$WDIR/${CONFIG_FILE_NAME}.example"
sq_aptOpt=
seq_config() {
initSeqConfig "$CONFIG_FILE_NAME" "$CONFIG_FILE_TEMPLATE"
if [ $? -eq 0 ] ; then
CONFIG=1
if ! initSeqConfig "${seq_configName:?}" "${seq_configTemplate:?}" ; then
# End if no configuration file exists
dry || return 1
fi
## Apt cmdline option to suppress user interaction
interactive || sq_aptOpt="-y"
return 0
}
step_1_info() { echo "$toolName installation"; }
step_1_alias() { echo "install"; }
step_1() {
exe apt update
exe apt install $toolDeps
exe apt install $toolDeps ${sq_aptOpt}
}
step_2_info() { echo "Configuration of $toolName"; }
@@ -161,7 +161,8 @@ E0F
NOTES_EOF
}
step_100_info() { echo "Add group <GROUP NAME> <USER ID>"; }
step_100_info() { echo "Add group"; }
step_100_options() { echo "<GROUP NAME> <USER ID>"; }
step_100_alias() { echo "addgroup"; }
step_100() {
shift
@@ -177,7 +178,8 @@ description: Created by $0
member: \${memberDn}
"
step_102_info() { echo "Add user <USER ID> <USER NAME> <USER LASTNAME> <UIDNUMBER> <USER EMAIL> [USER GID]"; }
step_102_info() { echo "Add user"; }
step_102_options() { echo "<USER ID> <USER NAME> <USER LASTNAME> <UIDNUMBER> <USER EMAIL> [USER GID]"; }
step_102_alias() { echo "adduser"; }
step_102() {
shift
@@ -214,7 +216,8 @@ objectClass: person
loginShell: /bin/bash
"
step_103_info() { echo "(re)Set passwort for <USER>"; }
step_103_info() { echo "(re)Set passwort for user"; }
step_103_options() { echo "<USER>"; }
step_103_alias() { echo "passwd"; }
step_103() {
shift
@@ -230,7 +233,8 @@ step_103() {
exe ldappasswd -H ldapi:/// -x -D "cn=admin,$LDAP_DC" -W -S "uid=$userId,$LDAP_OU_USERS,$LDAP_DC"
}
step_105_info() { echo "Adding <USER ID> to existing group <GROUP NAME>"; }
step_105_info() { echo "Adding user to existing group"; }
step_105_options() { echo "<USER ID> <GROUP NAME>"; }
step_105_alias() { echo "user2group"; }
step_105() {
shift
@@ -265,7 +269,8 @@ delete: member
member:
"
step_107_info() { echo "Removing <USER ID> from existing group <GROUP NAME>"; }
step_107_info() { echo "Removing user from existing group"; }
step_107_options() { echo "<USER ID> <GROUP NAME>"; }
step_107_alias() { echo "rmusergroup"; }
step_107() {
shift
@@ -299,7 +304,8 @@ delete: member
member: uid=\$userId,\$LDAP_OU_USERS,\$LDAP_DC
"
step_110_info() { echo "Remove group <GROUP NAME>"; }
step_110_info() { echo "Remove group"; }
step_110_options() { echo "<GROUP NAME>"; }
step_110_alias() { echo "rmgroup"; }
step_110() {
shift
@@ -314,7 +320,8 @@ rmGroup="dn: cn=\${groupName},\${LDAP_OU_GROUPS},\${LDAP_DC}
changetype: delete
"
step_112_info() { echo "Remove user <USER ID>"; }
step_112_info() { echo "Remove user"; }
step_112_options() { echo "<USER ID>"; }
step_112_alias() { echo "rmuser"; }
step_112() {
shift
@@ -329,7 +336,8 @@ rmUser="dn: uid=\${userName},\${LDAP_OU_USERS},\${LDAP_DC}
changetype: delete
"
step_200_info() { echo "List available groups <ADDITONAL ATTRIBUTES...>"; }
step_200_info() { echo "List available groups"; }
step_200_options() { echo "<ADDITONAL ATTRIBUTES...>"; }
step_200_alias() { echo "listgroups"; }
step_200() {
shift
@@ -337,7 +345,8 @@ step_200() {
exe ldapsearch -x -LLL -H ldap:/// -b ${LDAP_OU_GROUPS},${LDAP_DC} dn gidNumber $*
}
step_202_info() { echo "List available users <ADDITONAL ATTRIBUTES...>"; }
step_202_info() { echo "List available users"; }
step_200_options() { echo "<ADDITONAL ATTRIBUTES...>"; }
step_202_alias() { echo "listusers"; }
step_202() {
shift
@@ -364,5 +373,7 @@ variable2LdifEcho() {
echo "$tempLdif"
}
# shellcheck disable=SC2034 # Appears unused
readonly sqr_minVersion=16
# shellcheck disable=SC1091 # Don't follow this source
. /usr/local/bin/sequencer.sh

View File

@@ -525,15 +525,15 @@ MIGRATE_END
readDatabaseInfos() {
if [ "$postgresDb" == "" ] ; then
read -p "Enter postgres database name: " postgresDb
endCheckEmpty postgresDb "database"
endIfEmpty postgresDb "database"
fi
if [ "$postgresUser" == "" ] ; then
read -p "Enter postgres user name: " postgresUser
endCheckEmpty postgresUser "user name"
endIfEmpty postgresUser "user name"
fi
if [ "$postgresPass" == "" ] ; then
read -s -p "Enter postgres password: " postgresPass
endCheckEmpty postgresPass "password"
endIfEmpty postgresPass "password"
fi
echo
}

View File

@@ -209,15 +209,15 @@ step_22() {
readDatabaseInfos() {
if [ -z "$postgresDb" ] ; then
read -p "Enter postgres database name: " postgresDb
endCheckEmpty postgresDb "database"
endIfEmpty postgresDb "database"
fi
if [ -z "$postgresUser" ] ; then
read -p "Enter postgres user name: " postgresUser
endCheckEmpty postgresUser "user name"
endIfEmpty postgresUser "user name"
fi
if [ -z "$postgresPass" ] ; then
read -s -p "Enter postgres password: " postgresPass
endCheckEmpty postgresPass "password"
endIfEmpty postgresPass "password"
fi
info
}

View File

@@ -3,20 +3,12 @@
# Dependency to other seqs
# - mysql.sh (soft; Missing informational output)
toolName="nextcloud"
readonly toolName="nextcloud"
localOcc=("echo" "occ not found!")
# Get script working directory
# (when called from a different directory)
sq_dir="$( cd "$( dirname -- "$(realpath "${BASH_SOURCE[0]}")")" >>/dev/null 2>&1 && pwd )"
sq_config=0
sq_configFileName="${toolName}.cfg"
sq_configFileTemplate="$sq_dir/${sq_configFileName}.example"
seq_config() {
## or to use sequencer api:
initSeqConfig "$sq_configFileName" "$sq_configFileTemplate"
if [ $? -eq 0 ] ; then
if initSeqConfig "${seq_configName:?}" "${seq_configTemplate:?}" ; then
sq_config=1
fi
localOcc=( sudo -u $sc_ncServerUser php "$(escpath "$sc_ncInstallDir/occ")" )
@@ -34,7 +26,7 @@ step_1() {
step_20_info() { echo "Upgrade $toolName on command line to latest version of selected release channel"; }
step_20_alias() { echo "upgrade"; }
step_20() {
if [ $sq_config -eq 0 ] ; then
if (( ! sq_config )) ; then
error -e "No configuration found to determine installation directory"
return 1
fi
@@ -64,9 +56,9 @@ step_102() {
if [ -z $1 ] ; then
error -e "No database provided"
if [ -f "${sq_dir}/mysql.sh" ] ; then
if [ -f "${seq_origin}/mysql.sh" ] ; then
echo " [I] Available mysql databases:"
"${sq_dir}/mysql.sh" -qq listdb
"${seq_origin}/mysql.sh" -qq listdb
fi
return 1
else
@@ -147,5 +139,7 @@ occ config:app:set preview jpeg_quality --value="60"
NOTES_END
}
# shellcheck disable=SC2034 # Appears unused
readonly sqr_minVersion=16
# shellcheck disable=SC1091 # Don't follow this source
. /usr/local/bin/sequencer.sh

View File

@@ -160,15 +160,15 @@ step_24() {
readDatabaseInfos() {
if [ "$postgresDb" == "" ] ; then
read -p "Enter postgres database name: " postgresDb
endCheckEmpty postgresDb "database"
endIfEmpty postgresDb "database"
fi
if [ "$postgresUser" == "" ] ; then
read -p "Enter postgres user name: " postgresUser
endCheckEmpty postgresUser "user name"
endIfEmpty postgresUser "user name"
fi
if [ "$postgresPass" == "" ] ; then
read -s -p "Enter postgres password: " postgresPass
endCheckEmpty postgresPass "password"
endIfEmpty postgresPass "password"
fi
echo
}

View File

@@ -1,31 +1,22 @@
#!/bin/bash
toolName="pyload"
toolBranch="stable"
toolDownload="https://github.com/pyload/pyload.git"
toolDeps="git liblept5 python python-crypto python-pycurl python-imaging python-sleekxmpp tesseract-ocr zip unzip python-openssl libmozjs-24-bin"
readonly toolName="pyload"
readonly toolBranch="stable"
readonly toolDownload="https://github.com/pyload/pyload.git"
readonly toolDeps="git liblept5 python python-crypto python-pycurl python-imaging python-sleekxmpp tesseract-ocr zip unzip python-openssl libmozjs-24-bin"
# python-cryptography shall be implemented in future releases and replace pyhton-crypto
toolDepsDebian="sudo git python-crypto python-pycurl python-pil python-sleekxmpp tesseract-ocr zip unzip pyhton-openssl libmozjs-60-dev"
toolBuildDeps="rar unrar-nonfree"
readonly toolDepsDebian="sudo git python-crypto python-pycurl python-pil python-sleekxmpp tesseract-ocr zip unzip pyhton-openssl libmozjs-60-dev"
readonly toolBuildDeps="rar unrar-nonfree"
# Get script working directory
# (when called from a different directory)
WDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >>/dev/null 2>&1 && pwd)"
APTOPT=
CONFIG=0
SCRIPT_NAME=$(basename -- $0)
SCRIPT_NAME=${SCRIPT_NAME%%.*}
CONFIG_FILE_NAME="${SCRIPT_NAME}.cfg"
CONFIG_FILE_TEMPLATE="$WDIR/${CONFIG_FILE_NAME}.example"
sq_aptOpt=
seq_config() {
initSeqConfig "$CONFIG_FILE_NAME" "$CONFIG_FILE_TEMPLATE"
if [ $? -eq 0 ] ; then
CONFIG=1
else
if ! initSeqConfig "${seq_configName:?}" "${seq_configTemplate:?}" ; then
# End if no configuration file exists
dry || return 1
fi
quiet && APTOPT="-y"
interactive || sq_aptOpt="-y"
return 0
}
@@ -41,7 +32,7 @@ step_1() {
step_2_info() { echo "Install unrar-nonfree from source"; }
step_2() {
exe apt-get build-dep ${toolBuildDeps} $APTOPT
exe apt-get build-dep ${toolBuildDeps} ${sq_aptOpt}
exe cd /tmp
exe apt-get source -b unrar-nonfree
saveReturn $?
@@ -69,7 +60,7 @@ step_3() {
error -e "Unrecognized target"
return 1;;
esac
exe apt-get install ${lDeps} $APTOPT
exe apt-get install ${lDeps} ${sq_aptOpt}
saveReturn $?
endReturn
case "${1:-}" in
@@ -134,5 +125,7 @@ step_10() {
echo " Do so manually with: service $toolName start"
}
# shellcheck disable=SC2034 # Appears unused
readonly sqr_minVersion=16
# shellcheck disable=SC1091 # Don't follow this source
. /usr/local/bin/sequencer.sh

View File

@@ -124,7 +124,7 @@ step_52_options() { echo "<TORRENT ID>"; }
step_52_alias() { echo "info"; }
step_52() {
shift
endCheckEmpty 1 "Id must not be empty"
endIfEmpty 1 "Id must not be empty"
step netrcauth
color green

View File

@@ -73,7 +73,7 @@ step_24() {
shift
local destIp=${1:-}
local ipregex='^[0-2]*[0-9]{1,2}\.[0-2]*[0-9]{1,2}\.[0-2]*[0-9]{1,2}\.[0-2]*[0-9]{1,2}\/*[0-9]*$'
endCheckEmpty destIp "No IP provided"
endIfEmpty destIp "No IP provided"
if [[ ! ${1:-} =~ $ipregex ]]; then
error "No valid IP provided"
return 1