diff --git a/seqs/postfixadmin.cfg.example b/seqs/postfixadmin.cfg.example index f21513e..8172694 100644 --- a/seqs/postfixadmin.cfg.example +++ b/seqs/postfixadmin.cfg.example @@ -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" diff --git a/seqs/postfixadmin.sh b/seqs/postfixadmin.sh index 649290e..8858bd3 100755 --- a/seqs/postfixadmin.sh +++ b/seqs/postfixadmin.sh @@ -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 diff --git a/seqs/roundcube.sh b/seqs/roundcube.sh index 75953df..8ad1854 100755 --- a/seqs/roundcube.sh +++ b/seqs/roundcube.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 <