From 79d8b859cded1b78d64347e5d924b463f3574e4d Mon Sep 17 00:00:00 2001 From: Christoph Date: Sun, 13 May 2018 20:13:19 +0200 Subject: [PATCH] Add sample configuration for AMaViS install script. --- conf/install_amavis.conf.sample | 23 ++++ install_postfixadmin.sh | 216 ++++++++++++++++++++------------ 2 files changed, 157 insertions(+), 82 deletions(-) create mode 100644 conf/install_amavis.conf.sample diff --git a/conf/install_amavis.conf.sample b/conf/install_amavis.conf.sample new file mode 100644 index 0000000..9b6d62d --- /dev/null +++ b/conf/install_amavis.conf.sample @@ -0,0 +1,23 @@ +# --- +# - Parametersettins postfix bases system +# --- + +_HOSTNAME= +_IPV4= +_IPV6= + +_QUARANTINE_DIR=/var/QUARANTINE +_QUARANTINE_ADMIN=postmaster\@$mydomain + +_DB_IN_USE=false +_DB_TYPE=None +_DB_HOST= +_DB_NAME= +_DB_USER= +_DB_PASS= +_INSTALL_CLAMAV_UNOFFICIAL_SIGS=true +_MALWARE_PATROL_IN_USE=true +_MALWERE_PATROL_FREE=false +_MP_RECEIPT_NUMBER=106015125438 +_SECURITE_INFO_IN_USE=true +_SI_AUTHORISATION_SIGNATURE=abb4ec6b194639f3d123154f1b971843a3b8751d8c1bcdc7d07ed6db26621b11bca0e23d2a42b60aef3f7b7803a1466a964d90c7b1e82d67c7680c8f46b59a4e diff --git a/install_postfixadmin.sh b/install_postfixadmin.sh index 0da5815..3f57447 100755 --- a/install_postfixadmin.sh +++ b/install_postfixadmin.sh @@ -130,10 +130,39 @@ detect_os_1 () { # - Is 'systemd' supported on this system # - -if [ "X`which systemd`" = "X" ]; then - SYSTEMD_EXISTS=false -else - SYSTEMD_EXISTS=true +systemd_supported=false + +systemd=$(which systemd) +systemctl=$(which systemctl) + +if [[ -n "$systemd" ]] && [[ -n "$systemctl" ]] ; then + systemd_supported=true +fi + +# - Look for systemd service file or sysv init script for apache2 webservice +# - +APACHE_SERVICE_FILE="" +APACHE_INIT_SCRIPT="" +if $systemd_supported ; then + # - Is Service exclusive controlled by systemd + # - + if systemctl -t service list-unit-files \ + | grep -e "^apache" \ + | grep -q -E "(enabled|disabled)" 2> /devnull ; then + + APACHE_SERVICE_FILE=$(systemctl -t service list-unit-files \ + | grep -e "^apache" \ + | awk '{print$1}') + + fi +fi + +if [[ -z "$APACHE_SERVICE_FILE" ]] ; then + if [ -x "/etc/init.d/apache2" ]; then + APACHE_INIT_SCRIPT="/etc/init.d/apache2" + elif [ -x "/etc/init.d/apachectl" ]; then + APACHE_INIT_SCRIPT="/etc/init.d/apachectl" + fi fi # - Set variable @@ -435,7 +464,7 @@ echo -e "\tHostname for Vacation Messages.......: $AUTOREPLY_HOSTNAME" echo -e "\tUser of vacation script..............: $VACATION_USER" echo -e "\tGroup of vacation script.............: $VACATION_GROUP" echo "" -echo -e "\tSystem supports systemd..............: $SYSTEMD_EXISTS" +echo -e "\tSystem supports systemd..............: $systemd_supported" echo "" echo "" @@ -1156,10 +1185,26 @@ fi echononl "\tCreate VHost Configuration '${WEBSITE_NAME}.conf'.." _failed=false -cat < ${APACHE_VHOST_DIR}/${WEBSITE_NAME}.conf 2>> $log_file +_create_vhost_config=true +if [[ -n "$IPV6" ]] && [[ -n "$IPV4" ]] ; then + _vhost_ip_string_80="$IPV4:80 [$IPV6]:80" + _vhost_ip_string_443="$IPV4:443 [$IPV6]:443" +elif [[ -n "$IPV4" ]] ; then + _vhost_ip_string_80="$IPV4:80" + _vhost_ip_string_443="$IPV4:443" +elif [[ -n "$IPV6" ]] ; then + _vhost_ip_string_80=" [$IPV6]:80" + _vhost_ip_string_443=" [$IPV6]:443" +else + echo_failed + error "Neither an ipv4 nor an ipv6 address are given.!" + _create_vhost_config=false +fi +if $_create_vhost_config ; then + cat < ${APACHE_VHOST_DIR}/${WEBSITE_NAME}.conf 2>> $log_file # -- $WEBSITE_NAME -- # - + ServerAdmin $WEBMASTER_EMAIL @@ -1175,19 +1220,19 @@ cat < ${APACHE_VHOST_DIR}/${WEBSITE_NAME}.conf 2>> $log_file - + ServerAdmin $WEBMASTER_EMAIL ServerName $WEBSITE_NAME EOF -if [[ $? -ne 0 ]]; then - failed=true -fi + if [[ $? -ne 0 ]]; then + failed=true + fi -if [[ "$PHP_TYPE" = "mod_php" ]] ; then - cat <> ${APACHE_VHOST_DIR}/${WEBSITE_NAME}.conf 2>> $log_file + if [[ "$PHP_TYPE" = "mod_php" ]] ; then + cat <> ${APACHE_VHOST_DIR}/${WEBSITE_NAME}.conf 2>> $log_file ## - its allowed to overwrite by .htaccess ## - php_value error_reporting "E_ALL & ~E_NOTICE" @@ -1200,11 +1245,11 @@ if [[ "$PHP_TYPE" = "mod_php" ]] ; then DocumentRoot "${WEBSITE_BASEDIR}/htdocs/" EOF - if [[ $? -ne 0 ]]; then - failed=true - fi -elif [[ "$PHP_TYPE" = "fcgid" ]]; then - cat <> ${APACHE_VHOST_DIR}/${WEBSITE_NAME}.conf 2>> $log_file + if [[ $? -ne 0 ]]; then + failed=true + fi + elif [[ "$PHP_TYPE" = "fcgid" ]]; then + cat <> ${APACHE_VHOST_DIR}/${WEBSITE_NAME}.conf 2>> $log_file DocumentRoot "${WEBSITE_BASEDIR}/htdocs/" Require all granted @@ -1215,36 +1260,36 @@ elif [[ "$PHP_TYPE" = "fcgid" ]]; then Options +ExecCGI EOF - if [[ $? -ne 0 ]]; then - failed=true - fi -elif [[ "$PHP_TYPE" = "php_fpm" ]]; then - cat <> ${APACHE_VHOST_DIR}/${WEBSITE_NAME}.conf 2>> $log_file + if [[ $? -ne 0 ]]; then + failed=true + fi + elif [[ "$PHP_TYPE" = "php_fpm" ]]; then + cat <> ${APACHE_VHOST_DIR}/${WEBSITE_NAME}.conf 2>> $log_file DocumentRoot "${WEBSITE_BASEDIR}/htdocs/" EOF - if $PHP_DEBIAN_INSTALLATION ; then - cat <> ${APACHE_VHOST_DIR}/${WEBSITE_NAME}.conf 2>> $log_file + if $PHP_DEBIAN_INSTALLATION ; then + cat <> ${APACHE_VHOST_DIR}/${WEBSITE_NAME}.conf 2>> $log_file SetHandler "proxy:unix:/var/run/php$(echo $php_major_version | cut -d'.' -f1)-fpm.sock|fcgi://127.0.0.1" EOF - else - cat <> ${APACHE_VHOST_DIR}/${WEBSITE_NAME}.conf 2>> $log_file + else + cat <> ${APACHE_VHOST_DIR}/${WEBSITE_NAME}.conf 2>> $log_file SetHandler "proxy:unix:/tmp/php-${php_latest_ver}-fpm.www.sock|fcgi://127.0.0.1" EOF - fi - cat <> ${APACHE_VHOST_DIR}/${WEBSITE_NAME}.conf 2>> $log_file + fi + cat <> ${APACHE_VHOST_DIR}/${WEBSITE_NAME}.conf 2>> $log_file DirectoryIndex index.php index.html EOF - if [[ $? -ne 0 ]]; then - failed=true + if [[ $? -ne 0 ]]; then + failed=true + fi fi -fi -cat <> ${APACHE_VHOST_DIR}/${WEBSITE_NAME}.conf 2>> $log_file + cat <> ${APACHE_VHOST_DIR}/${WEBSITE_NAME}.conf 2>> $log_file # ========== # - HTTP security Headers @@ -1351,46 +1396,47 @@ cat <> ${APACHE_VHOST_DIR}/${WEBSITE_NAME}.conf 2>> $log_file EOF -if [[ $? -ne 0 ]]; then - _failed=true -fi -if $_failed ; then - echo_failed - error "$(cat $log_file)" -else - echo_ok -fi - - -if $APACHE_DEBIAN_INSTALLATION ; then - ## - add to /etc/apache2/ports.conf - ## - - ## - NameVirtualHost 46.4.73.217:80 - ## - NameVirtualHost [2a01:4f8:140:34c1::4]:80 - ## - Listen 46.4.73.217:80 - ## - Listen [2a01:4f8:140:34c1::4]:80 - ## - - ## - .. - ## - NameVirtualHost 46.4.73.217:443 - ## - NameVirtualHost [2a01:4f8:140:34c1::4]:443 - ## - Listen 46.4.73.217:443 - ## - Listen [2a01:4f8:140:34c1::4]:443 - ## - - ## - .. - #vim /etc/apache2/ports.conf - - - ## - enable site webmail.warenform.de - ## - - echononl "\tEnable ${WEBSITE_NAME}.conf" - a2ensite ${WEBSITE_NAME}.conf > $log_file 2>&1 - if [[ $? -eq 0 ]]; then - echo_ok - else + if [[ $? -ne 0 ]]; then + _failed=true + fi + if $_failed ; then echo_failed error "$(cat $log_file)" + else + echo_ok fi -fi + + + if $APACHE_DEBIAN_INSTALLATION ; then + ## - add to /etc/apache2/ports.conf + ## - + ## - NameVirtualHost 46.4.73.217:80 + ## - NameVirtualHost [2a01:4f8:140:34c1::4]:80 + ## - Listen 46.4.73.217:80 + ## - Listen [2a01:4f8:140:34c1::4]:80 + ## - + ## - .. + ## - NameVirtualHost 46.4.73.217:443 + ## - NameVirtualHost [2a01:4f8:140:34c1::4]:443 + ## - Listen 46.4.73.217:443 + ## - Listen [2a01:4f8:140:34c1::4]:443 + ## - + ## - .. + #vim /etc/apache2/ports.conf + + + ## - enable site webmail.warenform.de + ## - + echononl "\tEnable ${WEBSITE_NAME}.conf" + a2ensite ${WEBSITE_NAME}.conf > $log_file 2>&1 + if [[ $? -eq 0 ]]; then + echo_ok + else + echo_failed + error "$(cat $log_file)" + fi + fi +fi # if $_create_vhost_config echononl "\tCreate 'robots.txt'.." cat < ${WEBSITE_BASEDIR}/htdocs/robots.txt 2> $log_file @@ -1404,17 +1450,23 @@ else error "$(cat $log_file)" fi + echononl "\tRestart Apache Webservice.." -if $APACHE_DEBIAN_INSTALLATION ; then - /etc/init.d/apache2 reload > $log_file 2>&1 +if [[ -n "$APACHE_SERVICE_FILE" ]] || [[ -n "$APACHE_INIT_SCRIPT" ]] ; then + if [[ -n "$APACHE_SERVICE_FILE" ]] ; then + systemctl restart $APACHE_SERVICE_FILE > $log_file 2>&1 + else + $APACHE_INIT_SCRIPT restart > $log_file 2>&1 + fi + if [[ $? -eq 0 ]]; then + echo_ok + else + echo_failed + error "$(cat $log_file)" + fi else - /etc/init.d/apache2 restart > $log_file 2>&1 -fi -if [[ $? -eq 0 ]]; then - echo_ok -else - echo_failed - error "$(cat $log_file)" + echo_skipped + warn "Neither an init-script nor a service file for 'apache2' webservice found!" fi @@ -1726,7 +1778,7 @@ else fi echononl "\tReload/Restart postfix" -if $SYSTEMD_EXISTS ; then +if $systemd_supported ; then systemctl reload postfix > $log_file 2>&1 else /etc/init.d/postfix reload > $log_file 2>&1 @@ -2960,7 +3012,7 @@ fi echo "" echononl "\tReload/Restart postfix" -if $SYSTEMD_EXISTS ; then +if $systemd_supported ; then systemctl reload postfix > $log_file 2>&1 else /etc/init.d/postfix reload > $log_file 2>&1 @@ -2976,7 +3028,7 @@ fi # - if [[ -n "$php_major_versions" ]]; then for _ver in $php_major_versions ; do - echononl " Restart PHP FPM engine v${_ver}.." + echononl "\tRestart PHP FPM engine v${_ver}.." if [[ -f "/etc/init.d/php-${_ver}-fpm" ]]; then /etc/init.d/php-${_ver}-fpm restart > $log_file 2>&1 if [[ $? -eq 0 ]]; then