Replace SSMTP with MSMTP for sendmail

- New parameter "SMTP_PORT"
- Removed parameter "SMTP_AUTH_METHOD"
- Replacing config mapping based on env-variables
This commit is contained in:
Philipp Holzer 2020-07-22 23:17:31 +02:00
parent f18979f1ec
commit 55b4574787
No known key found for this signature in database
GPG Key ID: 9A28B7D4FF5667BD
16 changed files with 191 additions and 170 deletions

View File

@ -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; \

View File

@ -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 ..."

View File

@ -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; \

View File

@ -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 ..."

View File

@ -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; \

View File

@ -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 ..."

View File

@ -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; \

View File

@ -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 ..."

View File

@ -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; \

View File

@ -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 ..."

View File

@ -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; \

View File

@ -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 ..."

View File

@ -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; \

View File

@ -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; \

View File

@ -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

View File

@ -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