From 55b4574787b64e766d9db7174cffd47624f9a019 Mon Sep 17 00:00:00 2001 From: Philipp Date: Wed, 22 Jul 2020 23:17:31 +0200 Subject: [PATCH] Replace SSMTP with MSMTP for sendmail - New parameter "SMTP_PORT" - Removed parameter "SMTP_AUTH_METHOD" - Replacing config mapping based on env-variables --- 2020.07/apache/Dockerfile | 4 +-- 2020.07/apache/entrypoint.sh | 47 +++++++++++++++------------- 2020.07/fpm-alpine/Dockerfile | 4 +-- 2020.07/fpm-alpine/entrypoint.sh | 47 +++++++++++++++------------- 2020.07/fpm/Dockerfile | 4 +-- 2020.07/fpm/entrypoint.sh | 47 +++++++++++++++------------- 2020.09-dev/apache/Dockerfile | 4 +-- 2020.09-dev/apache/entrypoint.sh | 47 +++++++++++++++------------- 2020.09-dev/fpm-alpine/Dockerfile | 4 +-- 2020.09-dev/fpm-alpine/entrypoint.sh | 47 +++++++++++++++------------- 2020.09-dev/fpm/Dockerfile | 4 +-- 2020.09-dev/fpm/entrypoint.sh | 47 +++++++++++++++------------- Dockerfile-alpine.template | 4 +-- Dockerfile-debian.template | 4 +-- README.md | 2 +- docker-entrypoint.sh | 45 +++++++++++++------------- 16 files changed, 191 insertions(+), 170 deletions(-) diff --git a/2020.07/apache/Dockerfile b/2020.07/apache/Dockerfile index 1444749..c5eba22 100644 --- a/2020.07/apache/Dockerfile +++ b/2020.07/apache/Dockerfile @@ -10,7 +10,7 @@ RUN set -ex; \ bzip2 \ git \ # For mail() support - ssmtp \ + msmtp \ # For tini installation gnupg dirmngr \ ; \ @@ -109,7 +109,7 @@ RUN set -ex; \ } > /usr/local/etc/php/conf.d/opcache-recommended.ini; \ \ { \ - echo sendmail_path = "/usr/sbin/sendmail -t -i"; \ + echo sendmail_path = "/usr/bin/msmtp -t"; \ } > /usr/local/etc/php/conf.d/sendmail.ini; \ \ echo 'apc.enable_cli=1' >> /usr/local/etc/php/conf.d/docker-php-ext-apcu.ini; \ diff --git a/2020.07/apache/entrypoint.sh b/2020.07/apache/entrypoint.sh index 40303f9..adf2d05 100755 --- a/2020.07/apache/entrypoint.sh +++ b/2020.07/apache/entrypoint.sh @@ -7,49 +7,54 @@ run_as() { if [ "$(id -u)" -eq 0 ]; then su - www-data -s /bin/sh "$@" else - sh "$@" + sh "$@" fi } # checks if the the first parameter is greater than the second parameter version_greater() { - [ "$(printf '%s\n' "$@" | sort -r -t '-' -k2,2 | sort -t '.' -n -k1,1 -k2,2 -s | head -n 1)" != "$1" ] + [ "$(printf '%s\n' "$@" | sort -r -t '-' -k2,2 | sort -t '.' -n -k1,1 -k2,2 -s | head -n 1)" != "$1" ] } -setup_ssmtp() { +setup_msmtp() { if [ -n "${SMTP_DOMAIN+x}" ] && [ -n "${SMTP+x}" ] && [ "${SMTP}" != "localhost" ]; then SITENAME="${FRIENDICA_SITENAME:-Friendica Social Network}" - echo "Setup SSMTP for '$SITENAME' with '$SMTP' ..." + echo "Setup MSMTP for '$SITENAME' with '$SMTP' ..." - smtp_from=${SMTP_FROM:-no-reply} + smtp_from="${SMTP_FROM:=no-reply}" - # Setup SSMTP + # Setup MSMTP usermod --comment "$(echo "$SITENAME" | tr -dc '[:print:]')" root usermod --comment "$(echo "$SITENAME" | tr -dc '[:print:]')" www-data # add possible mail-senders { - echo "www-data:$smtp_from@$SMTP_DOMAIN:$SMTP" - echo "root::$smtp_from@$SMTP_DOMAIN:$SMTP" - } > /etc/ssmtp/revaliases + echo "www-data: $smtp_from@$SMTP_DOMAIN" + echo "root: $smtp_from@$SMTP_DOMAIN" + } >/etc/aliases - # replace ssmtp.conf settings + # create msmtp settings { - echo "root=:$smtp_from@$SMTP_DOMAIN" - echo "hostname=$SMTP_DOMAIN" - echo "mailhub=$SMTP" - echo "FromLineOverride=YES" - if [ -n "${SMTP_TLS+x}" ]; then echo "UseTLS=$SMTP_TLS"; fi - if [ -n "${SMTP_STARTTLS+x}" ]; then echo "UseSTARTTLS=$SMTP_STARTTLS"; fi - if [ -n "${SMTP_AUTH_USER+x}" ]; then echo "AuthUser=$SMTP_AUTH_USER"; fi - if [ -n "${SMTP_AUTH_PASS+x}" ]; then echo "AuthPass=$SMTP_AUTH_PASS";fi - if [ -n "${SMTP_AUTH_METHOD+x}" ]; then echo "AuthMethod=$SMTP_AUTH_METHOD"; fi - } > /etc/ssmtp/ssmtp.conf + echo "account default" + echo "host $SMTP_DOMAIN" + if [ -n "${SMTP_PORT+x}" ]; then echo "port $SMTP_PORT"; else echo "port 587"; fi + echo "from $smtp_from@$SMTP_DOMAIN" + echo "tls_certcheck off" # No certcheck because of internal docker mail-hostnames + if [ -n "${SMTP_TLS+x}" ]; then echo "tls on"; fi + if [ -n "${SMTP_STARTTLS+x}" ]; then echo "tls_starttls on"; fi + if [ -n "${SMTP_AUTH_USER+x}" ]; then echo "auth on"; fi + if [ -n "${SMTP_AUTH_USER+x}" ]; then echo "user $SMTP_AUTH_USER"; fi + if [ -n "${SMTP_AUTH_PASS+x}" ]; then echo "password $SMTP_AUTH_PASS"; fi + echo "logfile /var/log/msmtp.log" + echo "aliases /etc/aliases" + } >/etc/msmtprc echo "Setup finished" fi } +setup_msmtp + # just check if we execute apache or php-fpm if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; then installed_version="0.0.0.0" @@ -65,8 +70,6 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; then exit 1 fi - setup_ssmtp - # check it just in case the version is greater or if we force the upgrade if version_greater "$image_version" "$installed_version" || [ "${FRIENDICA_UPGRADE:-false}" = "true" ]; then echo "Initializing Friendica $image_version ..." diff --git a/2020.07/fpm-alpine/Dockerfile b/2020.07/fpm-alpine/Dockerfile index 39d2309..4502aaf 100644 --- a/2020.07/fpm-alpine/Dockerfile +++ b/2020.07/fpm-alpine/Dockerfile @@ -7,7 +7,7 @@ RUN set -ex; \ rsync \ git \ # For mail() support - ssmtp \ + msmtp \ shadow \ tini; @@ -84,7 +84,7 @@ RUN set -ex; \ } > /usr/local/etc/php/conf.d/opcache-recommended.ini; \ \ { \ - echo sendmail_path = "/usr/sbin/sendmail -t -i"; \ + echo sendmail_path = "/usr/bin/msmtp -t"; \ } > /usr/local/etc/php/conf.d/sendmail.ini; \ \ echo 'apc.enable_cli=1' >> /usr/local/etc/php/conf.d/docker-php-ext-apcu.ini; \ diff --git a/2020.07/fpm-alpine/entrypoint.sh b/2020.07/fpm-alpine/entrypoint.sh index 40303f9..adf2d05 100755 --- a/2020.07/fpm-alpine/entrypoint.sh +++ b/2020.07/fpm-alpine/entrypoint.sh @@ -7,49 +7,54 @@ run_as() { if [ "$(id -u)" -eq 0 ]; then su - www-data -s /bin/sh "$@" else - sh "$@" + sh "$@" fi } # checks if the the first parameter is greater than the second parameter version_greater() { - [ "$(printf '%s\n' "$@" | sort -r -t '-' -k2,2 | sort -t '.' -n -k1,1 -k2,2 -s | head -n 1)" != "$1" ] + [ "$(printf '%s\n' "$@" | sort -r -t '-' -k2,2 | sort -t '.' -n -k1,1 -k2,2 -s | head -n 1)" != "$1" ] } -setup_ssmtp() { +setup_msmtp() { if [ -n "${SMTP_DOMAIN+x}" ] && [ -n "${SMTP+x}" ] && [ "${SMTP}" != "localhost" ]; then SITENAME="${FRIENDICA_SITENAME:-Friendica Social Network}" - echo "Setup SSMTP for '$SITENAME' with '$SMTP' ..." + echo "Setup MSMTP for '$SITENAME' with '$SMTP' ..." - smtp_from=${SMTP_FROM:-no-reply} + smtp_from="${SMTP_FROM:=no-reply}" - # Setup SSMTP + # Setup MSMTP usermod --comment "$(echo "$SITENAME" | tr -dc '[:print:]')" root usermod --comment "$(echo "$SITENAME" | tr -dc '[:print:]')" www-data # add possible mail-senders { - echo "www-data:$smtp_from@$SMTP_DOMAIN:$SMTP" - echo "root::$smtp_from@$SMTP_DOMAIN:$SMTP" - } > /etc/ssmtp/revaliases + echo "www-data: $smtp_from@$SMTP_DOMAIN" + echo "root: $smtp_from@$SMTP_DOMAIN" + } >/etc/aliases - # replace ssmtp.conf settings + # create msmtp settings { - echo "root=:$smtp_from@$SMTP_DOMAIN" - echo "hostname=$SMTP_DOMAIN" - echo "mailhub=$SMTP" - echo "FromLineOverride=YES" - if [ -n "${SMTP_TLS+x}" ]; then echo "UseTLS=$SMTP_TLS"; fi - if [ -n "${SMTP_STARTTLS+x}" ]; then echo "UseSTARTTLS=$SMTP_STARTTLS"; fi - if [ -n "${SMTP_AUTH_USER+x}" ]; then echo "AuthUser=$SMTP_AUTH_USER"; fi - if [ -n "${SMTP_AUTH_PASS+x}" ]; then echo "AuthPass=$SMTP_AUTH_PASS";fi - if [ -n "${SMTP_AUTH_METHOD+x}" ]; then echo "AuthMethod=$SMTP_AUTH_METHOD"; fi - } > /etc/ssmtp/ssmtp.conf + echo "account default" + echo "host $SMTP_DOMAIN" + if [ -n "${SMTP_PORT+x}" ]; then echo "port $SMTP_PORT"; else echo "port 587"; fi + echo "from $smtp_from@$SMTP_DOMAIN" + echo "tls_certcheck off" # No certcheck because of internal docker mail-hostnames + if [ -n "${SMTP_TLS+x}" ]; then echo "tls on"; fi + if [ -n "${SMTP_STARTTLS+x}" ]; then echo "tls_starttls on"; fi + if [ -n "${SMTP_AUTH_USER+x}" ]; then echo "auth on"; fi + if [ -n "${SMTP_AUTH_USER+x}" ]; then echo "user $SMTP_AUTH_USER"; fi + if [ -n "${SMTP_AUTH_PASS+x}" ]; then echo "password $SMTP_AUTH_PASS"; fi + echo "logfile /var/log/msmtp.log" + echo "aliases /etc/aliases" + } >/etc/msmtprc echo "Setup finished" fi } +setup_msmtp + # just check if we execute apache or php-fpm if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; then installed_version="0.0.0.0" @@ -65,8 +70,6 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; then exit 1 fi - setup_ssmtp - # check it just in case the version is greater or if we force the upgrade if version_greater "$image_version" "$installed_version" || [ "${FRIENDICA_UPGRADE:-false}" = "true" ]; then echo "Initializing Friendica $image_version ..." diff --git a/2020.07/fpm/Dockerfile b/2020.07/fpm/Dockerfile index 352f771..4b4988b 100644 --- a/2020.07/fpm/Dockerfile +++ b/2020.07/fpm/Dockerfile @@ -10,7 +10,7 @@ RUN set -ex; \ bzip2 \ git \ # For mail() support - ssmtp \ + msmtp \ # For tini installation gnupg dirmngr \ ; \ @@ -109,7 +109,7 @@ RUN set -ex; \ } > /usr/local/etc/php/conf.d/opcache-recommended.ini; \ \ { \ - echo sendmail_path = "/usr/sbin/sendmail -t -i"; \ + echo sendmail_path = "/usr/bin/msmtp -t"; \ } > /usr/local/etc/php/conf.d/sendmail.ini; \ \ echo 'apc.enable_cli=1' >> /usr/local/etc/php/conf.d/docker-php-ext-apcu.ini; \ diff --git a/2020.07/fpm/entrypoint.sh b/2020.07/fpm/entrypoint.sh index 40303f9..adf2d05 100755 --- a/2020.07/fpm/entrypoint.sh +++ b/2020.07/fpm/entrypoint.sh @@ -7,49 +7,54 @@ run_as() { if [ "$(id -u)" -eq 0 ]; then su - www-data -s /bin/sh "$@" else - sh "$@" + sh "$@" fi } # checks if the the first parameter is greater than the second parameter version_greater() { - [ "$(printf '%s\n' "$@" | sort -r -t '-' -k2,2 | sort -t '.' -n -k1,1 -k2,2 -s | head -n 1)" != "$1" ] + [ "$(printf '%s\n' "$@" | sort -r -t '-' -k2,2 | sort -t '.' -n -k1,1 -k2,2 -s | head -n 1)" != "$1" ] } -setup_ssmtp() { +setup_msmtp() { if [ -n "${SMTP_DOMAIN+x}" ] && [ -n "${SMTP+x}" ] && [ "${SMTP}" != "localhost" ]; then SITENAME="${FRIENDICA_SITENAME:-Friendica Social Network}" - echo "Setup SSMTP for '$SITENAME' with '$SMTP' ..." + echo "Setup MSMTP for '$SITENAME' with '$SMTP' ..." - smtp_from=${SMTP_FROM:-no-reply} + smtp_from="${SMTP_FROM:=no-reply}" - # Setup SSMTP + # Setup MSMTP usermod --comment "$(echo "$SITENAME" | tr -dc '[:print:]')" root usermod --comment "$(echo "$SITENAME" | tr -dc '[:print:]')" www-data # add possible mail-senders { - echo "www-data:$smtp_from@$SMTP_DOMAIN:$SMTP" - echo "root::$smtp_from@$SMTP_DOMAIN:$SMTP" - } > /etc/ssmtp/revaliases + echo "www-data: $smtp_from@$SMTP_DOMAIN" + echo "root: $smtp_from@$SMTP_DOMAIN" + } >/etc/aliases - # replace ssmtp.conf settings + # create msmtp settings { - echo "root=:$smtp_from@$SMTP_DOMAIN" - echo "hostname=$SMTP_DOMAIN" - echo "mailhub=$SMTP" - echo "FromLineOverride=YES" - if [ -n "${SMTP_TLS+x}" ]; then echo "UseTLS=$SMTP_TLS"; fi - if [ -n "${SMTP_STARTTLS+x}" ]; then echo "UseSTARTTLS=$SMTP_STARTTLS"; fi - if [ -n "${SMTP_AUTH_USER+x}" ]; then echo "AuthUser=$SMTP_AUTH_USER"; fi - if [ -n "${SMTP_AUTH_PASS+x}" ]; then echo "AuthPass=$SMTP_AUTH_PASS";fi - if [ -n "${SMTP_AUTH_METHOD+x}" ]; then echo "AuthMethod=$SMTP_AUTH_METHOD"; fi - } > /etc/ssmtp/ssmtp.conf + echo "account default" + echo "host $SMTP_DOMAIN" + if [ -n "${SMTP_PORT+x}" ]; then echo "port $SMTP_PORT"; else echo "port 587"; fi + echo "from $smtp_from@$SMTP_DOMAIN" + echo "tls_certcheck off" # No certcheck because of internal docker mail-hostnames + if [ -n "${SMTP_TLS+x}" ]; then echo "tls on"; fi + if [ -n "${SMTP_STARTTLS+x}" ]; then echo "tls_starttls on"; fi + if [ -n "${SMTP_AUTH_USER+x}" ]; then echo "auth on"; fi + if [ -n "${SMTP_AUTH_USER+x}" ]; then echo "user $SMTP_AUTH_USER"; fi + if [ -n "${SMTP_AUTH_PASS+x}" ]; then echo "password $SMTP_AUTH_PASS"; fi + echo "logfile /var/log/msmtp.log" + echo "aliases /etc/aliases" + } >/etc/msmtprc echo "Setup finished" fi } +setup_msmtp + # just check if we execute apache or php-fpm if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; then installed_version="0.0.0.0" @@ -65,8 +70,6 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; then exit 1 fi - setup_ssmtp - # check it just in case the version is greater or if we force the upgrade if version_greater "$image_version" "$installed_version" || [ "${FRIENDICA_UPGRADE:-false}" = "true" ]; then echo "Initializing Friendica $image_version ..." diff --git a/2020.09-dev/apache/Dockerfile b/2020.09-dev/apache/Dockerfile index 5213650..ad683cd 100644 --- a/2020.09-dev/apache/Dockerfile +++ b/2020.09-dev/apache/Dockerfile @@ -10,7 +10,7 @@ RUN set -ex; \ bzip2 \ git \ # For mail() support - ssmtp \ + msmtp \ # For tini installation gnupg dirmngr \ ; \ @@ -109,7 +109,7 @@ RUN set -ex; \ } > /usr/local/etc/php/conf.d/opcache-recommended.ini; \ \ { \ - echo sendmail_path = "/usr/sbin/sendmail -t -i"; \ + echo sendmail_path = "/usr/bin/msmtp -t"; \ } > /usr/local/etc/php/conf.d/sendmail.ini; \ \ echo 'apc.enable_cli=1' >> /usr/local/etc/php/conf.d/docker-php-ext-apcu.ini; \ diff --git a/2020.09-dev/apache/entrypoint.sh b/2020.09-dev/apache/entrypoint.sh index 40303f9..adf2d05 100755 --- a/2020.09-dev/apache/entrypoint.sh +++ b/2020.09-dev/apache/entrypoint.sh @@ -7,49 +7,54 @@ run_as() { if [ "$(id -u)" -eq 0 ]; then su - www-data -s /bin/sh "$@" else - sh "$@" + sh "$@" fi } # checks if the the first parameter is greater than the second parameter version_greater() { - [ "$(printf '%s\n' "$@" | sort -r -t '-' -k2,2 | sort -t '.' -n -k1,1 -k2,2 -s | head -n 1)" != "$1" ] + [ "$(printf '%s\n' "$@" | sort -r -t '-' -k2,2 | sort -t '.' -n -k1,1 -k2,2 -s | head -n 1)" != "$1" ] } -setup_ssmtp() { +setup_msmtp() { if [ -n "${SMTP_DOMAIN+x}" ] && [ -n "${SMTP+x}" ] && [ "${SMTP}" != "localhost" ]; then SITENAME="${FRIENDICA_SITENAME:-Friendica Social Network}" - echo "Setup SSMTP for '$SITENAME' with '$SMTP' ..." + echo "Setup MSMTP for '$SITENAME' with '$SMTP' ..." - smtp_from=${SMTP_FROM:-no-reply} + smtp_from="${SMTP_FROM:=no-reply}" - # Setup SSMTP + # Setup MSMTP usermod --comment "$(echo "$SITENAME" | tr -dc '[:print:]')" root usermod --comment "$(echo "$SITENAME" | tr -dc '[:print:]')" www-data # add possible mail-senders { - echo "www-data:$smtp_from@$SMTP_DOMAIN:$SMTP" - echo "root::$smtp_from@$SMTP_DOMAIN:$SMTP" - } > /etc/ssmtp/revaliases + echo "www-data: $smtp_from@$SMTP_DOMAIN" + echo "root: $smtp_from@$SMTP_DOMAIN" + } >/etc/aliases - # replace ssmtp.conf settings + # create msmtp settings { - echo "root=:$smtp_from@$SMTP_DOMAIN" - echo "hostname=$SMTP_DOMAIN" - echo "mailhub=$SMTP" - echo "FromLineOverride=YES" - if [ -n "${SMTP_TLS+x}" ]; then echo "UseTLS=$SMTP_TLS"; fi - if [ -n "${SMTP_STARTTLS+x}" ]; then echo "UseSTARTTLS=$SMTP_STARTTLS"; fi - if [ -n "${SMTP_AUTH_USER+x}" ]; then echo "AuthUser=$SMTP_AUTH_USER"; fi - if [ -n "${SMTP_AUTH_PASS+x}" ]; then echo "AuthPass=$SMTP_AUTH_PASS";fi - if [ -n "${SMTP_AUTH_METHOD+x}" ]; then echo "AuthMethod=$SMTP_AUTH_METHOD"; fi - } > /etc/ssmtp/ssmtp.conf + echo "account default" + echo "host $SMTP_DOMAIN" + if [ -n "${SMTP_PORT+x}" ]; then echo "port $SMTP_PORT"; else echo "port 587"; fi + echo "from $smtp_from@$SMTP_DOMAIN" + echo "tls_certcheck off" # No certcheck because of internal docker mail-hostnames + if [ -n "${SMTP_TLS+x}" ]; then echo "tls on"; fi + if [ -n "${SMTP_STARTTLS+x}" ]; then echo "tls_starttls on"; fi + if [ -n "${SMTP_AUTH_USER+x}" ]; then echo "auth on"; fi + if [ -n "${SMTP_AUTH_USER+x}" ]; then echo "user $SMTP_AUTH_USER"; fi + if [ -n "${SMTP_AUTH_PASS+x}" ]; then echo "password $SMTP_AUTH_PASS"; fi + echo "logfile /var/log/msmtp.log" + echo "aliases /etc/aliases" + } >/etc/msmtprc echo "Setup finished" fi } +setup_msmtp + # just check if we execute apache or php-fpm if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; then installed_version="0.0.0.0" @@ -65,8 +70,6 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; then exit 1 fi - setup_ssmtp - # check it just in case the version is greater or if we force the upgrade if version_greater "$image_version" "$installed_version" || [ "${FRIENDICA_UPGRADE:-false}" = "true" ]; then echo "Initializing Friendica $image_version ..." diff --git a/2020.09-dev/fpm-alpine/Dockerfile b/2020.09-dev/fpm-alpine/Dockerfile index 14d2d90..0d82522 100644 --- a/2020.09-dev/fpm-alpine/Dockerfile +++ b/2020.09-dev/fpm-alpine/Dockerfile @@ -7,7 +7,7 @@ RUN set -ex; \ rsync \ git \ # For mail() support - ssmtp \ + msmtp \ shadow \ tini; @@ -84,7 +84,7 @@ RUN set -ex; \ } > /usr/local/etc/php/conf.d/opcache-recommended.ini; \ \ { \ - echo sendmail_path = "/usr/sbin/sendmail -t -i"; \ + echo sendmail_path = "/usr/bin/msmtp -t"; \ } > /usr/local/etc/php/conf.d/sendmail.ini; \ \ echo 'apc.enable_cli=1' >> /usr/local/etc/php/conf.d/docker-php-ext-apcu.ini; \ diff --git a/2020.09-dev/fpm-alpine/entrypoint.sh b/2020.09-dev/fpm-alpine/entrypoint.sh index 40303f9..adf2d05 100755 --- a/2020.09-dev/fpm-alpine/entrypoint.sh +++ b/2020.09-dev/fpm-alpine/entrypoint.sh @@ -7,49 +7,54 @@ run_as() { if [ "$(id -u)" -eq 0 ]; then su - www-data -s /bin/sh "$@" else - sh "$@" + sh "$@" fi } # checks if the the first parameter is greater than the second parameter version_greater() { - [ "$(printf '%s\n' "$@" | sort -r -t '-' -k2,2 | sort -t '.' -n -k1,1 -k2,2 -s | head -n 1)" != "$1" ] + [ "$(printf '%s\n' "$@" | sort -r -t '-' -k2,2 | sort -t '.' -n -k1,1 -k2,2 -s | head -n 1)" != "$1" ] } -setup_ssmtp() { +setup_msmtp() { if [ -n "${SMTP_DOMAIN+x}" ] && [ -n "${SMTP+x}" ] && [ "${SMTP}" != "localhost" ]; then SITENAME="${FRIENDICA_SITENAME:-Friendica Social Network}" - echo "Setup SSMTP for '$SITENAME' with '$SMTP' ..." + echo "Setup MSMTP for '$SITENAME' with '$SMTP' ..." - smtp_from=${SMTP_FROM:-no-reply} + smtp_from="${SMTP_FROM:=no-reply}" - # Setup SSMTP + # Setup MSMTP usermod --comment "$(echo "$SITENAME" | tr -dc '[:print:]')" root usermod --comment "$(echo "$SITENAME" | tr -dc '[:print:]')" www-data # add possible mail-senders { - echo "www-data:$smtp_from@$SMTP_DOMAIN:$SMTP" - echo "root::$smtp_from@$SMTP_DOMAIN:$SMTP" - } > /etc/ssmtp/revaliases + echo "www-data: $smtp_from@$SMTP_DOMAIN" + echo "root: $smtp_from@$SMTP_DOMAIN" + } >/etc/aliases - # replace ssmtp.conf settings + # create msmtp settings { - echo "root=:$smtp_from@$SMTP_DOMAIN" - echo "hostname=$SMTP_DOMAIN" - echo "mailhub=$SMTP" - echo "FromLineOverride=YES" - if [ -n "${SMTP_TLS+x}" ]; then echo "UseTLS=$SMTP_TLS"; fi - if [ -n "${SMTP_STARTTLS+x}" ]; then echo "UseSTARTTLS=$SMTP_STARTTLS"; fi - if [ -n "${SMTP_AUTH_USER+x}" ]; then echo "AuthUser=$SMTP_AUTH_USER"; fi - if [ -n "${SMTP_AUTH_PASS+x}" ]; then echo "AuthPass=$SMTP_AUTH_PASS";fi - if [ -n "${SMTP_AUTH_METHOD+x}" ]; then echo "AuthMethod=$SMTP_AUTH_METHOD"; fi - } > /etc/ssmtp/ssmtp.conf + echo "account default" + echo "host $SMTP_DOMAIN" + if [ -n "${SMTP_PORT+x}" ]; then echo "port $SMTP_PORT"; else echo "port 587"; fi + echo "from $smtp_from@$SMTP_DOMAIN" + echo "tls_certcheck off" # No certcheck because of internal docker mail-hostnames + if [ -n "${SMTP_TLS+x}" ]; then echo "tls on"; fi + if [ -n "${SMTP_STARTTLS+x}" ]; then echo "tls_starttls on"; fi + if [ -n "${SMTP_AUTH_USER+x}" ]; then echo "auth on"; fi + if [ -n "${SMTP_AUTH_USER+x}" ]; then echo "user $SMTP_AUTH_USER"; fi + if [ -n "${SMTP_AUTH_PASS+x}" ]; then echo "password $SMTP_AUTH_PASS"; fi + echo "logfile /var/log/msmtp.log" + echo "aliases /etc/aliases" + } >/etc/msmtprc echo "Setup finished" fi } +setup_msmtp + # just check if we execute apache or php-fpm if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; then installed_version="0.0.0.0" @@ -65,8 +70,6 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; then exit 1 fi - setup_ssmtp - # check it just in case the version is greater or if we force the upgrade if version_greater "$image_version" "$installed_version" || [ "${FRIENDICA_UPGRADE:-false}" = "true" ]; then echo "Initializing Friendica $image_version ..." diff --git a/2020.09-dev/fpm/Dockerfile b/2020.09-dev/fpm/Dockerfile index 0434081..10d8f46 100644 --- a/2020.09-dev/fpm/Dockerfile +++ b/2020.09-dev/fpm/Dockerfile @@ -10,7 +10,7 @@ RUN set -ex; \ bzip2 \ git \ # For mail() support - ssmtp \ + msmtp \ # For tini installation gnupg dirmngr \ ; \ @@ -109,7 +109,7 @@ RUN set -ex; \ } > /usr/local/etc/php/conf.d/opcache-recommended.ini; \ \ { \ - echo sendmail_path = "/usr/sbin/sendmail -t -i"; \ + echo sendmail_path = "/usr/bin/msmtp -t"; \ } > /usr/local/etc/php/conf.d/sendmail.ini; \ \ echo 'apc.enable_cli=1' >> /usr/local/etc/php/conf.d/docker-php-ext-apcu.ini; \ diff --git a/2020.09-dev/fpm/entrypoint.sh b/2020.09-dev/fpm/entrypoint.sh index 40303f9..adf2d05 100755 --- a/2020.09-dev/fpm/entrypoint.sh +++ b/2020.09-dev/fpm/entrypoint.sh @@ -7,49 +7,54 @@ run_as() { if [ "$(id -u)" -eq 0 ]; then su - www-data -s /bin/sh "$@" else - sh "$@" + sh "$@" fi } # checks if the the first parameter is greater than the second parameter version_greater() { - [ "$(printf '%s\n' "$@" | sort -r -t '-' -k2,2 | sort -t '.' -n -k1,1 -k2,2 -s | head -n 1)" != "$1" ] + [ "$(printf '%s\n' "$@" | sort -r -t '-' -k2,2 | sort -t '.' -n -k1,1 -k2,2 -s | head -n 1)" != "$1" ] } -setup_ssmtp() { +setup_msmtp() { if [ -n "${SMTP_DOMAIN+x}" ] && [ -n "${SMTP+x}" ] && [ "${SMTP}" != "localhost" ]; then SITENAME="${FRIENDICA_SITENAME:-Friendica Social Network}" - echo "Setup SSMTP for '$SITENAME' with '$SMTP' ..." + echo "Setup MSMTP for '$SITENAME' with '$SMTP' ..." - smtp_from=${SMTP_FROM:-no-reply} + smtp_from="${SMTP_FROM:=no-reply}" - # Setup SSMTP + # Setup MSMTP usermod --comment "$(echo "$SITENAME" | tr -dc '[:print:]')" root usermod --comment "$(echo "$SITENAME" | tr -dc '[:print:]')" www-data # add possible mail-senders { - echo "www-data:$smtp_from@$SMTP_DOMAIN:$SMTP" - echo "root::$smtp_from@$SMTP_DOMAIN:$SMTP" - } > /etc/ssmtp/revaliases + echo "www-data: $smtp_from@$SMTP_DOMAIN" + echo "root: $smtp_from@$SMTP_DOMAIN" + } >/etc/aliases - # replace ssmtp.conf settings + # create msmtp settings { - echo "root=:$smtp_from@$SMTP_DOMAIN" - echo "hostname=$SMTP_DOMAIN" - echo "mailhub=$SMTP" - echo "FromLineOverride=YES" - if [ -n "${SMTP_TLS+x}" ]; then echo "UseTLS=$SMTP_TLS"; fi - if [ -n "${SMTP_STARTTLS+x}" ]; then echo "UseSTARTTLS=$SMTP_STARTTLS"; fi - if [ -n "${SMTP_AUTH_USER+x}" ]; then echo "AuthUser=$SMTP_AUTH_USER"; fi - if [ -n "${SMTP_AUTH_PASS+x}" ]; then echo "AuthPass=$SMTP_AUTH_PASS";fi - if [ -n "${SMTP_AUTH_METHOD+x}" ]; then echo "AuthMethod=$SMTP_AUTH_METHOD"; fi - } > /etc/ssmtp/ssmtp.conf + echo "account default" + echo "host $SMTP_DOMAIN" + if [ -n "${SMTP_PORT+x}" ]; then echo "port $SMTP_PORT"; else echo "port 587"; fi + echo "from $smtp_from@$SMTP_DOMAIN" + echo "tls_certcheck off" # No certcheck because of internal docker mail-hostnames + if [ -n "${SMTP_TLS+x}" ]; then echo "tls on"; fi + if [ -n "${SMTP_STARTTLS+x}" ]; then echo "tls_starttls on"; fi + if [ -n "${SMTP_AUTH_USER+x}" ]; then echo "auth on"; fi + if [ -n "${SMTP_AUTH_USER+x}" ]; then echo "user $SMTP_AUTH_USER"; fi + if [ -n "${SMTP_AUTH_PASS+x}" ]; then echo "password $SMTP_AUTH_PASS"; fi + echo "logfile /var/log/msmtp.log" + echo "aliases /etc/aliases" + } >/etc/msmtprc echo "Setup finished" fi } +setup_msmtp + # just check if we execute apache or php-fpm if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; then installed_version="0.0.0.0" @@ -65,8 +70,6 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; then exit 1 fi - setup_ssmtp - # check it just in case the version is greater or if we force the upgrade if version_greater "$image_version" "$installed_version" || [ "${FRIENDICA_UPGRADE:-false}" = "true" ]; then echo "Initializing Friendica $image_version ..." diff --git a/Dockerfile-alpine.template b/Dockerfile-alpine.template index b507c49..b06696e 100644 --- a/Dockerfile-alpine.template +++ b/Dockerfile-alpine.template @@ -6,7 +6,7 @@ RUN set -ex; \ rsync \ git \ # For mail() support - ssmtp \ + msmtp \ shadow \ tini; @@ -83,7 +83,7 @@ RUN set -ex; \ } > /usr/local/etc/php/conf.d/opcache-recommended.ini; \ \ { \ - echo sendmail_path = "/usr/sbin/sendmail -t -i"; \ + echo sendmail_path = "/usr/bin/msmtp -t"; \ } > /usr/local/etc/php/conf.d/sendmail.ini; \ \ echo 'apc.enable_cli=1' >> /usr/local/etc/php/conf.d/docker-php-ext-apcu.ini; \ diff --git a/Dockerfile-debian.template b/Dockerfile-debian.template index e847727..22ba673 100644 --- a/Dockerfile-debian.template +++ b/Dockerfile-debian.template @@ -9,7 +9,7 @@ RUN set -ex; \ bzip2 \ git \ # For mail() support - ssmtp \ + msmtp \ # For tini installation gnupg dirmngr \ ; \ @@ -108,7 +108,7 @@ RUN set -ex; \ } > /usr/local/etc/php/conf.d/opcache-recommended.ini; \ \ { \ - echo sendmail_path = "/usr/sbin/sendmail -t -i"; \ + echo sendmail_path = "/usr/bin/msmtp -t"; \ } > /usr/local/etc/php/conf.d/sendmail.ini; \ \ echo 'apc.enable_cli=1' >> /usr/local/etc/php/conf.d/docker-php-ext-apcu.ini; \ diff --git a/README.md b/README.md index 39e27b2..29a93b2 100644 --- a/README.md +++ b/README.md @@ -107,13 +107,13 @@ A valid SMTP-MTA would be, for example, `mx.example.org`. The following environment variables are possible for the SMTP examples. - `SMTP` Address of the SMTP Mail-Gateway. (**required**) +- `SMTP_PORT` Port of the SMTP Mail-Gateway. (Default: 587) - `SMTP_DOMAIN` The sender domain. (**required** - e.g. `friendica.local`) - `SMTP_FROM` Sender user-part of the address. (Default: `no-reply` - e.g. no-reply@friendica.local) - `SMTP_TLS` Use TLS for connecting the SMTP Mail-Gateway. (Default: empty) - `SMTP_STARTTLS` Use STARTTLS for connecting the SMTP Mail-Gateway. (Default: empty) - `SMTP_AUTH_USER` Username for the SMTP Mail-Gateway. (Default: empty) - `SMTP_AUTH_PASS` Password for the SMTP Mail-Gateway. (Default: empty) -- `SMTP_AUTH_METHOD` Authentication method for the SMTP Mail-Gateway. (Default: empty/plain text) ## Database settings diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 8d5931d..adf2d05 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -7,50 +7,53 @@ run_as() { if [ "$(id -u)" -eq 0 ]; then su - www-data -s /bin/sh "$@" else - sh "$@" + sh "$@" fi } # checks if the the first parameter is greater than the second parameter version_greater() { - [ "$(printf '%s\n' "$@" | sort -r -t '-' -k2,2 | sort -t '.' -n -k1,1 -k2,2 -s | head -n 1)" != "$1" ] + [ "$(printf '%s\n' "$@" | sort -r -t '-' -k2,2 | sort -t '.' -n -k1,1 -k2,2 -s | head -n 1)" != "$1" ] } -setup_ssmtp() { +setup_msmtp() { if [ -n "${SMTP_DOMAIN+x}" ] && [ -n "${SMTP+x}" ] && [ "${SMTP}" != "localhost" ]; then SITENAME="${FRIENDICA_SITENAME:-Friendica Social Network}" - echo "Setup SSMTP for '$SITENAME' with '$SMTP' ..." + echo "Setup MSMTP for '$SITENAME' with '$SMTP' ..." - smtp_from=${SMTP_FROM:-no-reply} + smtp_from="${SMTP_FROM:=no-reply}" - # Setup SSMTP + # Setup MSMTP usermod --comment "$(echo "$SITENAME" | tr -dc '[:print:]')" root usermod --comment "$(echo "$SITENAME" | tr -dc '[:print:]')" www-data # add possible mail-senders { - echo "www-data:$smtp_from@$SMTP_DOMAIN:$SMTP" - echo "root::$smtp_from@$SMTP_DOMAIN:$SMTP" - } > /etc/ssmtp/revaliases + echo "www-data: $smtp_from@$SMTP_DOMAIN" + echo "root: $smtp_from@$SMTP_DOMAIN" + } >/etc/aliases - # replace ssmtp.conf settings + # create msmtp settings { - echo "root=:$smtp_from@$SMTP_DOMAIN" - echo "hostname=$SMTP_DOMAIN" - echo "mailhub=$SMTP" - echo "FromLineOverride=YES" - if [ -n "${SMTP_TLS+x}" ]; then echo "UseTLS=$SMTP_TLS"; fi - if [ -n "${SMTP_STARTTLS+x}" ]; then echo "UseSTARTTLS=$SMTP_STARTTLS"; fi - if [ -n "${SMTP_AUTH_USER+x}" ]; then echo "AuthUser=$SMTP_AUTH_USER"; fi - if [ -n "${SMTP_AUTH_PASS+x}" ]; then echo "AuthPass=$SMTP_AUTH_PASS";fi - if [ -n "${SMTP_AUTH_METHOD+x}" ]; then echo "AuthMethod=$SMTP_AUTH_METHOD"; fi - } > /etc/ssmtp/ssmtp.conf + echo "account default" + echo "host $SMTP_DOMAIN" + if [ -n "${SMTP_PORT+x}" ]; then echo "port $SMTP_PORT"; else echo "port 587"; fi + echo "from $smtp_from@$SMTP_DOMAIN" + echo "tls_certcheck off" # No certcheck because of internal docker mail-hostnames + if [ -n "${SMTP_TLS+x}" ]; then echo "tls on"; fi + if [ -n "${SMTP_STARTTLS+x}" ]; then echo "tls_starttls on"; fi + if [ -n "${SMTP_AUTH_USER+x}" ]; then echo "auth on"; fi + if [ -n "${SMTP_AUTH_USER+x}" ]; then echo "user $SMTP_AUTH_USER"; fi + if [ -n "${SMTP_AUTH_PASS+x}" ]; then echo "password $SMTP_AUTH_PASS"; fi + echo "logfile /var/log/msmtp.log" + echo "aliases /etc/aliases" + } >/etc/msmtprc echo "Setup finished" fi } -setup_ssmtp +setup_msmtp # just check if we execute apache or php-fpm if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; then