refactoring changes from sequpgrade (endReturn, ...) and some modernizations
This commit is contained in:
@@ -25,15 +25,15 @@ seq_config() {
|
||||
else
|
||||
dry || return 1
|
||||
fi
|
||||
|
||||
|
||||
## Apt cmdline option to suppress user interaction
|
||||
interactive || sq_aptOpt="-y"
|
||||
|
||||
|
||||
## Return of non zero value will abort the sequence
|
||||
return 0
|
||||
}
|
||||
|
||||
step_1_info() {
|
||||
step_1_info() {
|
||||
# eval needed to expand sourced configuration variables
|
||||
echo "Install $toolName dependencies:"
|
||||
echoinfo "${toolPhpDeps[@]/#/php${PFA_PHP_VERSION:-}-}"
|
||||
@@ -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,16 +153,16 @@ 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
|
||||
}
|
||||
|
||||
|
||||
step_20_info() {
|
||||
step_20_info() {
|
||||
echo -n "Create a backup"
|
||||
if [ $sq_config -ne 0 ] ; then
|
||||
echo " at $PFA_BACKUP"
|
||||
@@ -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
|
||||
@@ -309,7 +309,7 @@ step_23() {
|
||||
exe rm -rf "$tempDown"
|
||||
}
|
||||
|
||||
step_100_info() {
|
||||
step_100_info() {
|
||||
echo "Execute $toolName client script"
|
||||
echoinfo "[OPTIONS] are passed on to $toolName-cli unmodified"
|
||||
}
|
||||
|
Reference in New Issue
Block a user