update and simplify
This commit is contained in:
@@ -6,4 +6,4 @@ PFA_SRV_LOC="/srv/postfixadmin"
|
||||
PFA_WEB_LOC="/var/www/pfa"
|
||||
PFA_DATABASE="pfa_db"
|
||||
PFA_BACKUP="/root/backup/pfa"
|
||||
PFA_PHP_VERSION="7.3"
|
||||
PFA_PHP_VERSION="8.1"
|
||||
|
@@ -1,51 +1,47 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
|
||||
readonly toolName=postfixadmin
|
||||
# since php8.0 json is always available
|
||||
readonly toolPhpDeps=(bz2 curl fpm gmp imap intl mbstring mysql xml zip)
|
||||
readonly toolConfName="config.local.php"
|
||||
readonly toolTemplates="templates_c"
|
||||
readonly latestUrl="https://api.github.com/repos/$toolName/$toolName/releases/latest"
|
||||
readonly fetchmailUser="fetchmail"
|
||||
readonly fetchmailDeps="fetchmail liblockfile-simple-perl"
|
||||
|
||||
toolName=postfixadmin
|
||||
toolPhpDeps='php${PFA_PHP_VERSION:-}-fpm php${PFA_PHP_VERSION:-}-imap php${PFA_PHP_VERSION:-}-mbstring php${PFA_PHP_VERSION:-}-mysql php${PFA_PHP_VERSION:-}-json php${PFA_PHP_VERSION:-}-curl php${PFA_PHP_VERSION:-}-zip php${PFA_PHP_VERSION:-}-xml php${PFA_PHP_VERSION:-}-bz2 php${PFA_PHP_VERSION:-}-intl php${PFA_PHP_VERSION:-}-gmp'
|
||||
toolConfName="config.local.php"
|
||||
toolTemplates="templates_c"
|
||||
toolTemplatesLoc=
|
||||
toolAdditionsLoc=
|
||||
latestUrl="https://api.github.com/repos/$toolName/$toolName/releases/latest"
|
||||
fetchmailUser="fetchmail"
|
||||
fetchmailDeps="fetchmail liblockfile-simple-perl"
|
||||
|
||||
# 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=
|
||||
sq_config=0
|
||||
|
||||
seq_config() {
|
||||
if initSeqConfig "$CONFIG_FILE_NAME" "$CONFIG_FILE_TEMPLATE" ; then
|
||||
if initSeqConfig "${seq_configName:?}" "${seq_configTemplate:?}" ; then
|
||||
info "${toolName} path: ${PFA_WEB_LOC:-}"
|
||||
info -a "${toolName} backup: ${PFA_BACKUP:-}"
|
||||
info -a " php Version: ${PFA_PHP_VERSION:-}"
|
||||
CONFIG=1
|
||||
sq_config=1
|
||||
toolTemplatesLoc="$PFA_SRV_LOC/$toolTemplates"
|
||||
toolAdditionsLoc="$PFA_SRV_LOC/ADDITIONS"
|
||||
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() {
|
||||
# eval needed to expand sourced configuration variables
|
||||
local localDeps=`eval "echo \"$toolPhpDeps\""`
|
||||
echo "Install $toolName dependencies:"
|
||||
echoinfo "$localDeps"
|
||||
echoinfo "${toolPhpDeps[@]/#/php${PFA_PHP_VERSION:-}-}"
|
||||
}
|
||||
step_1_alias() { echo "install"; }
|
||||
step_1() {
|
||||
# eval needed to expand sourced configuration variables
|
||||
local localDeps=`eval "echo \"$toolPhpDeps\""`
|
||||
local aptOpt=
|
||||
if quiet;then
|
||||
aptOpt="-y"
|
||||
fi
|
||||
exe apt update
|
||||
exe apt install $localDeps $aptOpt
|
||||
exe apt install "${toolPhpDeps[@]/#/php${PFA_PHP_VERSION:?}-}" ${sq_aptOpt:-}
|
||||
}
|
||||
|
||||
step_2_info() { echo "Install $toolName to ${PFA_SRV_LOC:-}"; }
|
||||
@@ -56,11 +52,7 @@ step_2() {
|
||||
step_3_info() { echo "Install fetchmail"; }
|
||||
step_3_alias() { echo "install_fetchmail"; }
|
||||
step_3() {
|
||||
local aptOpt=
|
||||
if quiet;then
|
||||
aptOpt="-y"
|
||||
fi
|
||||
exe apt install $fetchmailDeps $aptOpt
|
||||
exe apt install $fetchmailDeps ${sq_aptOpt:-}
|
||||
endReturn -o $? "Failed to install fetchmail"
|
||||
exe systemctl stop fetchmail
|
||||
exe systemctl disable fetchmail
|
||||
@@ -69,7 +61,7 @@ step_3() {
|
||||
step_4_info() { echo "Configure postfixadmin to use fetchmail"; }
|
||||
step_4() {
|
||||
echo "# Create mysql config"
|
||||
echo " [$PFA_SRV_LOC/fetchmail.conf]"
|
||||
echo " [/etc/mail/postfixadmin/fetchmail.conf]"
|
||||
echo " # Follow instructions in $toolAdditionsLoc/fetchmail.pl"
|
||||
echo " \$db_type = 'mysql';"
|
||||
echo " \$run_dir=\"/var/lock\";"
|
||||
@@ -172,7 +164,7 @@ step_18() {
|
||||
step_20_info() {
|
||||
echoinfoArgs "[POSTFIXADMIN SRV ROOT]"
|
||||
echo -n "Create a backup"
|
||||
if [ $CONFIG -ne 0 ] ; then
|
||||
if [ $sq_config -ne 0 ] ; then
|
||||
echo " at $PFA_BACKUP"
|
||||
else
|
||||
echo
|
||||
@@ -182,7 +174,7 @@ step_20_alias() { echo "backup"; }
|
||||
step_20() {
|
||||
shift
|
||||
local tempRoot=
|
||||
if [ $CONFIG -eq 0 ] ; then
|
||||
if [ $sq_config -eq 0 ] ; then
|
||||
error -e "No configuration file found"
|
||||
return 1
|
||||
fi
|
||||
@@ -200,7 +192,7 @@ step_20() {
|
||||
exe cd "$tempRoot/.."
|
||||
exe tar czf "$srvBackup" $(basename "$tempRoot")
|
||||
|
||||
exe $WDIR/mysql.sh -qq backup "$PFA_DATABASE" "$PFA_BACKUP"
|
||||
exe ${seq_origin:?}/mysql.sh -qq backup "$PFA_DATABASE" "$PFA_BACKUP"
|
||||
}
|
||||
|
||||
step_22_info() {
|
||||
@@ -291,7 +283,7 @@ step_22() {
|
||||
exe cp -ar "$webConf" "$PFA_SRV_LOC/"
|
||||
else
|
||||
echo " [I] Creating empty configuration file $PFA_SRV_LOC/$toolConfName"
|
||||
exep "echo -e \"# Created gy $WDIR/$(basename $0)\\n\\n# Changeme\" > \"$PFA_SRV_LOC/$toolConfName\""
|
||||
exep "echo -e \"# Created by ${seq_origin:?}/$(basename $0)\\n\\n# Changeme\" > \"$PFA_SRV_LOC/$toolConfName\""
|
||||
fi
|
||||
|
||||
# Templates
|
||||
@@ -327,5 +319,7 @@ step_100() {
|
||||
exe ${PFA_SRV_LOC}/scripts/$toolName-cli $@
|
||||
}
|
||||
|
||||
# shellcheck disable=SC2034 # Appears unused
|
||||
readonly sqr_minVersion=16
|
||||
# shellcheck disable=SC1091 # Don't follow this source
|
||||
. /usr/local/bin/sequencer.sh
|
||||
|
@@ -1,43 +1,42 @@
|
||||
#!/bin/bash
|
||||
|
||||
toolName=roundcube
|
||||
toolPhpDeps="php\${phpVersion}-gd php\${phpVersion}-ldap php-imagick"
|
||||
readonly toolName=roundcube
|
||||
readonly toolPhpDeps=(curl gd intl ldap mbstring mysql xml zip)
|
||||
readonly toolDeps="php-imagick"
|
||||
#https://github.com/roundcube/roundcubemail/releases/latest
|
||||
latestUrl="https://api.github.com/repos/roundcube/roundcubemail/releases/latest"
|
||||
readonly latestUrl="https://api.github.com/repos/roundcube/roundcubemail/releases/latest"
|
||||
latestVersion=
|
||||
tempExtract=
|
||||
tempInstall=
|
||||
phpVersion=
|
||||
|
||||
# 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=
|
||||
sq_config=0
|
||||
|
||||
seq_config() {
|
||||
## use sequencer api:
|
||||
initSeqConfig -t "$CONFIG_FILE_NAME" "$CONFIG_FILE_TEMPLATE"
|
||||
if [ $CONFIG -eq 0 ] ; then
|
||||
CONFIG=1
|
||||
if initSeqConfig "${seq_configName:?}" "${seq_configTemplate:?}" ; then
|
||||
sq_config=1
|
||||
else
|
||||
# End if no configuration file exists
|
||||
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() { echo "Install $toolName"; }
|
||||
step_1_alias() { echo "install"; }
|
||||
step_1() {
|
||||
local aptOpt=
|
||||
if quiet;then
|
||||
aptOpt="-y"
|
||||
fi
|
||||
|
||||
downloadLatest
|
||||
fetchPhpVersion
|
||||
|
||||
if [ ! -z $phpVersion ] ; then
|
||||
if [ -n $phpVersion ] ; then
|
||||
exe apt update
|
||||
exe apt install `eval echo "$toolPhpDeps"` $aptOpt
|
||||
exe apt install "${toolPhpDeps[@]/#/php${phpVersion:?}-}" ${toolDeps:?} ${sq_aptOpt:-}
|
||||
fi
|
||||
|
||||
exe chown -R www-data: "$tempExtract"
|
||||
@@ -68,16 +67,18 @@ step_3_info() { echo "Configure $toolName"; }
|
||||
step_3_alias() { echo "config"; }
|
||||
step_3() {
|
||||
echo " [I] Recommended composer packages to be added to \"require\" section:"
|
||||
echo ' "melanie2/mobile": "*",'
|
||||
echo ' "roundcube/carddav": "*",'
|
||||
echo ' "alexandregz/twofactor_gauthenticator": "dev-master"'
|
||||
echo ' "alexandregz/twofactor_gauthenticator": "dev-master",'
|
||||
echo ' "johndoh/contextmenu": "*",'
|
||||
echo ' "kitist/html5_notifier": "*",'
|
||||
echo ' "roundcube/carddav": "*"'
|
||||
|
||||
exe read -p "Copy the lines above and press Enter to continue."
|
||||
exe vi "$RC_LOC/composer.json"
|
||||
step postupgrade
|
||||
|
||||
echo " [I] Generating mysql database $RC_DATABASE"
|
||||
echo
|
||||
exe $WDIR/mysql.sh createdb -c utf8mb4
|
||||
exe ${seq_origin:?}/mysql.sh createdb -c utf8mb4
|
||||
|
||||
echo
|
||||
echo " [I] Now visit: http://url-to-roundcube/installer/"
|
||||
@@ -91,6 +92,7 @@ step_3() {
|
||||
step_10_info() { echo "Configuration notes"; }
|
||||
step_10_alias() { echo "notes"; }
|
||||
step_10() {
|
||||
fetchPhpVersion
|
||||
color green
|
||||
cat <<NOTES_END
|
||||
# smtp port if missing after installation
|
||||
@@ -101,20 +103,10 @@ step_10() {
|
||||
|
||||
# Enable two factor auth (installed with step config) for all user
|
||||
[$RC_LOC/plugins/twofactor_gauthenticator/config.inc.php]
|
||||
$rcmail_config['users_allowed_2FA'] = array('.*');
|
||||
|
||||
# Add mobile skin to roundcube and run step 'postupgrade'.
|
||||
Don't forget to activate plugins if asked for.
|
||||
|
||||
[$RC_LOC/composer.json]
|
||||
"require": {
|
||||
...
|
||||
"mobiledetect/mobiledetectlib": "^2.8",
|
||||
"roundcube/elastic4mobile": "dev-master"
|
||||
}
|
||||
\$rcmail_config['users_allowed_2FA'] = array('.*');
|
||||
|
||||
# Install pspell and aspell spell check engine
|
||||
apt install php7.x-pspell aspell-en aspell-de
|
||||
apt install php${phpVersion}-pspell aspell-en aspell-de
|
||||
|
||||
[$RC_LOC/config/config.inc.php]
|
||||
\$config['spellcheck_engine'] = 'pspell';
|
||||
@@ -142,7 +134,7 @@ TROUBLE_END
|
||||
|
||||
step_20_info() {
|
||||
echo -n "Create a backup"
|
||||
if [ $CONFIG -ne 0 ] ; then
|
||||
if (( ${sq_config} )) ; then
|
||||
echo " at $RC_BACKUP"
|
||||
else
|
||||
echo
|
||||
@@ -150,14 +142,14 @@ step_20_info() {
|
||||
}
|
||||
step_20_alias() { echo "backup"; }
|
||||
step_20() {
|
||||
if [ $CONFIG -eq 0 ] ; then
|
||||
if [ ${sq_config} -eq 0 ] ; then
|
||||
error -e "No configuration file found"
|
||||
return 1
|
||||
fi
|
||||
if [ ! -z $RC_BACKUP ] ; then
|
||||
exe mkdir -p "$RC_BACKUP"
|
||||
fi
|
||||
exe $WDIR/mysql.sh -qq backup "$RC_DATABASE" "$RC_BACKUP"
|
||||
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"
|
||||
exe cd "$RC_LOC/.."
|
||||
@@ -254,5 +246,7 @@ downloadLatest() {
|
||||
tempDown="/tmp/roundcube"
|
||||
tempLoc="$tempDown/rc.tar.gz"
|
||||
|
||||
# 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