refactoring changes from sequpgrade (endReturn, ...) and some modernizations
This commit is contained in:
@@ -152,7 +152,7 @@ step_3() {
|
||||
if [ $noRemount -eq 0 ]; then
|
||||
# remount target to be writable
|
||||
exep "mount -o rw,remount '${buTarget}' >>/dev/null 2>&1"
|
||||
endReturn -o $? "Remount (${buTarget}) to be writable failed"
|
||||
endReturn "Remount (${buTarget}) to be writable failed"
|
||||
fi
|
||||
|
||||
if [ ! -w "${buTarget}" ] ; then
|
||||
|
@@ -16,7 +16,7 @@ step_10_info() { echo "ssmtp installation"; }
|
||||
step_10_alias() { echo "ssmtp"; }
|
||||
step_10() {
|
||||
exe apt update && apt install $SSMTP_DEPS
|
||||
endReturn -o $? "ssmtp installation failed"
|
||||
endReturn "ssmtp installation failed"
|
||||
}
|
||||
SSMTP_DEPS="ssmtp"
|
||||
|
||||
@@ -29,7 +29,7 @@ step_11() {
|
||||
return 1
|
||||
fi
|
||||
addConf -c -f "$CONFIG_FILE_SSMTP" "$CONFIG_LOC_SSMTP"
|
||||
endReturn -o $? "Could not write ssmtp configuration"
|
||||
endReturn "Could not write ssmtp configuration"
|
||||
|
||||
if [ ! -f "$CONFIG_FILE_SSMTP_AL" ] ; then
|
||||
warning -e "User aliases ($CONFIG_FILE_SSMTP_AL) not found"
|
||||
@@ -37,7 +37,7 @@ step_11() {
|
||||
return 1
|
||||
fi
|
||||
addConf -c -f "$CONFIG_FILE_SSMTP_AL" "$CONFIG_LOC_SSMTP_AL"
|
||||
endReturn -o $? "Could not write ssmtp aliases"
|
||||
endReturn "Could not write ssmtp aliases"
|
||||
}
|
||||
CONFIG_LOC_SSMTP="/etc/ssmtp/ssmtp.conf"
|
||||
CONFIG_LOC_SSMTP_AL="/etc/ssmtp/revaliases"
|
||||
|
@@ -48,7 +48,7 @@ step_2() {
|
||||
fi
|
||||
if [ ! -e "$CALWEB_VENV_ROOT/bin" ]; then
|
||||
exe python3 -m venv "$CALWEB_VENV_ROOT"
|
||||
endReturn -o $? "Creating virtual environment failed"
|
||||
endReturn "Creating virtual environment failed"
|
||||
exe chown -R ${CALWEB_USER}: "$CALWEB_BASE"
|
||||
else
|
||||
warning "Virtual env. $CALWEB_VENV_ROOT already exists"
|
||||
|
@@ -38,7 +38,7 @@ step_1() {
|
||||
osName="Ubuntu"
|
||||
fi
|
||||
|
||||
echo " [I] Detected OS: $osName $distName"
|
||||
info "Detected OS: $osName $distName"
|
||||
|
||||
if [ "$osName" == "Ubuntu" ] ; then
|
||||
exe apt-get update
|
||||
|
@@ -34,7 +34,7 @@ step_1() {
|
||||
exe apt update
|
||||
exe apt install $toolDeps $APTOPT
|
||||
exe pip install --upgrade pyopenssl
|
||||
endReturn -o $? "Pip install pyopenssl failed"
|
||||
endReturn "Pip install pyopenssl failed"
|
||||
}
|
||||
|
||||
step_2_info() { echo "Clone git repository"; }
|
||||
@@ -51,7 +51,7 @@ step_3() {
|
||||
step_4_info() { echo "Create systemd service"; }
|
||||
step_4() {
|
||||
exe cp "$CPO_INSTALL_DIR/init/couchpotato.service" "/etc/systemd/system"
|
||||
endReturn -o $? "Creating service file failed"
|
||||
endReturn "Creating service file failed"
|
||||
exe systemctl daemon-reload
|
||||
}
|
||||
|
||||
|
@@ -50,18 +50,18 @@ step_1() {
|
||||
|
||||
if [ ! -f "$downShaFile" ] ; then
|
||||
exe wget -O "$downShaFile" "$downSha256"
|
||||
endReturn -o $? "Error downloading $downShaFile"
|
||||
endReturn "Error downloading $downShaFile"
|
||||
fi
|
||||
|
||||
if [ ! -f "$toolDownFile" ] ; then
|
||||
exe wget -O "$toolDownFile" "$toolDownUrl"
|
||||
endReturn -o $? "Error downloading $downDownFile"
|
||||
endReturn "Error downloading $downDownFile"
|
||||
fi
|
||||
|
||||
info "Checking SHA256 checksum"
|
||||
exe cd $(dirname "$toolDownFile")
|
||||
exe sha256sum -c "$downShaFile" >>/dev/null
|
||||
endReturn -o $? "SHA256 checksum error"
|
||||
endReturn "SHA256 checksum error"
|
||||
}
|
||||
|
||||
step_2_info() { echo "Write image to device"; }
|
||||
@@ -73,7 +73,7 @@ step_2() {
|
||||
fi
|
||||
read_sd_dev "$SDDEV"
|
||||
# check if device was confirmed
|
||||
endReturn -o $? "SD card device not found"
|
||||
endReturn "SD card device not found"
|
||||
|
||||
info "Writing $(basename "$toolDownFile")"
|
||||
exep "xzcat \"$toolDownFile\" | dd of=$SDDEV bs=64k oflag=dsync status=progress"
|
||||
@@ -143,7 +143,7 @@ step_12() {
|
||||
fi
|
||||
|
||||
exe sed -i "s/#[[:space:]]*\($localUsDefault\)/\1/" "$localesConfigLoc"
|
||||
endReturn -o $? "Changing locales failed"
|
||||
endReturn "Changing locales failed"
|
||||
exe locale-gen
|
||||
exe update-locale LANG=$localUs
|
||||
info "Logout and login for changes to be active"
|
||||
@@ -162,7 +162,7 @@ step_14() {
|
||||
return 0
|
||||
fi
|
||||
exe hostnamectl set-hostname "$localHostname"
|
||||
endReturn -o $? "Couldn't set hostname"
|
||||
endReturn "Couldn't set hostname"
|
||||
exe sed -i "s/^\(127\.0\.0\.1[[:space:]]*\)\(localhost.*\)/\1\2\n\1$localHostname/" "$hostsLoc"
|
||||
}
|
||||
hostsLoc="/etc/hosts"
|
||||
@@ -255,7 +255,7 @@ read_sd_dev() {
|
||||
SDROOTDEV=
|
||||
SDBOOTPUUID=
|
||||
SDROOTPUUID=
|
||||
echo " [I] Available devices:"
|
||||
info "Available devices:"
|
||||
echo
|
||||
exe lsblk -p
|
||||
echo
|
||||
|
@@ -278,7 +278,7 @@ step_14() {
|
||||
local bazarrGitUrl="https://github.com/morpheus65535/bazarr.git"
|
||||
|
||||
exe python3 -m venv "$bazarrVenv"
|
||||
endReturn -o $? "Creating virtual environment failed"
|
||||
endReturn "Creating virtual environment failed"
|
||||
|
||||
exe git clone $bazarrGitUrl "$bazarrDir"
|
||||
exe chown -R $DLD_USER: "$bazarrVenv"
|
||||
@@ -340,15 +340,15 @@ step_16() {
|
||||
local buildPath="/tmp/unrarbuild"
|
||||
|
||||
cat /etc/apt/sources.list | grep -E "^deb-src" >>/dev/null 2>&1
|
||||
endReturn -o $? "No deb-src entry found in /etc/apt/sources.list"
|
||||
endReturn "No deb-src entry found in /etc/apt/sources.list"
|
||||
|
||||
exe mkdir -p "$buildPath"
|
||||
exe cd "$buildPath"
|
||||
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)"
|
||||
endReturn "unrar-nonfree build failed ($buildPath left untouched)"
|
||||
exe dpkg -i unrar*.deb
|
||||
endReturn -o $? "unrar-nonfree install failed ($buildPath left untouched)"
|
||||
endReturn "unrar-nonfree install failed ($buildPath left untouched)"
|
||||
|
||||
exe rm -rf "$buildPath"
|
||||
}
|
||||
|
@@ -58,18 +58,18 @@ step_1() {
|
||||
done
|
||||
|
||||
if [ -z $EBU_TARGET ] || [ -z $EBU_SOURCE ] ; then
|
||||
echo " [I] Nothing to do. Check $seq_configFile"
|
||||
info "Nothing to do. Check $seq_configFile"
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [ -n "${1:-}" ] && ( [ "$1" == "full" ] || [ "$1" == "incremental" ] ) ; then
|
||||
dupArgs+=("$1")
|
||||
elif [ -n "${1:-}" ] ; then
|
||||
echo " [W] $toolName command \"$1\" not recognized"
|
||||
warning "$toolName command \"$1\" not recognized"
|
||||
return 1
|
||||
fi
|
||||
|
||||
echo " [I] Running backup profile [$seq_profileName]"
|
||||
info "Running backup profile [$seq_profileName]"
|
||||
|
||||
if [ "${dupArgs[0]:-}" != "full" ] && [ -n "$EBU_MAX_FULLBKP_AGE" ] ; then
|
||||
dupArgs+=(--full-if-older-than "$EBU_MAX_FULLBKP_AGE")
|
||||
@@ -97,7 +97,7 @@ step_3() {
|
||||
shift
|
||||
|
||||
if [ -z $EBU_TARGET ] || [ -z $EBU_SOURCE ] ; then
|
||||
echo " [I] Nothing to do. Check $seq_configFile"
|
||||
info "Nothing to do. Check $seq_configFile"
|
||||
return 1
|
||||
fi
|
||||
|
||||
@@ -260,16 +260,16 @@ step_70() {
|
||||
cronEntry+=" >$cronLog"
|
||||
|
||||
if [ -z "$EBU_CRONTIME" ] || [ $cronRemove -ne 0 ] ; then
|
||||
echo " [I] Removing cron for profile $seq_profileName"
|
||||
info "Removing cron for profile $seq_profileName"
|
||||
exe rm -r "$cronScript"
|
||||
else
|
||||
checkFileHead "$cronScript" "$cronEntry"
|
||||
if [ $? -ne 0 ] ; then
|
||||
echo " [I] Update cron for profile $seq_profileName"
|
||||
info "Update cron for profile $seq_profileName"
|
||||
exep "sudo echo \"$cronEntry\" > \"$cronScript\""
|
||||
syslogEntry "Cron file update complete [$EBU_CRONTIME]"
|
||||
else
|
||||
echo " [I] Cron for profile $seq_profileName is up to date"
|
||||
info "Cron for profile $seq_profileName is up to date"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
@@ -116,10 +116,10 @@ step_22() {
|
||||
if [ ! -e "$tempExtract" ] ; then
|
||||
exe mkdir -p "$tempDown"
|
||||
exe wget -O "$tempLoc" "$downUrl"
|
||||
endReturn -o $? "Download failed: $downUrl"
|
||||
endReturn "Download failed: $downUrl"
|
||||
exe cd "$tempDown"
|
||||
exe tar -xf "$tempLoc"
|
||||
endReturn -o $? "Extract failed: $tempLoc"
|
||||
endReturn "Extract failed: $tempLoc"
|
||||
else
|
||||
info "Found existing download: $tempExtract"
|
||||
fi
|
||||
@@ -130,7 +130,7 @@ step_22() {
|
||||
|
||||
exe mv "$ELEMENT_WEB_LOC" "$tempBu"
|
||||
step backup "$tempBu"
|
||||
endReturn -o $? "Backup failed; $ELEMENT_WEB_LOC renamed!"
|
||||
endReturn "Backup failed; $ELEMENT_WEB_LOC renamed!"
|
||||
info "Installing version $latestVersion to $ELEMENT_WEB_LOC"
|
||||
exe mv "$tempExtract" "$ELEMENT_WEB_LOC"
|
||||
exe chown -R www-data: "$ELEMENT_WEB_LOC"
|
||||
|
16
seqs/fhem.sh
16
seqs/fhem.sh
@@ -34,21 +34,21 @@ step_1() {
|
||||
#exe apt update
|
||||
exe apt install $toolDeps $toolDeps2 "$aptOpt"
|
||||
#exe apt install "$toolDeps2" "$aptOpt"
|
||||
endReturn -o $? "Installation of prerequisits failed"
|
||||
endReturn "Installation of prerequisits failed"
|
||||
}
|
||||
|
||||
step_2_info() { echo "Install jabber prerequisits"; echoinfo "(May be skipped)"; }
|
||||
step_2() {
|
||||
exe apt install $toolDepsJabber "$aptOpt"
|
||||
endReturn -o $? "Installation of prerequisits for jabber failed"
|
||||
endReturn "Installation of prerequisits for jabber failed"
|
||||
}
|
||||
|
||||
step_3_info() { echo "Download and install $toolName version $toolVersion"; }
|
||||
step_3() {
|
||||
exe wget "$toolUrl" -O "$downPath"
|
||||
endReturn -o $? "Download of $toolName failed"
|
||||
endReturn "Download of $toolName failed"
|
||||
exe dpkg -i "$downPath"
|
||||
endReturn -o $? "Installation of $toolName failed"
|
||||
endReturn "Installation of $toolName failed"
|
||||
info "$toolName is now running on http://$(hostname -I | cut -d " " -f 1):8083"
|
||||
}
|
||||
downPath="/tmp/$toolDpkg"
|
||||
@@ -56,14 +56,14 @@ downPath="/tmp/$toolDpkg"
|
||||
step_20_info() { echo "List $toolName prerequisits"; }
|
||||
step_20_alias() { echo "listdeps"; }
|
||||
step_20() {
|
||||
echo " [I] $toolName prerequisits:"
|
||||
info "$toolName prerequisits:"
|
||||
echo "$toolDeps $toolDeps2"
|
||||
}
|
||||
|
||||
step_30_info() { echo "Create user $toolUser"; }
|
||||
step_30() {
|
||||
exe useradd --system --home "$toolHome" --gid dialout --shell /bin/false "$toolUser"
|
||||
endReturn -o $? "Creating user $toolUser failed"
|
||||
endReturn "Creating user $toolUser failed"
|
||||
}
|
||||
|
||||
step_32_info() { echo "Create $toolName systemd service"; }
|
||||
@@ -78,11 +78,11 @@ step_34_alias() { echo "downgrade_xmpp"; }
|
||||
step_34() {
|
||||
if [ ! -f $libnetDown ]; then
|
||||
exe wget "$libnetUrl" -O "$libnetDown"
|
||||
endReturn -o $? "Download of $libnetUrl failed"
|
||||
endReturn "Download of $libnetUrl failed"
|
||||
fi
|
||||
if [ ! -f $libxmlDown ]; then
|
||||
exe wget "$libxmlUrl" -O "$libxmlDown"
|
||||
endReturn -o $? "Download of $libxmlUrl failed"
|
||||
endReturn "Download of $libxmlUrl failed"
|
||||
fi
|
||||
|
||||
local aptOption=
|
||||
|
@@ -39,7 +39,7 @@ step_50() {
|
||||
local frDbSchema="$toolConfLoc/mods-config/sql/main/mysql/schema.sql"
|
||||
local frDbSetup="$toolConfLoc/mods-config/sql/main/mysql/setup.sql"
|
||||
exe "$WDIR"/mysql.sh createdb -c utf8 -d "$FRAD_DB_NAME" -u "$FRAD_DB_USER"
|
||||
endReturn -o $? "Creating database failed"
|
||||
endReturn "Creating database failed"
|
||||
|
||||
exep "mysql -uroot \"$FRAD_DB_NAME\" < $frDbSchema"
|
||||
#exep "mysql -uroot \"$FRAD_DB_NAME\" < $frDbSetup"
|
||||
|
@@ -40,16 +40,16 @@ step_20() {
|
||||
fi
|
||||
|
||||
exe "${seq_dir}/mysql.sh" -qq backup "$FR_DATABASE" "$FR_BACKUP"
|
||||
endReturn -o $? "Backup mysql database failed"
|
||||
endReturn "Backup mysql database failed"
|
||||
|
||||
[ ! -e "$tempRoot" ] && endReturn -o 1 -f "Friendica root $tempRoot not found"
|
||||
|
||||
local wwwBackup="$FR_BACKUP/${toolName}_www_`date +%Y%m%d-%H%M%S`.tar.gz"
|
||||
local dataBackup="$FR_BACKUP/${toolName}_data_`date +%Y%m%d-%H%M%S`.tar.gz"
|
||||
echo " [I] Backing up webserver directory to $wwwBackup"
|
||||
info "Backing up webserver directory to $wwwBackup"
|
||||
exe cd "$tempRoot/.."
|
||||
exe tar czf "$wwwBackup" $(basename "$tempRoot")
|
||||
echo " [I] Backing up data directory to $dataBackup"
|
||||
info "Backing up data directory to $dataBackup"
|
||||
exe cd "$FR_LOC_DATA/.."
|
||||
exe tar czf "$dataBackup" $(basename "$FR_LOC_DATA")
|
||||
}
|
||||
@@ -110,21 +110,21 @@ step_22() {
|
||||
if [ ! -e "$tempExtract" ] ; then
|
||||
exe mkdir -p "$tempDown"
|
||||
exe wget -O "$tempLoc" $downUrl
|
||||
endReturn -o $? "Download failed: $downUrl"
|
||||
endReturn "Download failed: $downUrl"
|
||||
exe cd "$tempDown"
|
||||
exe tar -xf "$tempLoc"
|
||||
endReturn -o $? "Extract failed: $tempLoc"
|
||||
endReturn "Extract failed: $tempLoc"
|
||||
else
|
||||
info "Found existing download: $tempExtract"
|
||||
fi
|
||||
|
||||
if [ ! -e "$tempExtractAddons" ] ; then
|
||||
exe wget -O "$tempLocAddons" $downUrlAddons
|
||||
endReturn -o $? "Download failed: $downUrlAddons"
|
||||
endReturn "Download failed: $downUrlAddons"
|
||||
exe cd "$tempDown"
|
||||
exe mkdir -p "$tempExtractAddons"
|
||||
exe tar -xC "${tempExtractAddons}" -f "$tempLocAddons"
|
||||
endReturn -o $? "Extract failed: $tempLocAddons"
|
||||
endReturn "Extract failed: $tempLocAddons"
|
||||
else
|
||||
info "Found existing download: $tempExtractAddons"
|
||||
fi
|
||||
@@ -135,7 +135,7 @@ step_22() {
|
||||
|
||||
exe mv "$FR_LOC" "$tempBu"
|
||||
step backup "$tempBu"
|
||||
endReturn -o $? "Backup failed; $FR_LOC renamed!"
|
||||
endReturn "Backup failed; $FR_LOC renamed!"
|
||||
info "Installing version $latestVersion to $FR_LOC"
|
||||
exe systemctl stop friendica.service
|
||||
exe mv "$tempExtract" "$FR_LOC"
|
||||
|
31
seqs/git.sh
31
seqs/git.sh
@@ -1,34 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
toolName=git
|
||||
|
||||
# Get script working directory
|
||||
# (when called from a different directory and even when called via symlink)
|
||||
WDIR="$(cd "$(dirname -- "$(realpath ${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"
|
||||
|
||||
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 || return -1
|
||||
#fi
|
||||
|
||||
## Apt cmdline option to suppress user interaction
|
||||
quiet && APTOPT="-y"
|
||||
|
||||
## Return of non zero value will abort the sequence
|
||||
return 0
|
||||
}
|
||||
|
||||
step_1_info() { echo "Setup global git aliases"; }
|
||||
step_1_alias() { echo "alias"; }
|
||||
step_1() {
|
||||
@@ -48,5 +19,7 @@ step_1() {
|
||||
exe git config --global alias.ll 'log'
|
||||
}
|
||||
|
||||
# shellcheck disable=SC2034 # Appears unused
|
||||
readonly sqr_minVersion=16
|
||||
# shellcheck disable=SC1091 # Don't follow this source
|
||||
. /usr/local/bin/sequencer.sh
|
||||
|
@@ -92,7 +92,7 @@ step_4() {
|
||||
exe install -g $SEQ_GITEA_USER -m 770 -d "$giteaLogDir"
|
||||
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"
|
||||
endReturn "Failed to install $SEQ_GITEA_BIN_LOC"
|
||||
}
|
||||
|
||||
step_5_info() { echo "Creating systemd service"; }
|
||||
@@ -159,7 +159,7 @@ step_12_alias() { echo "upgrade"; }
|
||||
step_12() {
|
||||
endIfEmpty versionNow "Please install $toolName first"
|
||||
exe wget -O "$giteaDownFile" $giteaDownload
|
||||
endReturn -o $? "Download failed"
|
||||
endReturn "Download failed"
|
||||
|
||||
if [ -f "$SEQ_GITEA_BIN_LOC" ] ; then
|
||||
local toolBackup="${SEQ_GITEA_BACKUP_DIR}/gitea_${versionNow}"
|
||||
@@ -170,7 +170,7 @@ step_12() {
|
||||
exe cp -ar "$SEQ_GITEA_BIN_LOC" "$toolBackup" && sqr::echo "ok" || sqr::echo "nok"
|
||||
fi
|
||||
exe install --backup=none -m 755 -T "$giteaDownFile" "$SEQ_GITEA_BIN_LOC"
|
||||
endReturn -o $? "Upgrade failed"
|
||||
endReturn "Upgrade failed"
|
||||
exe service gitea start
|
||||
}
|
||||
|
||||
|
@@ -95,7 +95,7 @@ step_22() {
|
||||
fi
|
||||
fi
|
||||
exe wget ${downUrl} -q -O "${sq_grocyDownLoc}"
|
||||
endReturn -o $? "Download failed"
|
||||
endReturn "Download failed"
|
||||
if [ -e "${sc_grocyDir}" ] ; then
|
||||
step backup
|
||||
exe rm -rf "${sc_grocyDir}/${sc_grocyViewcache}"
|
||||
|
112
seqs/jitsi.sh
112
seqs/jitsi.sh
@@ -2,24 +2,6 @@
|
||||
|
||||
toolName="jitsi-meet"
|
||||
|
||||
# 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"
|
||||
|
||||
#step_config() {
|
||||
#echo "Called once before executing steps."
|
||||
## e.g. to source a config file manually:
|
||||
#. "$CONFIG_FILE"
|
||||
## or to use sequencer api:
|
||||
#initSeqConfig "$CONFIG_FILE_NAME" "$CONFIG_FILE_TEMPLATE"
|
||||
#if [ $? -eq 0 ] ; then
|
||||
# CONFIG=1
|
||||
#fi
|
||||
#}
|
||||
|
||||
step_1_info() { echo "Installation of prerequisits"; }
|
||||
step_1_alias() { echo "prepare"; }
|
||||
step_1() {
|
||||
@@ -50,7 +32,7 @@ step_5_info() { echo "Install nginx webserver"; }
|
||||
step_5_alias() { echo "webserver"; }
|
||||
step_5() {
|
||||
exe apt install nginx
|
||||
endReturn -o $? "Installation of webserver nginx failed"
|
||||
endReturn "Installation of webserver nginx failed"
|
||||
exe mkdir -p /etc/nginx/sites-available
|
||||
exe mkdir -p /etc/nginx/sites-enabled
|
||||
exe mkdir -p /etc/nginx/modules-enabled
|
||||
@@ -61,12 +43,12 @@ step_6_info() { echo "Install ufw firewall"; }
|
||||
step_6_alias() { echo "firewall"; }
|
||||
step_6() {
|
||||
exe apt install ufw
|
||||
endReturn -o $? "Installation of firewall ufw failed"
|
||||
endReturn "Installation of firewall ufw failed"
|
||||
}
|
||||
|
||||
step_7_info() { echo "Setup ufw firewall to run $toolName"; }
|
||||
step_7() {
|
||||
echo " [I] Configure ufw firewall"
|
||||
info "Configure ufw firewall"
|
||||
exe ufw allow 22/tcp
|
||||
exe ufw allow 80/tcp
|
||||
exe ufw allow 443/tcp
|
||||
@@ -87,57 +69,61 @@ step_9() {
|
||||
exe mv /etc/nginx/sites-available/*.conf /etc/nginx/conf.d
|
||||
exe mv /etc/nginx/conf.d/default.conf /etc/nginx/sites-available
|
||||
exe service nginx restart
|
||||
echo " [I] Check /etc/nginx/conf.d for unwanted configurations"
|
||||
info "Check /etc/nginx/conf.d for unwanted configurations"
|
||||
}
|
||||
|
||||
step_10_info() { echo "WIP post-install tasks"; }
|
||||
step_10() {
|
||||
echo " [I] Tasks to be automated"
|
||||
echo
|
||||
echo " * Make jitsi installation password protected"
|
||||
echo " (https://github.com/jitsi/jicofo#secure-domain)"
|
||||
echo " Creating new rooms will require username and password"
|
||||
echo
|
||||
echo " ** /etc/prosody/conf.avail/[your-hostname].cfg.lua"
|
||||
echo
|
||||
echo " a) Enable authentication on your main domain:"
|
||||
echo
|
||||
echo " VirtualHost \"jitsi-meet.example.com\""
|
||||
echo " authentication = \"internal_plain\""
|
||||
echo
|
||||
echo " b) Add new virtual host with anonymous login method for guests:"
|
||||
echo
|
||||
echo " VirtualHost \"guest.jitsi-meet.example.com\""
|
||||
echo " authentication = \"anonymous\""
|
||||
echo " c2s_require_encryption = false"
|
||||
echo
|
||||
echo " ** /etc/jitsi/meet/[your-hostname]-config.js"
|
||||
echo
|
||||
echo " var config = {"
|
||||
echo " hosts: {"
|
||||
echo " domain: 'jitsi-meet.example.com',"
|
||||
echo " anonymousdomain: 'guest.jitsi-meet.example.com',"
|
||||
echo " ..."
|
||||
echo " },"
|
||||
echo " ..."
|
||||
echo " }"
|
||||
echo
|
||||
echo " ** /etc/jitsi/jicofo/sip-communicator.properties"
|
||||
echo " add new line:"
|
||||
echo
|
||||
echo " org.jitsi.jicofo.auth.URL=XMPP:jitsi-meet.example.com"
|
||||
echo
|
||||
echo " ** Create prosody user(s):"
|
||||
echo
|
||||
echo " prosodyctl register <username> jitsi-meet.example.com <password>"
|
||||
echo
|
||||
echo " [I] Use step \"restart\" after these changes"
|
||||
color green
|
||||
cat << WIP_END
|
||||
# Tasks to be automated
|
||||
|
||||
* Make jitsi installation password protected
|
||||
(https://github.com/jitsi/jicofo#secure-domain)
|
||||
Creating new rooms will require username and password
|
||||
|
||||
** /etc/prosody/conf.avail/[your-hostname].cfg.lua
|
||||
|
||||
a) Enable authentication on your main domain:
|
||||
|
||||
VirtualHost "jitsi-meet.example.com"
|
||||
authentication = "internal_plain"
|
||||
|
||||
b) Add new virtual host with anonymous login method for guests:
|
||||
|
||||
VirtualHost "guest.jitsi-meet.example.com"
|
||||
authentication = "anonymous"
|
||||
c2s_require_encryption = false
|
||||
|
||||
** /etc/jitsi/meet/[your-hostname]-config.js
|
||||
|
||||
var config = {
|
||||
hosts: {
|
||||
domain: 'jitsi-meet.example.com',
|
||||
anonymousdomain: 'guest.jitsi-meet.example.com',
|
||||
...
|
||||
},
|
||||
...
|
||||
}
|
||||
|
||||
** /etc/jitsi/jicofo/sip-communicator.properties
|
||||
add new line:
|
||||
|
||||
org.jitsi.jicofo.auth.URL=XMPP:jitsi-meet.example.com
|
||||
|
||||
** Create prosody user(s):
|
||||
|
||||
prosodyctl register <username> jitsi-meet.example.com <password>
|
||||
|
||||
WIP_END
|
||||
color none
|
||||
info "Use step \"restart\" after these changes"
|
||||
}
|
||||
|
||||
step_20_info() { echo "Restart all $toolName components"; }
|
||||
step_20_alias() { echo "restart"; }
|
||||
step_20() {
|
||||
echo " [I] Restart jitsi-meet components"
|
||||
info "Restart jitsi-meet components"
|
||||
exep "service prosody restart&& service jicofo restart && service jitsi-videobridge2 restart"
|
||||
}
|
||||
|
||||
|
26
seqs/ldap.sh
26
seqs/ldap.sh
@@ -98,11 +98,11 @@ objectClass: organizationalUnit
|
||||
step_8_info() { echo "Setup SSL secured ldaps:// access"; }
|
||||
step_8() {
|
||||
sudo -u $toolUser test -r "$LDAP_CERT_KEY" >>/dev/null 2>&1
|
||||
endReturn -o $? "$toolUser cannot access certificate key file: $LDAP_CERT_KEY"
|
||||
endReturn "$toolUser cannot access certificate key file: $LDAP_CERT_KEY"
|
||||
sudo -u $toolUser test -r "$LDAP_CERT" >>/dev/null 2>&1
|
||||
endReturn -o $? "$toolUser cannot access certificate file: $LDAP_CERT"
|
||||
endReturn "$toolUser cannot access certificate file: $LDAP_CERT"
|
||||
sudo -u $toolUser test -r "$LDAP_CERT_CA" >>/dev/null 2>&1
|
||||
endReturn -o $? "$toolUser cannot access CA certificate file: $LDAP_CERT_CA"
|
||||
endReturn "$toolUser cannot access CA certificate file: $LDAP_CERT_CA"
|
||||
|
||||
local tempLdif=`eval "echo \"$sslSetup\""`
|
||||
exep "echo \"$tempLdif\" | ldapmodify -Y EXTERNAL -H ldapi:///"
|
||||
@@ -208,7 +208,7 @@ step_102() {
|
||||
fi
|
||||
|
||||
variable2Ldif add "$addUser"
|
||||
endReturn -o $? "Adding user failed"
|
||||
endReturn "Adding user failed"
|
||||
}
|
||||
userId=
|
||||
addUser="dn: uid=\$userId,\$LDAP_OU_USERS,\$LDAP_DC
|
||||
@@ -235,10 +235,10 @@ step_103_alias() { echo "passwd"; }
|
||||
step_103() {
|
||||
shift
|
||||
if [ -n "${1:-}" ] ; then
|
||||
echo " [I] Password operation for $1"
|
||||
info "Password operation for $1"
|
||||
userId="$1"
|
||||
elif [ ! -z $userId ] ; then
|
||||
echo " [I] Password operation for $userId"
|
||||
info "Password operation for $userId"
|
||||
else
|
||||
error -e "No user id provided"
|
||||
return 1
|
||||
@@ -253,9 +253,9 @@ step_105() {
|
||||
shift
|
||||
if [ -n "${1:-}" ] ; then
|
||||
userId="$1"
|
||||
echo " [I] User operation for $userId"
|
||||
info "User operation for $userId"
|
||||
elif [ ! -z $userId ] ; then
|
||||
echo " [I] User operation for $userId"
|
||||
info "User operation for $userId"
|
||||
else
|
||||
error -e "No user id provided"
|
||||
return 1
|
||||
@@ -268,7 +268,7 @@ step_105() {
|
||||
|
||||
variable2Ldif modify "$removeFromgroup"
|
||||
variable2Ldif modify "$add2group"
|
||||
endReturn -o $? "Adding user to group failed"
|
||||
endReturn "Adding user to group failed"
|
||||
}
|
||||
#remove empty member
|
||||
add2group="dn: cn=\$groupName,\$LDAP_OU_GROUPS,\$LDAP_DC
|
||||
@@ -289,9 +289,9 @@ step_107() {
|
||||
shift
|
||||
if [ -n "${1:-}" ] ; then
|
||||
userId="$1"
|
||||
echo " [I] User operation for $userId"
|
||||
info "User operation for $userId"
|
||||
elif [ ! -z $userId ] ; then
|
||||
echo " [I] User operation for $userId"
|
||||
info "User operation for $userId"
|
||||
else
|
||||
error -e "No user id provided"
|
||||
return 1
|
||||
@@ -354,7 +354,7 @@ step_200_options() { echo "<ADDITONAL ATTRIBUTES...>"; }
|
||||
step_200_alias() { echo "listgroups"; }
|
||||
step_200() {
|
||||
shift
|
||||
echo " [I] Available groups:"
|
||||
info "Available groups:"
|
||||
exe ldapsearch -x -LLL -H ldap:/// -b ${LDAP_OU_GROUPS},${LDAP_DC} dn gidNumber $*
|
||||
}
|
||||
|
||||
@@ -363,7 +363,7 @@ step_200_options() { echo "<ADDITONAL ATTRIBUTES...>"; }
|
||||
step_202_alias() { echo "listusers"; }
|
||||
step_202() {
|
||||
shift
|
||||
echo " [I] Available user:"
|
||||
info "Available user:"
|
||||
exe ldapsearch -x -LLL -H ldap:/// -b ${LDAP_OU_USERS},${LDAP_DC} dn uidNumber gidNumber $*
|
||||
}
|
||||
|
||||
|
@@ -36,7 +36,7 @@ step_2_info() {
|
||||
}
|
||||
step_2() {
|
||||
exe apt install $libreDeps ${sq_aptOpt}
|
||||
endReturn -o $? "Failed to install $toolName dependencies"
|
||||
endReturn "Failed to install $toolName dependencies"
|
||||
}
|
||||
|
||||
step_3_info() {
|
||||
@@ -47,7 +47,7 @@ step_3_info() {
|
||||
step_3() {
|
||||
fetchPhpVersion
|
||||
exe apt install "${librePhpDeps[@]/#/php${phpVersion}-}" ${sq_aptOpt}
|
||||
endReturn -o $? "Failed to install $toolName php dependencies"
|
||||
endReturn "Failed to install $toolName php dependencies"
|
||||
}
|
||||
|
||||
step_4_info() { echo "Adding $toolName user ($toolUser)"; }
|
||||
@@ -67,7 +67,7 @@ step_5() {
|
||||
step_6_info() { echo "Installing $toolName using composer"; }
|
||||
step_6() {
|
||||
exe sudo -u librenms "${LNMS_DIR}/scripts/composer_wrapper.php" install --no-dev
|
||||
endReturn -o $? "Failed to install php dependencies"
|
||||
endReturn "Failed to install php dependencies"
|
||||
}
|
||||
|
||||
step_10_info() { echo "Create mysql database for $toolName"; }
|
||||
@@ -77,7 +77,7 @@ step_10() {
|
||||
libreDbOpt="-d $LNMS_DB_NAME"
|
||||
fi
|
||||
exe "${seq_origin}"/mysql.sh ${sqr_args} createdb --charset utf8 "$libreDbOpt"
|
||||
endReturn -o $? "Failed to create mysql database $LNMS_DB_NAME"
|
||||
endReturn "Failed to create mysql database $LNMS_DB_NAME"
|
||||
}
|
||||
|
||||
step_11_info() { echo "MariaDB configuration"; }
|
||||
|
@@ -1,29 +1,17 @@
|
||||
#!/bin/bash
|
||||
|
||||
toolName=matrix-commander
|
||||
toolCloneUrl='https://github.com/8go/matrix-commander.git'
|
||||
toolDeps="python3-pip python3-venv libolm-dev"
|
||||
readonly toolName=matrix-commander
|
||||
readonly toolCloneUrl='https://github.com/8go/matrix-commander.git'
|
||||
readonly toolDeps="python3-pip python3-venv libolm-dev"
|
||||
|
||||
toolCredentialDir=
|
||||
toolEncStoreDir=
|
||||
|
||||
# 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"
|
||||
sq_aptOpt=
|
||||
|
||||
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
|
||||
if ! initSeqConfig "${seq_configName:?}" "${seq_configTemplate:?}" ; then
|
||||
# End if no configuration file exists
|
||||
dry || return -1
|
||||
fi
|
||||
@@ -32,7 +20,7 @@ seq_config() {
|
||||
toolEncStoreDir="$MACO_BASE_DIR/.local/share/matrix-commander"
|
||||
|
||||
## Apt cmdline option to suppress user interaction
|
||||
quiet && APTOPT="-y"
|
||||
quiet && sq_aptOpt="-y"
|
||||
|
||||
## Return of non zero value will abort the sequence
|
||||
return 0
|
||||
@@ -59,7 +47,7 @@ step_3() {
|
||||
step_50_info() { echo "Install $toolName dependencies"; }
|
||||
step_50_alias() { echo "install"; }
|
||||
step_50() {
|
||||
apt install $toolDeps $APTOPT
|
||||
apt install $toolDeps $sq_aptOpt
|
||||
}
|
||||
|
||||
step_51_info() { echo "Add system user ${MACO_USER:-}"; }
|
||||
@@ -75,7 +63,7 @@ step_52() {
|
||||
[ -e "$MACO_BASE_DIR" ] && endReturn -o 1 "$toolName already installed"
|
||||
|
||||
exe python3 -m venv "$MACO_BASE_DIR"
|
||||
endReturn -o $? "Creating virtual environment failed"
|
||||
endReturn "Creating virtual environment failed"
|
||||
|
||||
exe git clone $toolCloneUrl "$MACO_DIR"
|
||||
exe chown -R $MACO_USER: "$MACO_BASE_DIR"
|
||||
@@ -140,5 +128,7 @@ credentials.json - $MACO_BASE_DIR/.config/matrix-commander/credentials.json
|
||||
NOTES_EOF
|
||||
}
|
||||
|
||||
# shellcheck disable=SC2034 # Appears unused
|
||||
readonly sqr_minVersion=16
|
||||
# shellcheck disable=SC1091 # Don't follow this source
|
||||
. /usr/local/bin/sequencer.sh
|
||||
|
@@ -59,7 +59,7 @@ step_1_info() { echo "Installing $toolName dependencies"; }
|
||||
step_1_alias() { echo "install"; }
|
||||
step_1() {
|
||||
exe apt update
|
||||
endReturn -o $? "Updating apt repositories failed"
|
||||
endReturn "Updating apt repositories failed"
|
||||
|
||||
if [ "$osName" != "Raspbian" ] ; then
|
||||
toolDepsRaspi=""
|
||||
@@ -212,7 +212,7 @@ step_16_options() { echo "[OPTION] [IP]:8008"; }
|
||||
step_16_alias() { echo "listuser"; }
|
||||
step_16() {
|
||||
adminTokenCheck
|
||||
endReturn -o $? "Admin token needed. Check $seq_configFile"
|
||||
endReturn "Admin token needed. Check $seq_configFile"
|
||||
|
||||
shift
|
||||
local synapseIP=localhost
|
||||
@@ -279,7 +279,7 @@ step_22_options() { echo "[OPTION] [IP]:8008"; }
|
||||
step_22_alias() { echo "listrooms"; }
|
||||
step_22() {
|
||||
adminTokenCheck
|
||||
endReturn -o $? "Admin token needed. Check $seq_configFile"
|
||||
endReturn "Admin token needed. Check $seq_configFile"
|
||||
|
||||
shift
|
||||
local arg
|
||||
@@ -313,7 +313,7 @@ step_24_options() { echo "[OPTION] [ROOM ID] [IP]:8008"; }
|
||||
step_24_alias() { echo "listmember"; }
|
||||
step_24() {
|
||||
adminTokenCheck
|
||||
endReturn -o $? "Admin token needed. Check $seq_configFile"
|
||||
endReturn "Admin token needed. Check $seq_configFile"
|
||||
|
||||
shift
|
||||
local roomId=""
|
||||
@@ -351,7 +351,7 @@ step_26_options() { echo "[IP]:8008"; }
|
||||
step_26_alias() { echo "purge"; }
|
||||
step_26() {
|
||||
adminTokenCheck
|
||||
endReturn -o $? "Admin token needed. Check $seq_configFile"
|
||||
endReturn "Admin token needed. Check $seq_configFile"
|
||||
|
||||
shift
|
||||
local i
|
||||
@@ -378,7 +378,7 @@ step_28_options() { echo "<ROOM ID> [IP]:8008"; }
|
||||
step_28_alias() { echo "deleteroom"; }
|
||||
step_28() {
|
||||
adminTokenCheck
|
||||
endReturn -o $? "Admin token needed. Check $seq_configFile"
|
||||
endReturn "Admin token needed. Check $seq_configFile"
|
||||
|
||||
shift
|
||||
local roomId=""
|
||||
@@ -393,7 +393,7 @@ step_28() {
|
||||
|
||||
[ -n "${1:-}" ] && synapseIP="$1"
|
||||
|
||||
echo " [I] Deleting room with ID: $roomId"
|
||||
info "Deleting room with ID: $roomId"
|
||||
|
||||
local apiCall="http://${synapseIP}:8008/_synapse/admin/v2/rooms/$roomId"
|
||||
exep "curl -sS --header \"Authorization: Bearer $MATRIX_ACCESS\" \
|
||||
@@ -437,9 +437,9 @@ step_30() {
|
||||
postgresDb="$1"
|
||||
fi
|
||||
|
||||
echo " [I] Stopping ${toolServiceName}"
|
||||
info "Stopping ${toolServiceName}"
|
||||
exe service ${toolServiceName} stop
|
||||
endReturn -o $? "Couldn't stop ${toolServiceName}. Stopping debloat."
|
||||
endReturn "Couldn't stop ${toolServiceName}. Stopping debloat."
|
||||
|
||||
exe cd ~postgres
|
||||
exe su -c "psql -d ${postgresDb} -c \"REINDEX${pgVerboseReId}DATABASE ${postgresDb};\"" - postgres
|
||||
|
@@ -46,7 +46,7 @@ step_1_info() {
|
||||
step_1_alias() { echo "install"; }
|
||||
step_1() {
|
||||
step upgrade
|
||||
endReturn -o $? "Download failed"
|
||||
endReturn "Download failed"
|
||||
}
|
||||
|
||||
step_2_info() { echo "Create required directory structure"; }
|
||||
@@ -65,13 +65,13 @@ step_3() {
|
||||
step_4_info() { echo "Creating systemd service"; }
|
||||
step_4() {
|
||||
addConf -s "$toolService" "$toolServiceLoc"
|
||||
endReturn -o $? "Creating service failed"
|
||||
endReturn "Creating service failed"
|
||||
}
|
||||
|
||||
step_5_info() { echo "Enable $toolName service"; }
|
||||
step_5() {
|
||||
exe systemctl enable ${toolName}
|
||||
echo " [I] Before proceeding to run ${toolName} you need to modify ${toolConfigLoc} first"
|
||||
info "Before proceeding to run ${toolName} you need to modify ${toolConfigLoc} first"
|
||||
echo
|
||||
}
|
||||
|
||||
@@ -122,7 +122,7 @@ step_12_alias() { echo "upgrade"; }
|
||||
step_12() {
|
||||
step backup
|
||||
exe wget -O "$toolLoc" "${toolDownload}"
|
||||
endReturn -o $? "Download failed"
|
||||
endReturn "Download failed"
|
||||
exe chmod +x "$toolLoc"
|
||||
exe service ${toolName} restart >>/dev/null 2>&1
|
||||
return 0
|
||||
@@ -156,9 +156,9 @@ step_30() {
|
||||
if [ ! -e "${goDir}" ] ; then
|
||||
info "Download go${goVer}: ${goDownUrl}"
|
||||
exe wget -O "${goDownLoc}" "${goDownUrl}"
|
||||
endReturn -o $? "Download ${goVer} failed"
|
||||
endReturn "Download ${goVer} failed"
|
||||
exe tar -C "$(dirname -- "${goDir}")" -xzf "${goDownLoc}"
|
||||
endReturn -o $? "Extraction ${goVer} failed"
|
||||
endReturn "Extraction ${goVer} failed"
|
||||
fi
|
||||
}
|
||||
|
||||
|
@@ -54,7 +54,7 @@ step_2() {
|
||||
graphviz libfuse2 libjpeg-dev libmagic1 libpq-dev libpng-dev libtiff-dev libldap2-dev libsasl2-dev \
|
||||
poppler-utils postgresql python3-dev python3-pip python3-venv python3-virtualenv \
|
||||
redis-server sane-utils supervisor tesseract-ocr tesseract-ocr-deu zlib1g-dev -y
|
||||
endReturn -o $? "Binary dependencies installation failed"
|
||||
endReturn "Binary dependencies installation failed"
|
||||
|
||||
exe systemctl enable supervisor
|
||||
exe systemctl stop supervisor
|
||||
@@ -65,7 +65,7 @@ step_3() {
|
||||
exe adduser --disabled-password --disabled-login --no-create-home --gecos "" mayan
|
||||
exe usermod -a -G users mayan
|
||||
exe python3 -m venv ${toolRoot}
|
||||
endReturn -o $? "Creating virtual environment failed"
|
||||
endReturn "Creating virtual environment failed"
|
||||
exe chown -R mayan:mayan ${toolRoot}
|
||||
}
|
||||
|
||||
@@ -86,9 +86,9 @@ step_5() {
|
||||
step upgradepip
|
||||
|
||||
exe sudo -u mayan ${toolRoot}/bin/pip install --no-cache-dir mayan-edms=="${toolVersion}"
|
||||
endReturn -o $? "pip install for $toolName failed"
|
||||
endReturn "pip install for $toolName failed"
|
||||
exe sudo -u mayan ${toolRoot}/bin/pip install --no-cache-dir psycopg2==2.8.4 redis==3.4.1
|
||||
endReturn -o $?
|
||||
endReturn
|
||||
}
|
||||
|
||||
step_6_info() { echo "Supervisord configuration for $toolName"; }
|
||||
@@ -133,10 +133,10 @@ step_10() {
|
||||
step upgradepip
|
||||
exe curl -o "$uninstallRemovalsLoc" https://gitlab.com/mayan-edms/mayan-edms/raw/master/removals.txt
|
||||
exe sudo -u mayan ${toolRoot}/bin/pip uninstall -r "$uninstallRemovalsLoc"
|
||||
endReturn -o $?
|
||||
endReturn
|
||||
exe systemctl stop supervisor
|
||||
exe sudo -u mayan ${toolRoot}/bin/pip install --no-cache-dir mayan-edms=="${toolVersion}"
|
||||
endReturn -o $?
|
||||
endReturn
|
||||
toolScript performupgrade
|
||||
#toolScript preparestatic --noinput # only < 3.4
|
||||
case "${1:-}" in
|
||||
@@ -178,7 +178,7 @@ step_20_alias() { echo "backupdb"; }
|
||||
step_20() {
|
||||
local DELYEAR=$(($(date +%Y)-2))
|
||||
if [ ! -s ~/.pgpass ] ; then
|
||||
echo " [I] For unattended backup please define ~/.pgpass containing credentials for user mayan"
|
||||
info "For unattended backup please define ~/.pgpass containing credentials for user mayan"
|
||||
echo " e.g. localhost:5432:mayan:mayan:pass4mayan"
|
||||
echo "Backup custom pg format with standard user / database: mayan / mayan"
|
||||
fi
|
||||
@@ -191,7 +191,7 @@ toolDbBackupFolder=${toolMediaFolder}/backupdb
|
||||
step_22_info() { echo "Postgres database restore"; }
|
||||
step_22_alias() { echo "restoredb"; }
|
||||
step_22() {
|
||||
echo " [I] Postgres database restore procedure"
|
||||
info "Postgres database restore procedure"
|
||||
echo "1. Create a empty postgres database first (step 4)"
|
||||
echo "2. psql -h <host> -U <database user> -d <database name> -W -f <sql dump file>"
|
||||
echo " e.g. psql -h 127.0.0.1 -U mayan -d mayan -W -f 2018-06-07_18-10-56.sql"
|
||||
|
@@ -39,7 +39,7 @@ seq_config() {
|
||||
SEQ_OSNAME="Ubuntu"
|
||||
fi
|
||||
|
||||
echo " [I] Detected OS: $SEQ_OSNAME $SEQ_DISTNAME"
|
||||
info "Detected OS: $SEQ_OSNAME $SEQ_DISTNAME"
|
||||
}
|
||||
|
||||
step_1_info() { echo "Install $toolName dependencies"; }
|
||||
@@ -54,7 +54,7 @@ step_1() {
|
||||
fi
|
||||
|
||||
exe apt update
|
||||
endReturn -o $? "Updating apt repositories failed"
|
||||
endReturn "Updating apt repositories failed"
|
||||
|
||||
if quiet ; then
|
||||
aptOption="-y"
|
||||
@@ -75,24 +75,24 @@ step_2() {
|
||||
fi
|
||||
|
||||
if [ "$motionUrl" == "" ]; then
|
||||
echo " [W] Unsupported OS"
|
||||
warning "Unsupported OS"
|
||||
return 1
|
||||
fi
|
||||
|
||||
exe wget -O "$motionDownload" $motionUrl
|
||||
endReturn -o $? "Download motion failed"
|
||||
endReturn "Download motion failed"
|
||||
}
|
||||
motionDownload="/tmp/motion.deb"
|
||||
|
||||
step_3_info() { echo "Install downloaded motion version"; }
|
||||
step_3() {
|
||||
if [ ! -f "$motionDownload" ]; then
|
||||
echo " [I] No downloaded motion found attempting download"
|
||||
info "No downloaded motion found attempting download"
|
||||
step 2
|
||||
fi
|
||||
|
||||
exe dpkg -i "$motionDownload"
|
||||
endReturn -o $? "Installing motion failed"
|
||||
endReturn "Installing motion failed"
|
||||
}
|
||||
|
||||
step_4_info() { echo "Upgrade python pip"; }
|
||||
@@ -100,13 +100,13 @@ step_4_alias() { echo "upgradepip"; }
|
||||
step_4()
|
||||
{
|
||||
exe pip install --upgrade pip
|
||||
endReturn -o $? "Upgrading pip failed"
|
||||
endReturn "Upgrading pip failed"
|
||||
}
|
||||
|
||||
step_5_info() { echo "Install $toolName"; }
|
||||
step_5() {
|
||||
exe pip install motioneye
|
||||
endReturn -o $? "Installing $toolName failed"
|
||||
endReturn "Installing $toolName failed"
|
||||
}
|
||||
|
||||
step_6_info() { echo "Prepare configuration directory $toolCfgDir"; }
|
||||
@@ -129,7 +129,7 @@ motioneyeMediaDir="/var/lib/motioneye"
|
||||
step_8_info() { echo "Create $toolName service"; }
|
||||
step_8() {
|
||||
exe cp "$motioneyeServiceSource" "$motioneyeServiceTarget"
|
||||
endReturn -o $? "Creating service failed"
|
||||
endReturn "Creating service failed"
|
||||
exe systemctl daemon-reload
|
||||
exe systemctl enable motioneye
|
||||
exe systemctl start motioneye
|
||||
@@ -142,7 +142,7 @@ step_20_alias() { echo "upgrade"; }
|
||||
step_20() {
|
||||
step "upgradepip"
|
||||
exe pip install motioneye --upgrade
|
||||
endReturn -o $? "Upgrading $toolName failed"
|
||||
endReturn "Upgrading $toolName failed"
|
||||
exe systemctl restart motioneye
|
||||
}
|
||||
|
||||
|
@@ -31,7 +31,7 @@ step_6_alias() { echo install; }
|
||||
step_6() {
|
||||
exe apt update
|
||||
exe apt install $databasePackages
|
||||
endReturn -o $? "Error instaling $databaseName"
|
||||
endReturn "Error instaling $databaseName"
|
||||
}
|
||||
|
||||
step_7_info() { echo "Secure ${databaseName} installation"; }
|
||||
@@ -105,14 +105,14 @@ step_10() {
|
||||
esac
|
||||
|
||||
if [ -z "$dbName" ] ; then
|
||||
echo " [I] Existing mysql databases:"
|
||||
info "Existing mysql databases:"
|
||||
exe mysql -u root -e 'SHOW DATABASES;'
|
||||
|
||||
read -p "Enter database name: " dbName
|
||||
fi
|
||||
endIfEmpty dbName "database name"
|
||||
exe mysql -u root -e 'CREATE DATABASE '$dbName' '"$dbOption"';'
|
||||
endReturn -o $? "Cannot create database $dbName"
|
||||
endReturn "Cannot create database $dbName"
|
||||
}
|
||||
|
||||
step_11_info() {
|
||||
@@ -148,7 +148,7 @@ step_11() {
|
||||
done
|
||||
|
||||
if [ -z "$dbUser" ] ; then
|
||||
echo " [I] Existing mysql user:"
|
||||
info "Existing mysql user:"
|
||||
exe mysql -u root -e 'SELECT User, Host FROM mysql.user;'
|
||||
read -p "Enter mysql user name: " dbUser
|
||||
fi
|
||||
@@ -163,7 +163,7 @@ step_11() {
|
||||
info "Enter mysql password: ...skipped..."
|
||||
fi
|
||||
exe mysql -u root -e 'CREATE USER '"'"$dbUser"'"'@'"'"$dbRemote"'"' IDENTIFIED BY '"'"$dbPass"'"';'
|
||||
endReturn -o $? "Error creating mysql user"
|
||||
endReturn "Error creating mysql user"
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -200,7 +200,7 @@ step_12() {
|
||||
done
|
||||
|
||||
exe mysql -u root -e 'GRANT ALL PRIVILEGES ON '$dbName'.* TO '"'"$dbUser"'"'@'"'"$dbRemote"'"';'
|
||||
endReturn -o $? "Error assigning privileges on database"
|
||||
endReturn "Error assigning privileges on database"
|
||||
|
||||
exe mysql -u root -e 'FLUSH PRIVILEGES;'
|
||||
}
|
||||
@@ -231,7 +231,7 @@ step_14() {
|
||||
done
|
||||
|
||||
exe mysql -u root -e 'REVOKE ALL, GRANT OPTION FROM '"'"$dbUser"'"'@'"'"$dbRemote"'"';'
|
||||
endReturn -o $? "Error revoking privileges for user $dbUser"
|
||||
endReturn "Error revoking privileges for user $dbUser"
|
||||
|
||||
exe mysql -u root -e 'FLUSH PRIVILEGES;'
|
||||
}
|
||||
@@ -311,9 +311,9 @@ step_50() {
|
||||
endReturn -o 1 -f "${2:-} does not exist"
|
||||
fi
|
||||
|
||||
echo " [I] Dumping database $dbName to $buTarget"
|
||||
info "Dumping database $dbName to $buTarget"
|
||||
exep "mysqldump --single-transaction $dbName > \"$(realpath $buTarget)/${dbName}_backup_$(date +%Y%m%d-%H%M%S).sql\""
|
||||
endReturn -o $? "Error creating $dbName backup"
|
||||
endReturn "Error creating $dbName backup"
|
||||
}
|
||||
|
||||
step_52_info() { echo "Restore a mysql database"; }
|
||||
|
@@ -57,7 +57,7 @@ step_102() {
|
||||
if [ -z $1 ] ; then
|
||||
error -e "No database provided"
|
||||
if [ -f "${seq_origin}/mysql.sh" ] ; then
|
||||
echo " [I] Available mysql databases:"
|
||||
info "Available mysql databases:"
|
||||
"${seq_origin}/mysql.sh" -qq listdb
|
||||
fi
|
||||
return 1
|
||||
@@ -73,7 +73,7 @@ step_102() {
|
||||
fi
|
||||
|
||||
exe mysql -u root -D ${ncdb} -e 'delete FROM oc_bruteforce_attempts WHERE IP="'${ip}'";'
|
||||
endReturn -o $? "Error deleting ip $ip"
|
||||
endReturn "Error deleting ip $ip"
|
||||
}
|
||||
|
||||
step_104_info() { echo "Reset and rescan the music library in the background for one user"; }
|
||||
|
@@ -63,7 +63,7 @@ step_11_alias() { echo "install"; }
|
||||
step_11() {
|
||||
exe apt update
|
||||
exe apt install ${sq_toolDeps} ${sq_aptOpt:-}
|
||||
endReturn -o $? "Failed to install ${toolName}"
|
||||
endReturn "Failed to install ${toolName}"
|
||||
}
|
||||
|
||||
step_12_info() {
|
||||
|
@@ -63,9 +63,9 @@ downloadLatest() {
|
||||
if [ ! -e "$tempInstall" ] ; then
|
||||
exe mkdir -p "$tempDown"
|
||||
exe wget -O "$tempInstall" $downUrl
|
||||
endReturn -o $? "Download failed: $downUrl"
|
||||
endReturn "Download failed: $downUrl"
|
||||
else
|
||||
echo " [I] Found existing download: $tempInstall"
|
||||
info "Found existing download: $tempInstall"
|
||||
fi
|
||||
}
|
||||
tempDown="/tmp/olivetin"
|
||||
|
@@ -56,7 +56,7 @@ step_1_alias() { echo "install"; }
|
||||
step_1() {
|
||||
exe apt update
|
||||
exe apt install $dockerDeps $APTOPT
|
||||
endReturn -o $? "Docker dependencies installation failed"
|
||||
endReturn "Docker dependencies installation failed"
|
||||
}
|
||||
|
||||
step_2_info() { echo "Install Docker repository"; }
|
||||
@@ -66,9 +66,9 @@ step_2() {
|
||||
|
||||
# Add stable repository
|
||||
exe add-apt-repository "deb [arch=amd64] ${dockerRepoUrl} $(lsb_release -cs) stable"
|
||||
endReturn -o $? "Failed to add Docker repository"
|
||||
endReturn "Failed to add Docker repository"
|
||||
exe apt update
|
||||
endReturn -o $? "Docker repository not available"
|
||||
endReturn "Docker repository not available"
|
||||
}
|
||||
|
||||
step_3_info() { echo "Install latest Docker version"; }
|
||||
@@ -81,7 +81,7 @@ step_3() {
|
||||
fi
|
||||
exe apt install $dockerPackages $aptOption
|
||||
|
||||
echo " [I] You may test the installation by running:"
|
||||
info "You may test the installation by running:"
|
||||
echo " sudo docker run hello-world"
|
||||
}
|
||||
|
||||
@@ -143,7 +143,7 @@ step_7() {
|
||||
warning -e "No $toolName Docker container found"
|
||||
fi
|
||||
exe docker pull $dockerImageName
|
||||
endReturn -o $? "Error getting $toolName Docker update"
|
||||
endReturn "Error getting $toolName Docker update"
|
||||
|
||||
step startoo
|
||||
}
|
||||
@@ -153,7 +153,7 @@ step_10_alias() { echo "ls"; }
|
||||
step_10() {
|
||||
exe docker container ls
|
||||
echo
|
||||
echo " [I] To stop a container run:"
|
||||
info "To stop a container run:"
|
||||
echo " docker stop [CONTAINER ID]"
|
||||
echo " e.g.: docker stop 70f1c5c81be2"
|
||||
}
|
||||
|
@@ -1,36 +1,14 @@
|
||||
#!/bin/bash
|
||||
|
||||
toolName=openvpn
|
||||
toolDeps=openvpn
|
||||
toolDefaultConf="/etc/default/openvpn"
|
||||
toolUserScriptsLoc="/usr/lib/openvpn"
|
||||
readonly toolName=openvpn
|
||||
readonly toolDeps=openvpn
|
||||
readonly toolDefaultConf="/etc/default/openvpn"
|
||||
readonly toolUserScriptsLoc="/usr/lib/openvpn"
|
||||
|
||||
# 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"
|
||||
CONFIG_DIR="$WDIR/$SCRIPT_NAME"
|
||||
sq_aptOpt=
|
||||
|
||||
seq_config() {
|
||||
#echo "Called once before executing steps."
|
||||
## e.g. to source a config file manually:
|
||||
#. "$CONFIG_FILE"
|
||||
## or to use sequencer api with global config file:
|
||||
#initSeqConfig "$CONFIG_FILE_NAME" "$CONFIG_FILE_TEMPLATE"
|
||||
## or to use sequencer api with profile config file support:
|
||||
#initSeqConfig -p "$SCRIPT_NAME" "$CONFIG_FILE_TEMPLATE"
|
||||
#if [ $? -eq 0 ] ; then
|
||||
# CONFIG=1
|
||||
#else
|
||||
# # End if no configuration file exists
|
||||
# dry || return -1
|
||||
#fi
|
||||
quiet && APTOPT="-y"
|
||||
interactive || sq_aptOpt="-y"
|
||||
return 0
|
||||
}
|
||||
|
||||
@@ -38,7 +16,7 @@ step_1_info() { echo "Install $toolName"; }
|
||||
step_1_alias() { echo "install"; }
|
||||
step_1() {
|
||||
exe apt update
|
||||
exe apt install $toolDeps $APTOPT
|
||||
exe apt install $toolDeps $sq_aptOpt
|
||||
}
|
||||
|
||||
step_2_info() { echo "Install customized helper scripts to $toolUserScriptsLoc"; }
|
||||
@@ -46,7 +24,7 @@ step_2() {
|
||||
exep "mkdir \"$toolUserScriptsLoc\" 2>>/dev/null"
|
||||
[ $? -ne 0 ] && \
|
||||
warning "$toolUserScriptsLoc already exists. Not overwriting existing files."
|
||||
exe cp -n "$CONFIG_DIR"/* "$toolUserScriptsLoc"
|
||||
exe cp -n "${seq_origin}/${seq_fileName}"/* "$toolUserScriptsLoc"
|
||||
}
|
||||
|
||||
step_10_info() { echo "Open openvpn system start configuration"; }
|
||||
@@ -55,5 +33,7 @@ step_10() {
|
||||
exe vi "$toolDefaultConf"
|
||||
}
|
||||
|
||||
# shellcheck disable=SC2034 # Appears unused
|
||||
readonly sqr_minVersion=16
|
||||
# shellcheck disable=SC1091 # Don't follow this source
|
||||
. /usr/local/bin/sequencer.sh
|
||||
|
@@ -127,7 +127,7 @@ step_12() {
|
||||
fi
|
||||
fi
|
||||
exe wget ${downUrl} -q -O "${sq_paperlessDownLoc}"
|
||||
endReturn -o $? "Download failed"
|
||||
endReturn "Download failed"
|
||||
|
||||
if [ -e "${sc_paperlessDir}" ] ; then
|
||||
if step backup --nostart; then
|
||||
@@ -194,12 +194,12 @@ step_19_alias() { echo 'nltk'; }
|
||||
step_19() {
|
||||
info 'Installing nltk'
|
||||
exe "${sc_paperlessVenv}/bin/pip3" install -U nltk
|
||||
endReturn -o $? "Failed to install nlkt"
|
||||
endReturn "Failed to install nlkt"
|
||||
|
||||
exe cd "${sc_paperlessHome}/data"
|
||||
exe mkdir -p "nltk"
|
||||
exe "${sc_paperlessVenv}/bin/python3" -m nltk.downloader -d ./nltk/ snowball_data stopwords punkt
|
||||
endReturn -o $? "Failed to install nlkt modules snowball stopwords punkt"
|
||||
endReturn "Failed to install nlkt modules snowball stopwords punkt"
|
||||
|
||||
step service restart
|
||||
}
|
||||
|
@@ -126,7 +126,7 @@ step_12() {
|
||||
fi
|
||||
fi
|
||||
exe wget ${downUrl} -q -O "${sq_paperlessDownLoc}"
|
||||
endReturn -o $? "Download failed"
|
||||
endReturn "Download failed"
|
||||
|
||||
if [ -e "${sc_paperlessDir}" ] ; then
|
||||
if step backup --nostart; then
|
||||
|
@@ -44,9 +44,9 @@ step_1() {
|
||||
step_2_info() { echo -e "Installing $toolName dependencies"; }
|
||||
step_2() {
|
||||
exe apt install "${toolPhpDeps[@]/#/${sq_phpName}-}" $toolDeps ${sq_aptOpt}
|
||||
endReturn -o $? "Installing deps for $toolName failed"
|
||||
endReturn "Installing deps for $toolName failed"
|
||||
exe service ${sq_phpName}-fpm restart
|
||||
endReturn -o $? "Problems starting $toolName"
|
||||
endReturn "Problems starting $toolName"
|
||||
}
|
||||
|
||||
step_3_info() { echo -e "Get $toolName using git"; }
|
||||
@@ -63,7 +63,7 @@ step_4() {
|
||||
exe cd "${toolPath:?}"
|
||||
exe ${seq_origin:?}/composer.sh -qq install
|
||||
exe sudo -u www-data ${sq_phpName:?} composer.phar install --no-ansi --no-interaction --optimize-autoloader
|
||||
endReturn -o $? "Composer install error"
|
||||
endReturn "Composer install error"
|
||||
}
|
||||
|
||||
step_5_info() { echo "Create mysql database for $toolName"; }
|
||||
@@ -97,7 +97,7 @@ step_7() {
|
||||
step_8_info() { echo "Create pixelfed (horzion) service"; }
|
||||
step_8() {
|
||||
addConf -c "${horizonService}" "${horizonServiceLoc}"
|
||||
endReturn -o $? "Failed to add horizon service"
|
||||
endReturn "Failed to add horizon service"
|
||||
exe systemctl daemon-reload
|
||||
exe systemctl enable pixelfed.service
|
||||
exe service pixelfed start
|
||||
@@ -149,7 +149,7 @@ step_10() {
|
||||
addConf -c "$lNginxConfig" "$nginxConfigLoc"
|
||||
exe ln -s "$nginxConfigLoc" "$nginxConfigEnable"
|
||||
exe nginx -t
|
||||
endReturn -o $? "Nginx configuration check error"
|
||||
endReturn "Nginx configuration check error"
|
||||
exe service nginx restart
|
||||
}
|
||||
|
||||
@@ -247,9 +247,9 @@ step_100_alias() { echo "upgrade"; }
|
||||
step_100() {
|
||||
exe cd ${toolPath:?}
|
||||
exe git pull origin $toolTag
|
||||
endReturn -o $? "git pull failed"
|
||||
endReturn "git pull failed"
|
||||
exe git checkout $toolTag
|
||||
endReturn -o $? "git checkout failed"
|
||||
endReturn "git checkout failed"
|
||||
}
|
||||
|
||||
step_101_info() { echo "Recommended post update procedure"; }
|
||||
|
@@ -53,7 +53,7 @@ step_3_info() { echo "Install fetchmail"; }
|
||||
step_3_alias() { echo "install_fetchmail"; }
|
||||
step_3() {
|
||||
exe apt install $fetchmailDeps ${sq_aptOpt:-}
|
||||
endReturn -o $? "Failed to install fetchmail"
|
||||
endReturn "Failed to install fetchmail"
|
||||
exe systemctl stop fetchmail
|
||||
exe systemctl disable fetchmail
|
||||
}
|
||||
@@ -69,7 +69,7 @@ step_4() {
|
||||
echo " [$toolAdditionsLoc/fetchmail.pl]"
|
||||
echo " # Change path to fetchmail.conf (see above)"
|
||||
echo
|
||||
echo " [I] Run step \"timer\" when configuration is done"
|
||||
info "Run step \"timer\" when configuration is done"
|
||||
}
|
||||
|
||||
step_6_info() {
|
||||
@@ -153,10 +153,10 @@ step_18() {
|
||||
|
||||
isInstalled=$(grep -E "${latestVersion}" "${PFA_WEB_LOC}/version" >>/dev/null 2>&1 && echo "1" || echo "0")
|
||||
if [ $isInstalled -eq 1 ] ; then
|
||||
echo " [I] Version $latestVersion is already installed"
|
||||
info "Version $latestVersion is already installed"
|
||||
return 1
|
||||
else
|
||||
echo " [I] Update to $latestVersion available"
|
||||
info "Update to $latestVersion available"
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
@@ -189,7 +189,7 @@ step_20() {
|
||||
fi
|
||||
|
||||
local srvBackup="$PFA_BACKUP/${toolName}_`date +%Y%m%d-%H%M%S`.tar.gz"
|
||||
echo " [I] Backing up server directory to $srvBackup"
|
||||
info "Backing up server directory to $srvBackup"
|
||||
exe cd "$tempRoot/.."
|
||||
exe tar czf "$srvBackup" $(basename "$tempRoot")
|
||||
|
||||
@@ -252,12 +252,12 @@ step_22() {
|
||||
if [ ! -e "$tempExtract" ] ; then
|
||||
exe mkdir -p "$tempDown"
|
||||
exe wget -O "$tempLoc" $downUrl
|
||||
endReturn -o $? "Download failed: $downUrl"
|
||||
endReturn "Download failed: $downUrl"
|
||||
exe cd "$tempDown"
|
||||
exe tar -xf "$tempLoc"
|
||||
endReturn -o $? "Extract failed: $tempLoc"
|
||||
endReturn "Extract failed: $tempLoc"
|
||||
else
|
||||
echo " [I] Found existing download: $tempExtract"
|
||||
info "Found existing download: $tempExtract"
|
||||
fi
|
||||
|
||||
# Installation
|
||||
@@ -266,12 +266,12 @@ step_22() {
|
||||
if [ -e "$PFA_SRV_LOC" ] ; then
|
||||
exe mv "$PFA_SRV_LOC" "$tempBu"
|
||||
step backup "$tempBu"
|
||||
endReturn -o $? "Backup failed; $PFA_SRV_LOC renamed!"
|
||||
endReturn "Backup failed; $PFA_SRV_LOC renamed!"
|
||||
fi
|
||||
echo " [I] Installing version $latestVersion to $PFA_SRV_LOC"
|
||||
info "Installing version $latestVersion to $PFA_SRV_LOC"
|
||||
exe cp -ar "$tempExtract" "$PFA_SRV_LOC"
|
||||
exe mkdir -p $(dirname "$PFA_WEB_LOC")
|
||||
echo " [I] Create symlink to $PFA_WEB_LOC"
|
||||
info "Create symlink to $PFA_WEB_LOC"
|
||||
exe ln -fs "$PFA_SRV_LOC/public" "$PFA_WEB_LOC"
|
||||
|
||||
# Setting file permissions
|
||||
@@ -280,20 +280,20 @@ step_22() {
|
||||
# Configuration
|
||||
local webConf="$tempBu/$toolConfName"
|
||||
if [ -e "$webConf" ] ; then
|
||||
echo " [I] Copying configuration"
|
||||
info "Copying configuration"
|
||||
exe cp -ar "$webConf" "$PFA_SRV_LOC/"
|
||||
else
|
||||
echo " [I] Creating empty configuration file $PFA_SRV_LOC/$toolConfName"
|
||||
info "Creating empty configuration file $PFA_SRV_LOC/$toolConfName"
|
||||
exep "echo -e \"# Created by ${seq_origin:?}/$(basename $0)\\n\\n# Changeme\" > \"$PFA_SRV_LOC/$toolConfName\""
|
||||
fi
|
||||
|
||||
# Templates
|
||||
local templatesLoc="$tempBu/$toolTemplates"
|
||||
if [ -e "$templatesLoc" ] ; then
|
||||
echo " [I] Copying $toolTemplates"
|
||||
info "Copying $toolTemplates"
|
||||
exe cp -ar "$templatesLoc" "$toolTemplatesLoc"
|
||||
else
|
||||
echo " [I] Creating empty directory $toolTemplatesLoc"
|
||||
info "Creating empty directory $toolTemplatesLoc"
|
||||
exe mkdir -p "$toolTemplatesLoc"
|
||||
exe chown -R www-data: "$toolTemplatesLoc"
|
||||
fi
|
||||
|
@@ -62,7 +62,7 @@ step_11_info() { echo "Installing $toolName dependencies"; }
|
||||
step_11_alias() { echo "install"; }
|
||||
step_11() {
|
||||
exe apt update
|
||||
endReturn -o $? "Updating apt repositories failed"
|
||||
endReturn "Updating apt repositories failed"
|
||||
exe apt install $toolDeps ${sq_aptOpt}
|
||||
}
|
||||
|
||||
@@ -137,7 +137,7 @@ step_40() {
|
||||
dbname="$postgresDb"
|
||||
fi
|
||||
#if [ ! -s ~/.pgpass ] ; then
|
||||
# echo " [I] For unattended backup please define ~/.pgpass containing credentials"
|
||||
# info "For unattended backup please define ~/.pgpass containing credentials"
|
||||
# echo " e.g. localhost:5432:database:user:pass"
|
||||
#fi
|
||||
# -Fc custom format
|
||||
@@ -150,7 +150,7 @@ step_40() {
|
||||
step_42_info() { echo "Postgres database restore"; }
|
||||
step_42_alias() { echo "restoredb"; }
|
||||
step_42() {
|
||||
echo " [I] Postgres database restore procedure"
|
||||
info "Postgres database restore procedure"
|
||||
echo "1. Create a empty postgres database first (step 4)"
|
||||
echo "2. psql -h <host> -U <database user> -d <database name> -W -f <sql dump file>"
|
||||
echo " e.g. psql -h 127.0.0.1 -U synapse -d synapse -W -f 2018-06-07_18-10-56.sql"
|
||||
|
@@ -76,7 +76,7 @@ step_3() {
|
||||
step_4_info() { echo "Get $toolName from $toolDownload and create dedicated user"; }
|
||||
step_4() {
|
||||
exe git clone -b $toolBranch $toolDownload "$PYL_INSTALL_DIR"
|
||||
endReturn -o $? "Git clone failed"
|
||||
endReturn "Git clone failed"
|
||||
exe adduser --system --home "$PYL_CONFIG_DIR" "$PYL_USER"
|
||||
}
|
||||
|
||||
@@ -121,7 +121,7 @@ step_10() {
|
||||
exe service $toolName stop
|
||||
exe cd "$PYL_INSTALL_DIR"
|
||||
exe git pull
|
||||
echo " [I] Service is not started automatically"
|
||||
info "Service is not started automatically"
|
||||
echo " Do so manually with: service $toolName start"
|
||||
}
|
||||
|
||||
|
@@ -99,7 +99,7 @@ step_1() {
|
||||
fi
|
||||
if [ ! -f "$downImgLoc" ] ; then
|
||||
exe unxz "$downLoc"
|
||||
endReturn -o $? "Unzip raspios image $PIARCH failed"
|
||||
endReturn "Unzip raspios image $PIARCH failed"
|
||||
fi
|
||||
}
|
||||
downDay=$(date +%Y%m%d)
|
||||
@@ -186,7 +186,7 @@ step_3() {
|
||||
fi
|
||||
|
||||
read_sd_dev "${1:-}"
|
||||
endReturn -o $? "SD card device not found"
|
||||
endReturn "SD card device not found"
|
||||
|
||||
if [ ! -w "$SDBOOT" ] ; then
|
||||
error -e "SD card boot partion not writeable"
|
||||
@@ -232,13 +232,13 @@ step_4() {
|
||||
shift; local lArgs=( "$@" ); evalArgs "${lArgs[@]}"; shift $?
|
||||
|
||||
read_sd_dev "${1:-}"
|
||||
endReturn -o $? "SD detection error $?"
|
||||
endReturn "SD detection error $?"
|
||||
read_hd_dev "${2:-}"
|
||||
endReturn -o $? "HD detection error"
|
||||
echo " [I] SD: $SDDEV"
|
||||
endReturn "HD detection error"
|
||||
info "SD: $SDDEV"
|
||||
echo " $SDBOOT [$SDBOOTPUUID]"
|
||||
echo " $SDROOT [$SDROOTPUUID]"
|
||||
echo " [I] HD: $HDDEV"
|
||||
info "HD: $HDDEV"
|
||||
echo " $HDROOT [$HDROOTPUUID]"
|
||||
echo " $HDSWAP [$HDSWAPPUUID]"
|
||||
echo
|
||||
@@ -270,7 +270,7 @@ step_4() {
|
||||
echo
|
||||
|
||||
# Resize second partition of SD to max. possible size
|
||||
echo " [I] Resize root partion of SD: ${SDROOT} "
|
||||
info "Resize root partion of SD: ${SDROOT} "
|
||||
step resizesd "$SDDEV"
|
||||
if [ $? -ne 0 ] ; then
|
||||
warning -e "Something seems to have failed during resize"
|
||||
@@ -306,30 +306,30 @@ step_5() {
|
||||
error -e "Not ready yet...TODO"
|
||||
#return 1
|
||||
read_sd_dev "${1:-}"
|
||||
endReturn -o $? "SD detection error $?"
|
||||
endReturn "SD detection error $?"
|
||||
|
||||
read_hd_dev "${2:-}"
|
||||
endReturn -o $? "HD detection error"
|
||||
echo " [I] SD: $SDDEV"
|
||||
endReturn "HD detection error"
|
||||
info "SD: $SDDEV"
|
||||
echo " $SDBOOT [$SDBOOTPUUID]"
|
||||
echo " $SDROOT [$SDROOTPUUID]"
|
||||
echo " [I] HD: $HDDEV"
|
||||
info "HD: $HDDEV"
|
||||
echo " $HDROOT [$HDROOTPUUID]"
|
||||
echo " $HDSWAP [$HDSWAPPUUID]"
|
||||
echo
|
||||
|
||||
# TODO how to partition HD
|
||||
echo " [I] $HDDEV is expected to be partitioned with root and swap"
|
||||
info "$HDDEV is expected to be partitioned with root and swap"
|
||||
echo " TODO create a step for partitioning script support?!"
|
||||
echo
|
||||
|
||||
# Initial rsync of system to HD
|
||||
echo " [I] Clone SD root to HD root:"
|
||||
info "Clone SD root to HD root:"
|
||||
echo " rsync -avxHAX --numeric-ids --info=stats2 $SDROOT/ $HDROOT/"
|
||||
echo
|
||||
|
||||
# Modify fstab on HD for root and swap on HD
|
||||
echo " [I] modify $HDROOT/etc/fstab"
|
||||
info "modify $HDROOT/etc/fstab"
|
||||
echo " PARTUUID=$SDBOOTPUUID /boot vfat ro,defaults 0 2"
|
||||
echo " PARTUUID=$SDROOTPUUID /backup ext4 ro,defaults,noatime 0 2"
|
||||
echo " PARTUUID=$HDROOTPUUID / ext4 defaults,noatime 0 1"
|
||||
@@ -337,7 +337,7 @@ step_5() {
|
||||
echo
|
||||
|
||||
# etc
|
||||
echo " [I] modify $HDROOT/etc/dhcpcd.conf for static IPs"
|
||||
info "modify $HDROOT/etc/dhcpcd.conf for static IPs"
|
||||
}
|
||||
|
||||
read_sd_dev() {
|
||||
@@ -356,7 +356,7 @@ read_sd_dev() {
|
||||
SDROOTDEV=
|
||||
SDBOOTPUUID=
|
||||
SDROOTPUUID=
|
||||
echo " [I] Available devices:"
|
||||
info "Available devices:"
|
||||
echo
|
||||
exe lsblk -p
|
||||
echo
|
||||
@@ -403,7 +403,7 @@ read_hd_dev() {
|
||||
HDROOT=
|
||||
HDROOTPUUID=
|
||||
HDSWAPPUUID=
|
||||
echo " [I] Available devices:"
|
||||
info "Available devices:"
|
||||
echo
|
||||
exe lsblk -p
|
||||
echo
|
||||
@@ -462,7 +462,7 @@ step_22() {
|
||||
error -e "No SD found"
|
||||
return 1
|
||||
fi
|
||||
echo " [I] Device to be resized: $SDROOTDEV"
|
||||
info "Device to be resized: $SDROOTDEV"
|
||||
|
||||
exe umount -q "$SDROOT"
|
||||
exe parted -s "$SDDEV" "resizepart $SDROOTPARTNO -1" quit
|
||||
@@ -493,7 +493,7 @@ step_24() {
|
||||
if [ ! -z "$2" ] && [ "$2" == "-p" ] ; then
|
||||
exep "grep \"$ledPowerBright\" $startScript >>/dev/null"
|
||||
if [ $? -eq 0 ] ; then
|
||||
echo " [I] Power LED brightness already used. Please check $startScript manually for:"
|
||||
info "Power LED brightness already used. Please check $startScript manually for:"
|
||||
echo " $ledOffCmd"
|
||||
return 1
|
||||
fi
|
||||
@@ -564,7 +564,7 @@ step_34() {
|
||||
exe $tvserviceOffCmd
|
||||
exep "grep \"$tvserviceBin\" $startScript >>/dev/null"
|
||||
if [ $? -eq 0 ] ; then
|
||||
echo " [I] Tvservice already used. Please check $startScript manually for:"
|
||||
info "Tvservice already used. Please check $startScript manually for:"
|
||||
echo " $tvserviceOffCmd"
|
||||
return 1
|
||||
fi
|
||||
|
@@ -1,34 +1,26 @@
|
||||
#!/bin/bash
|
||||
|
||||
toolName=redis
|
||||
toolDeps=redis-server
|
||||
|
||||
# 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_NAME="${SCRIPT_NAME}.cfg"
|
||||
CONFIG_FILE_TEMPLATE="$WDIR/${CONFIG_FILE_NAME}.example"
|
||||
readonly toolName=redis
|
||||
readonly toolDeps=redis-server
|
||||
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 "Install $toolName"; }
|
||||
step_1_alias() { echo "install"; }
|
||||
step_1() {
|
||||
local aptOpt=
|
||||
if quiet;then
|
||||
aptOpt="-y"
|
||||
fi
|
||||
|
||||
exe apt update
|
||||
exe apt install $toolDeps $aptOpt
|
||||
exe apt install $toolDeps $sq_aptOpt
|
||||
}
|
||||
|
||||
step_2_info() { echo "Installation notes"; }
|
||||
@@ -82,5 +74,7 @@ step_10() {
|
||||
fi
|
||||
}
|
||||
|
||||
# shellcheck disable=SC2034 # Appears unused
|
||||
readonly sqr_minVersion=16
|
||||
# shellcheck disable=SC1091 # Don't follow this source
|
||||
. /usr/local/bin/sequencer.sh
|
||||
|
@@ -66,7 +66,7 @@ step_2() {
|
||||
step_3_info() { echo "Configure $toolName"; }
|
||||
step_3_alias() { echo "config"; }
|
||||
step_3() {
|
||||
echo " [I] Recommended composer packages to be added to \"require\" section:"
|
||||
info "Recommended composer packages to be added to \"require\" section:"
|
||||
echo ' "alexandregz/twofactor_gauthenticator": "dev-master",'
|
||||
echo ' "johndoh/contextmenu": "*",'
|
||||
echo ' "kitist/html5_notifier": "*",'
|
||||
@@ -76,12 +76,12 @@ step_3() {
|
||||
exe vi "$RC_LOC/composer.json"
|
||||
step postupgrade
|
||||
|
||||
echo " [I] Generating mysql database $RC_DATABASE"
|
||||
info "Generating mysql database $RC_DATABASE"
|
||||
echo
|
||||
exe ${seq_origin:?}/mysql.sh createdb -c utf8mb4
|
||||
|
||||
echo
|
||||
echo " [I] Now visit: http://url-to-roundcube/installer/"
|
||||
info "Now visit: http://url-to-roundcube/installer/"
|
||||
echo
|
||||
echo " ! Check the database password in $RC_LOC/config/config.inc.php"
|
||||
echo " afterwards, the installer may have corrupted some special character"
|
||||
@@ -151,7 +151,7 @@ step_20() {
|
||||
fi
|
||||
exe ${seq_origin:?}/mysql.sh -qq backup "$RC_DATABASE" "$RC_BACKUP"
|
||||
local wwwBackup="$RC_BACKUP/${toolName}_www_`date +%Y%m%d-%H%M%S`.tar.gz"
|
||||
echo " [I] Backing up webserver directory to $wwwBackup"
|
||||
info "Backing up webserver directory to $wwwBackup"
|
||||
exe cd "$RC_LOC/.."
|
||||
exe tar czf "$wwwBackup" $(basename "$RC_LOC")
|
||||
}
|
||||
@@ -195,16 +195,16 @@ step_22() {
|
||||
downloadLatest
|
||||
|
||||
step backup
|
||||
echo " [I] Installing version $latestVersion to $RC_LOC"
|
||||
info "Installing version $latestVersion to $RC_LOC"
|
||||
exe "$tempInstall" "$RC_LOC"
|
||||
echo " [I] Make sure to check composer.json-dist file for upstream changes"
|
||||
info "Make sure to check composer.json-dist file for upstream changes"
|
||||
}
|
||||
|
||||
step_23_info() { echo "Post upgrade procedure"; }
|
||||
step_23_alias() { echo "postupgrade"; }
|
||||
step_23() {
|
||||
exe cd "$RC_LOC"
|
||||
echo " [I] Starting post update procedure"
|
||||
info "Starting post update procedure"
|
||||
exe php composer.phar update --no-dev
|
||||
}
|
||||
|
||||
@@ -233,12 +233,12 @@ downloadLatest() {
|
||||
if [ ! -e "$tempExtract" ] ; then
|
||||
exe mkdir -p "$tempDown"
|
||||
exe wget -O "$tempLoc" $downUrl
|
||||
endReturn -o $? "Download failed: $downUrl"
|
||||
endReturn "Download failed: $downUrl"
|
||||
exe cd "$tempDown"
|
||||
exe tar -xf "$tempLoc"
|
||||
endReturn -o $? "Extract failed: $tempLoc"
|
||||
endReturn "Extract failed: $tempLoc"
|
||||
else
|
||||
echo " [I] Found existing download: $tempExtract"
|
||||
info "Found existing download: $tempExtract"
|
||||
fi
|
||||
}
|
||||
tempDown="/tmp/roundcube"
|
||||
|
@@ -5,16 +5,13 @@
|
||||
# source:
|
||||
# - https://selivan.github.io/2017/02/07/rsyslog-log-forward-save-filename-handle-multi-line-failover.html
|
||||
|
||||
toolName="rsyslog"
|
||||
toolConfig="/etc/rsyslog.conf"
|
||||
readonly toolName="rsyslog"
|
||||
readonly toolConfig="/etc/rsyslog.conf"
|
||||
|
||||
# Get script working directory
|
||||
# (when called from a different directory)
|
||||
WDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >>/dev/null 2>&1 && pwd )"
|
||||
CONFIG_SNMP="$WDIR/${toolName}/10-snmp.conf"
|
||||
CONFIG_CRON="$WDIR/${toolName}/10-cron.conf"
|
||||
CONFIG_RNGD="$WDIR/${toolName}/10-rngd.conf"
|
||||
CONFIG_REMOTE="$WDIR/${toolName}/90-remote.conf"
|
||||
CONFIG_SNMP="${seq_origin}/${toolName}/10-snmp.conf"
|
||||
CONFIG_CRON="${seq_origin}/${toolName}/10-cron.conf"
|
||||
CONFIG_RNGD="${seq_origin}/${toolName}/10-rngd.conf"
|
||||
CONFIG_REMOTE="${seq_origin}/${toolName}/90-remote.conf"
|
||||
|
||||
step_1_info() { echo "Install $toolName"; }
|
||||
step_1_alias() { echo "install"; }
|
||||
@@ -27,14 +24,14 @@ step_2_info() { echo "Check configuration"; }
|
||||
step_2_alias() { echo "checkconf"; }
|
||||
step_2() {
|
||||
exe rsyslogd -N 1 -f "$toolConfig"
|
||||
endReturn -o $? "Invalid $toolName configuration"
|
||||
endReturn "Invalid $toolName configuration"
|
||||
}
|
||||
|
||||
step_10_info() { echo "Reduce snmpd syslog messages"; }
|
||||
step_10_alias() { echo "snmpd"; }
|
||||
step_10() {
|
||||
addConf -s -f "$CONFIG_SNMP" "$CONFIG_SNMP_DEST"
|
||||
endReturn -o $?
|
||||
endReturn
|
||||
|
||||
step checkconf
|
||||
exe service rsyslog restart
|
||||
@@ -45,7 +42,7 @@ step_12_info() { echo "Reduce cron syslog messages"; }
|
||||
step_12_alias() { echo "cron"; }
|
||||
step_12() {
|
||||
addConf -s -f "$CONFIG_CRON" "$CONFIG_CRON_DEST"
|
||||
endReturn -o $?
|
||||
endReturn
|
||||
|
||||
step checkconf
|
||||
exe service rsyslog restart
|
||||
@@ -56,7 +53,7 @@ step_14_info() { echo "Reduce rngd syslog messages"; }
|
||||
step_14_alias() { echo "rngd"; }
|
||||
step_14() {
|
||||
addConf -s -f "$CONFIG_RNGD" "$CONFIG_RNGD_DEST"
|
||||
endReturn -o $?
|
||||
endReturn
|
||||
|
||||
step checkconf
|
||||
exe service rsyslog restart
|
||||
@@ -77,9 +74,9 @@ step_16() {
|
||||
return 1
|
||||
fi
|
||||
addConf -s -f "$CONFIG_REMOTE" "$CONFIG_REMOTE_DEST"
|
||||
endReturn -o $? "Custom remote host $remoteHost not applied to destination or check ${sqr_missingConf:-}"
|
||||
endReturn "Custom remote host $remoteHost not applied to destination or check ${sqr_missingConf:-}"
|
||||
exe sed -i "s/12\.34\.56\.78\:514/${remoteHost}/" "$CONFIG_REMOTE_DEST"
|
||||
endReturn -o $? "Couldn't apply $remoteHost to $CONFIG_REMOTE_DEST"
|
||||
endReturn "Couldn't apply $remoteHost to $CONFIG_REMOTE_DEST"
|
||||
|
||||
step checkconf
|
||||
exe service rsyslog restart
|
||||
@@ -104,5 +101,7 @@ step_30() {
|
||||
SERVER_EOF
|
||||
}
|
||||
|
||||
# shellcheck disable=SC2034 # Appears unused
|
||||
readonly sqr_minVersion=16
|
||||
# shellcheck disable=SC1091 # Don't follow this source
|
||||
. /usr/local/bin/sequencer.sh
|
||||
|
38
seqs/snmp.sh
38
seqs/snmp.sh
@@ -25,7 +25,7 @@ step_1() {
|
||||
else
|
||||
exe apt install $toolName
|
||||
fi
|
||||
endReturn -o $? "$toolName installation failed"
|
||||
endReturn "$toolName installation failed"
|
||||
}
|
||||
|
||||
step_2_info() {
|
||||
@@ -113,7 +113,7 @@ step_5() {
|
||||
[ -n "${1:-}" ] && lInterface="$1"
|
||||
# Check if interface exists
|
||||
ip -br a | grep -E "^$lInterface" >>/dev/null 2>&1
|
||||
endReturn -o $? "Interface $lInterface does not exist"
|
||||
endReturn "Interface $lInterface does not exist"
|
||||
|
||||
exe ufw allow in on $lInterface to any port 161 proto udp comment "snmp"
|
||||
}
|
||||
@@ -127,7 +127,7 @@ step_20() {
|
||||
fi
|
||||
|
||||
exe wget https://raw.githubusercontent.com/librenms/librenms-agent/master/snmp/raspberry.sh -O "${rpiExtendLoc}"
|
||||
endReturn -o $? "Download failed"
|
||||
endReturn "Download failed"
|
||||
exe chmod +x "$rpiExtendLoc"
|
||||
|
||||
addConf -a "extend raspberry /etc/snmp/raspberry.sh" "$toolConfig"
|
||||
@@ -152,7 +152,7 @@ step_22() {
|
||||
fi
|
||||
|
||||
exe wget https://raw.githubusercontent.com/librenms/librenms-agent/master/snmp/osupdate -O "${osUpdateExtendLoc}"
|
||||
endReturn -o $? "Download failed"
|
||||
endReturn "Download failed"
|
||||
exe chmod +x "$osUpdateExtendLoc"
|
||||
addConf -a "extend osupdate $osUpdateExtendLoc" "$toolConfig"
|
||||
|
||||
@@ -184,7 +184,7 @@ step_25() {
|
||||
exe bash -i
|
||||
info "Interactive shell ended. Continuing with $0."
|
||||
exe nginx -t
|
||||
endReturn -o $? "Nginx configuration error"
|
||||
endReturn "Nginx configuration error"
|
||||
|
||||
exe service nginx restart
|
||||
;;
|
||||
@@ -211,7 +211,7 @@ step_26_alias() { echo "phpfpm_config"; }
|
||||
step_26() {
|
||||
exe sed -i "s/^;\(pm\.status_path\)/\1/" "$phpPoolConfigLoc"
|
||||
exe php-fpm${phpVersionStr} -t
|
||||
endReturn -o $? "Invalid php configuration"
|
||||
endReturn "Invalid php configuration"
|
||||
|
||||
service php${phpVersionStr}-fpm restart
|
||||
}
|
||||
@@ -227,7 +227,7 @@ step_27() {
|
||||
fi
|
||||
|
||||
exe wget https://github.com/librenms/librenms-agent/raw/master/snmp/phpfpmsp -O "${phpfpmExtendLoc}"
|
||||
endReturn -o $? "Download failed"
|
||||
endReturn "Download failed"
|
||||
exe chmod +x "$phpfpmExtendLoc"
|
||||
|
||||
addConf -a "extend phpfpmsp ${phpfpmExtendLoc}" "$toolConfig"
|
||||
@@ -253,7 +253,7 @@ step_29() {
|
||||
exe bash -i
|
||||
info "Interactive shell ended. Continuing with $0."
|
||||
exe nginx -t
|
||||
endReturn -o $? "Nginx configuration error"
|
||||
endReturn "Nginx configuration error"
|
||||
|
||||
exe service nginx restart
|
||||
;;
|
||||
@@ -279,7 +279,7 @@ step_30() {
|
||||
fi
|
||||
|
||||
exe wget https://raw.githubusercontent.com/librenms/librenms-agent/master/snmp/nginx -O "${nginxExtendLoc}"
|
||||
endReturn -o $? "Download failed"
|
||||
endReturn "Download failed"
|
||||
exe chmod +x "$nginxExtendLoc"
|
||||
|
||||
addConf -a "extend nginx ${nginxExtendLoc}" "$toolConfig"
|
||||
@@ -293,9 +293,9 @@ step_32_info() { echo "Extend for postfix detailed and queue"; }
|
||||
step_32_alias() { echo "postfix"; }
|
||||
step_32() {
|
||||
exe wget https://github.com/librenms/librenms-agent/raw/master/snmp/postfix-queues -O "${postfixQueuesExtendLoc}"
|
||||
endReturn -o $? "Download postfix-queues failed"
|
||||
endReturn "Download postfix-queues failed"
|
||||
exe wget https://github.com/librenms/librenms-agent/raw/master/snmp/postfixdetailed -O "${postfixScript}"
|
||||
endReturn -o $? "Download postfixdetailed failed"
|
||||
endReturn "Download postfixdetailed failed"
|
||||
|
||||
exe chmod +x "${postfixQueuesExtendLoc}"
|
||||
exe chmod +x "${postfixScript}"
|
||||
@@ -352,7 +352,7 @@ step_37_info() { echo "Extend for fail2ban jail information"; }
|
||||
step_37_alias() { echo "fail2ban"; }
|
||||
step_37(){
|
||||
exe wget https://github.com/librenms/librenms-agent/raw/master/snmp/fail2ban -O "${fail2banExtendLoc}"
|
||||
endReturn -o $? "Download postfix failed"
|
||||
endReturn "Download postfix failed"
|
||||
|
||||
exe chmod +x "$fail2banExtendLoc"
|
||||
|
||||
@@ -384,7 +384,7 @@ step_40() {
|
||||
fi
|
||||
|
||||
exe wget https://raw.githubusercontent.com/librenms/librenms-agent/master/snmp/distro -O "${distroExtendLoc}"
|
||||
endReturn -o $? "Download distro detection script failed"
|
||||
endReturn "Download distro detection script failed"
|
||||
exe chmod +x "$distroExtendLoc"
|
||||
|
||||
info "Create distro extend"
|
||||
@@ -409,10 +409,10 @@ step_42() {
|
||||
[ $? -ne 0 ] && return 0
|
||||
|
||||
exe apt install dhcpd-pools ${sq_aptOpt}
|
||||
endReturn -o $? "Install dhcpd-pools failed"
|
||||
endReturn "Install dhcpd-pools failed"
|
||||
|
||||
exe wget $locExtUrl -O "${locExtLoc}"
|
||||
endReturn -o $? "Download $locExtName script failed"
|
||||
endReturn "Download $locExtName script failed"
|
||||
exe chmod +x "$locExtLoc"
|
||||
|
||||
info "Create extend for $locExtName"
|
||||
@@ -421,7 +421,7 @@ step_42() {
|
||||
info "Create config for $locExtName"
|
||||
addConf -s "$dhcpExtendConfig" "$dhcpExtendConfigLoc"
|
||||
|
||||
echo " [W] Adapt config $dhcpExtendConfigLoc manually and restart snmpd"
|
||||
warning "Adapt config $dhcpExtendConfigLoc manually and restart snmpd"
|
||||
}
|
||||
dhcpExtendConfigLoc="${toolConfigLoc}/dhcp.json"
|
||||
dhcpExtendConfig="{\"leasefile\": \"/var/lib/dhcp/dhcpd.leases\"
|
||||
@@ -438,7 +438,7 @@ step_44() {
|
||||
[ $? -ne 0 ] && return 0
|
||||
|
||||
exe wget $locExtUrl -O "${locExtLoc}"
|
||||
endReturn -o $? "Download $locExtName script failed"
|
||||
endReturn "Download $locExtName script failed"
|
||||
exe chmod +x "$locExtLoc"
|
||||
|
||||
info "Create extend for $locExtName"
|
||||
@@ -483,7 +483,7 @@ step_46() {
|
||||
exe apt install $piholeDeps ${sq_aptOpt}
|
||||
|
||||
exe wget $locExtUrl -O "${locExtLoc}"
|
||||
endReturn -o $? "Download $locExtName script failed"
|
||||
endReturn "Download $locExtName script failed"
|
||||
exe chmod +x "$locExtLoc"
|
||||
|
||||
info "Create extend for $locExtName"
|
||||
@@ -493,7 +493,7 @@ step_46() {
|
||||
color red
|
||||
echo -e " [W] Check the following in the extend script and restart snmpd:\n"
|
||||
else
|
||||
echo " [I] Check the follwing in the extend script:"
|
||||
info "Check the follwing in the extend script:"
|
||||
fi
|
||||
echo "(API_AUTH_KEY) Add your pi-hole API key"
|
||||
echo " (API_URL) and check the API URL"
|
||||
|
@@ -20,7 +20,7 @@ step_3_alias() { echo "create"; }
|
||||
step_3() {
|
||||
exep "ssh-keygen -l -f $toolIdentity 2>>/dev/null"
|
||||
if [ $? -eq 0 ]; then
|
||||
echo " [I] Using key found at $toolIdentity."
|
||||
info "Using key found at $toolIdentity."
|
||||
return 0
|
||||
fi
|
||||
exe ssh-keygen -b 4096 -t rsa -C "$(hostname)" -N "" -f $(realpath $toolIdentity)
|
||||
|
@@ -69,7 +69,7 @@ step_10() {
|
||||
exe mv "${loBackup}" "${sc_synadmLoc}" 2>/dev/null
|
||||
else
|
||||
exe tar -xf "${loTemp}" -C "$(dirname -- "${sc_synadmLoc}")"
|
||||
endReturn -o $? "Extraction failed"
|
||||
endReturn "Extraction failed"
|
||||
exe mv "$(dirname -- "${sc_synadmLoc}")/${toolName}-${versionNew}" "${sc_synadmLoc}"
|
||||
exe chown -R root: "${sc_synadmLoc}"
|
||||
info "Downloaded to ${sc_synadmLoc}"
|
||||
|
@@ -127,11 +127,11 @@ step_30() {
|
||||
return 1
|
||||
fi
|
||||
|
||||
echo " [I] Upgrading data"
|
||||
info "Upgrading data"
|
||||
exe mv "$toolConfigLoc/lib" "$toolConfigLoc/lib_bu"
|
||||
exe cp -ar "$gitLibLoc/lib" "$toolConfigLoc/"
|
||||
|
||||
echo " [I] Upgrading html"
|
||||
info "Upgrading html"
|
||||
exe mv "$toolHtmlLoc" "${toolHtmlLoc}_bu"
|
||||
exe cp -ar "$gitHtmlLoc" "$toolHtmlLoc"
|
||||
exe cp -arL "$toolBackupLoc/config.php" "$toolHtmlLoc"
|
||||
|
@@ -16,7 +16,7 @@ step_1() {
|
||||
|
||||
echo -n "Downloading tvheadend repository key ... "
|
||||
exe wget -qO- https://doozer.io/keys/tvheadend/tvheadend/pgp | sudo apt-key add -
|
||||
endReturn -o $? "Download of repository key failed"
|
||||
endReturn "Download of repository key failed"
|
||||
|
||||
addConf -c "$sourceEntry" "$sourceList"
|
||||
}
|
||||
|
@@ -14,7 +14,7 @@ step_1_alias() { echo "install"; }
|
||||
step_1() {
|
||||
exe apt update
|
||||
exe apt install $serverPackages
|
||||
endReturn -o $? "Server package installation error"
|
||||
endReturn "Server package installation error"
|
||||
}
|
||||
|
||||
step_2_info() { echo "Basic nginx configuration for initial letsencrypt certificate creation"; }
|
||||
@@ -36,7 +36,7 @@ step_2() {
|
||||
|
||||
echo -n " [I] Restarting Nginx ... "
|
||||
exe service nginx restart && echo "ok"
|
||||
endReturn -o $? "Nginx error during startup"
|
||||
endReturn "Nginx error during startup"
|
||||
}
|
||||
snippetLetsencryptLoc="/etc/nginx/snippets/letsencrypt.conf"
|
||||
siteLetsencryptWww="/var/www/letsencrypt"
|
||||
@@ -58,7 +58,7 @@ step_3_info() {
|
||||
}
|
||||
step_3() {
|
||||
exe apt install $phpPackages
|
||||
endReturn -o $? "$phpName error during startup"
|
||||
endReturn "$phpName error during startup"
|
||||
}
|
||||
phpFpmConfigLocation="/etc/php/${phpVersion}/fpm/conf.d/90-custom_pi.ini"
|
||||
phpFpmConfig="\
|
||||
@@ -88,7 +88,7 @@ step_4() {
|
||||
|
||||
echo -n "Restarting ${phpName} ..."
|
||||
exe service ${phpName}-fpm restart
|
||||
endReturn -o $? "$phpName error during restart"
|
||||
endReturn "$phpName error during restart"
|
||||
echo "ok"
|
||||
}
|
||||
|
||||
|
@@ -40,7 +40,7 @@ step_20() {
|
||||
exe apt-get install "${toolDeps[@]}" ${sq_aptOpt}
|
||||
info "Installing ${toolName} from ${sq_gitUrl}"
|
||||
exe git clone "${sq_gitUrl}" "${sc_whoogleDir:?}"
|
||||
endReturn -o $? "Cloning ${toolName} failed"
|
||||
endReturn "Cloning ${toolName} failed"
|
||||
|
||||
exe cd "${sc_whoogleDir:?}"
|
||||
exe python3 -m venv venv
|
||||
@@ -84,7 +84,7 @@ step_30_info() { echo "Upgrade installation using git"; }
|
||||
step_30_alias() { echo "upgrade"; }
|
||||
step_30() {
|
||||
exe cd "${sc_whoogleDir:?}"
|
||||
endReturn -o $? "${toolName} doesn't seam to be installed"
|
||||
endReturn "${toolName} doesn't seam to be installed"
|
||||
exe service "${toolName}" stop
|
||||
exe git pull
|
||||
}
|
||||
|
@@ -1,33 +1,14 @@
|
||||
#!/bin/bash
|
||||
|
||||
toolName=wireguard
|
||||
toolBin=wg
|
||||
toolDefaultConf=wg0
|
||||
toolService=wg-quick@$toolDefaultConf
|
||||
|
||||
# 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"
|
||||
|
||||
#step_config() {
|
||||
#echo "Called once before executing steps."
|
||||
## e.g. to source a config file manually:
|
||||
#. "$CONFIG_FILE"
|
||||
## or to use sequencer api:
|
||||
#initSeqConfig "$CONFIG_FILE_NAME" "$CONFIG_FILE_TEMPLATE"
|
||||
#if [ $? -eq 0 ] ; then
|
||||
# CONFIG=1
|
||||
#fi
|
||||
#}
|
||||
readonly toolName=wireguard
|
||||
readonly toolDefaultConf=wg0
|
||||
readonly toolService=wg-quick@$toolDefaultConf
|
||||
|
||||
step_1_info() { echo "Prepare installation of $toolName"; }
|
||||
step_1_alias() { echo "install"; }
|
||||
step_1_alias() { echo "setup"; }
|
||||
step_1() {
|
||||
exe apt install raspberrypi-kernel-headers
|
||||
endReturn -o $? "Installation of kernel headers failed"
|
||||
endReturn "Installation of kernel headers failed"
|
||||
addConf -s "deb http://deb.debian.org/debian/ unstable main" "/etc/apt/sources.list.d/unstable.list"
|
||||
exep "wget -O - https://ftp-master.debian.org/keys/archive-key-$(lsb_release -sr).asc | sudo apt-key add -"
|
||||
addConf -s "$pinEntry" "/etc/apt/preferences.d/limit-unstable"
|
||||
@@ -38,6 +19,7 @@ Pin: release a=unstable
|
||||
Pin-Priority: 150"
|
||||
|
||||
step_2_info() { echo "Installing $toolName"; }
|
||||
step_2_alias() { echo "install"; }
|
||||
step_2() {
|
||||
local aptOpt=""
|
||||
if quiet ; then
|
||||
@@ -82,12 +64,7 @@ step_14() {
|
||||
}
|
||||
defaultConfLoc="/etc/$toolName/$toolDefaultConf.conf"
|
||||
|
||||
|
||||
step_20_info() { echo "Usage notes"; }
|
||||
step_20() {
|
||||
echo " [I] Some usage Notes"
|
||||
}
|
||||
|
||||
|
||||
# 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