Bugfixings SMTP /

- changed sendmail to ssmtp support
- deleted smtp-examples (not necessary anymore)
- added vendor libraries in stable-docker images ("full" package)
- changed stack.yml to new SMTP behavior
This commit is contained in:
Philipp Holzer 2018-06-06 20:37:02 +02:00
parent 4043b7901d
commit fec33c98be
No known key found for this signature in database
GPG Key ID: 58160D7D6AF942B6
39 changed files with 442 additions and 330 deletions

View File

@ -1,18 +1,23 @@
#!/bin/sh
set -eu
FRIENDICA_VERSION=${FRIENDICA_VERSION:-develop}
FRIENDICA_ADDONS=${FRIENDICA_ADDONS:-develop}
AUTOINSTALL=${AUTOINSTALL:-false}
SMTP=${SMTP:-localhost}
SMTP_FROM=${SMTP_FROM:-no-reply}
SOURCEDIR=/usr/src
WORKDIR=/var/www/html
SOURCEDIR=${SOURCEDIR:-/usr/src}
WORKDIR=${WORKDIR:-/var/www/html}
SMTP_TLS=${SMTP_TLS:-}
SMTP_STARTTLS=${SMTP_STARTTLS:-}
SMTP_AUTH_USER=${SMTP_AUTH_USER:-}
SMTP_AUTH_PASS=${SMTP_AUTH_PASS:-}
SMTP_AUTH_METHOD=${SMTP_AUTH_METHOD:-}
VERBOSE=1
for arg; do
case "$arg" in
-q|--quit)
if [ "$VERBOSE" -eq "2" ]; then
if [ "$VERBOSE" -eq 2 ]; then
echo 'You cannot use verbose and quiet at the same time'
exit 1
fi
@ -20,7 +25,7 @@ for arg; do
break
;;
-v|--verbose)
if [ "$VERBOSE" -eq "0" ]; then
if [ "$VERBOSE" -eq 0 ]; then
echo 'You cannot use verbose and quiet at the same time'
exit 1
fi
@ -32,7 +37,7 @@ done
# run an command with the www-data user
run_as() {
if [ "$(id -u)" = 0 ]; then
if [ "$(id -u)" -eq 0 ]; then
su - www-data -s /bin/sh -c "$1"
else
sh -c "$1"
@ -42,7 +47,7 @@ run_as() {
# log event
log() {
currVerb=1
if [ $# -eq 2 ]; then
if [ "$#" -eq 2 ]; then
currVerb=$2
fi
if [ "$VERBOSE" -ge "$currVerb" ]; then
@ -105,6 +110,9 @@ console() {
composer() {
if [ -f $WORKDIR/bin/composer.phar ]; then
run_as "cd $WORKDIR;$WORKDIR/bin/composer.phar $@ -d $WORKDIR"
elif [ -f $SOURCEDIR/friendica/bin/composer.phar ]; then
cd $SOURCEDIR/friendica
$SOURCEDIR/friendica/bin/composer.phar "$@" -d $SOURCEDIR/friendica
fi
}
@ -133,7 +141,7 @@ copy_sources() {
fi
if version_greater "$image_version" "$installed_version"; then
if [ "$(id -u)" = 0 ]; then
if [ "$(id -u)" -eq 0 ]; then
rsync_options="-rlDog --chown=www-data:root"
else
rsync_options="-rlD"
@ -163,7 +171,7 @@ install() {
if [ ! -f ${WORKDIR}/.htconfig.php ] &&
[ -f ${SOURCEDIR}/config/htconfig.php ] &&
"$AUTOINSTALL" == "true"; then
[ "$AUTOINSTALL" = "true" ]; then
run_as "cp ${SOURCEDIR}/config/htconfig.php ${WORKDIR}/.htconfig.php"
console autoinstall -f .htconfig.php
# TODO Workaround because of a strange permission issue
@ -186,21 +194,37 @@ update() {
console dbstructure update
}
sendmail() {
if [ ! -f /etc/init.d/sendmail ]; then
# If sendmail isn't installed, exit this method
configmail() {
if [ "$SMTP" = "localhost" ]; then
# SMTP is a required setting
# do nothing if it is "localhost" (= not changed)
return
fi
line=$(head -n 1 /etc/hosts)
line2=$(echo $line | awk '{print $2}')
echo "$line $line2.localdomain" >> /etc/hosts
sed -i "s/:root:/:${SITENAME}:/g" /etc/passwd
sed -i "s/Linux\ User/${SITENAME}/g" /etc/passwd
log 'Starting sendmail for Mail-Support'
nohup /etc/init.d/sendmail start > /dev/null 2>&1 &
# add possible mail-senders
echo "www-data:$SMTP_FROM@$HOSTNAME:$SMTP" >> /etc/ssmtp/revaliases
echo "root:$SMTP_FROM@$HOSTNAME:$SMTP" >> /etc/ssmtp/revaliases
# replace ssmtp.conf settings
cat << EOF > /etc/ssmtp/ssmtp.conf
# /etc/ssmtp/ssmtp.conf
root=$SMTP_FROM@$HOSTNAME
hostname=$HOSTNAME
mailhub=$SMTP
FromLineOverride=YES
EOF
[ -z "$SMTP_TLS" ] || echo "UseTLS=$SMTP_TLS" >> /etc/ssmtp/ssmtp.conf
[ -z "$SMTP_STARTTLS" ] || echo "UseSTARTTLS=$SMTP_STARTTLS" >> /etc/ssmtp/ssmtp.conf
[ -z "$SMTP_AUTH_USER" ] || echo "AuthUser=$SMTP_AUTH_USER" >> /etc/ssmtp/ssmtp.conf
[ -z "$SMTP_AUTH_PASS" ] || echo "AuthPass=$SMTP_AUTH_PASS" >> /etc/ssmtp/ssmtp.conf
[ -z "$SMTP_AUTH_METHOD" ] || echo "AuthMethod=$SMTP_AUTH_METHOD" >> /etc/ssmtp/ssmtp.conf
}
if [ $# -eq 0 ]; then
if [ "$#" -eq 0 ]; then
friendica_help
exit 0
fi
@ -210,6 +234,6 @@ case "$1" in
update) shift; update $@ ;;
console) shift; console $@ ;;
composer) shift; composer $@ ;;
sendmail) shift; sendmail $@ ;;
configmail) shift; configmail $@ ;;
*) friendica_help ;;
esac

View File

@ -106,3 +106,8 @@ $a->config['system']['allowed_link_protocols'] = ['ftp', 'ftps', 'mailto', 'cid'
// Authentication cookie lifetime, in days
$a->config['system']['auth_cookie_lifetime'] = 7;
if (!empty(getenv('VALIDATION'))) {
$a->config['system']['disable_url_validation'] = strtolower(getenv('VALIDATION'));
$a->config['system']['disable_email_validation'] = strtolower(getenv('VALIDATION'));
}

View File

@ -16,7 +16,6 @@ The Dockerfiles use the default images as base image and build on top of it.
Examples | Descriptions
-------- | -------
[cron](https://github.com/friendica/docker/tree/master/.examples/dockerfiles/cron) | uses supervisor to run the cron job inside the container (so no extra container is needed).
[smtp](https://github.com/friendica/docker/tree/master/.examples/dockerfiles/smtp) | adds dependencies required to use SMTP as mail relay/smarthost
## docker-compose

View File

@ -9,6 +9,6 @@ RUN set -ex; \
rm -rf /var/lib/apt/lists/*; \
mkdir /var/log/supervisord /var/run/supervisord
COPY ./supervisord.conf /etc/supervisor/supervisord.conf
COPY supervisord.conf /etc/supervisor/supervisord.conf
CMD ["/usr/bin/supervisord"]

View File

@ -9,6 +9,6 @@ RUN set -ex; \
rm -rf /var/lib/apt/lists/*; \
mkdir /var/log/supervisord /var/run/supervisord
COPY ./supervisord.conf /etc/supervisor/supervisord.conf
COPY supervisord.conf /etc/supervisor/supervisord.conf
CMD ["/usr/bin/supervisord"]

View File

@ -1,24 +0,0 @@
# SMTP section
In this subfolder are examples how to add SMTP support to the Friendica docker images.
Each directory represents the image-version of the Dockerfile.
It uses the stable-branches of the Friendica Dockerfiles out-of-the-box.
So if you want to use the develop-branch, you have to add the prefix `develop-` at the `FROM`clause (e.g. `FROM friendica:apache` -> `FROM friendica:develop-apache`)
- `SMTP_HOST` The host/IP of the SMTP-MTA
## Custom SMTP Settings
Currently, only `apache` and `fpm` supports custom SMTP settings.
You **have** to set `SMTP_TYPE` to `custom` for other settings than `SMTP_HOST` (default: `simple`)
### SMTP Authentication
- `SMTP_USERNAME` Username for the SMTP-MTA user to authenticate.
- `SMTP_PASSWORD` Password for the SMTP-MTA user to authenticate.
### Additional settings
- `SMTP_PORT` The port of the SMTP-MTA (default: `25`)
- `SMTP_AUTH` The authentication string for the SMTP-MTA (default: `A p`)
- `SMTP_TRUST_AUTH_MECH` The trusted authentication mechanism for the SMTP-MTA (default: `EXTERNAL DIGEST-MD5 CRAM-MD5 LOGIN PLAIN`)
- `SMTP_AUTH_MECH` The authentication mechanism for the SMTP-MTA (default: `EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN`)

View File

@ -1,45 +0,0 @@
#!/bin/sh
set -eu
IFS=\n
SMTP_TYPE=${SMTP_TYPE:-simple}
# config options
SMTP_HOST=${SMTP_HOST:-'localhost'}
SMTP_PORT=${SMTP_PORT:-'25'}
SMTP_AUTH=${SMTP_AUTH:-'A p'}
SMTP_TRUST_AUTH_MECH=${SMTP_TRUST_AUTH_MECH:-'EXTERNAL DIGEST-MD5 CRAM-MD5 LOGIN PLAIN'}
SMTP_AUTH_MECH=${SMTP_AUTH_MECH:-'EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN'}
SMTP_USERNAME=${SMTP_USERNAME:-''}
SMTP_PASSWORD=${SMTP_PASSWORD:-''}
smtp_simple() {
sed -i '/MAILER_DEFINITIONS/i define(`SMART_HOST'\'',`'$SMTP_HOST''\'')dnl/' /etc/mail/sendmail.mc
}
smtp_custom() {
cd /etc/mail
mkdir -m 700 authinfo
cd authinfo/
echo 'Authinfo: "U:www-data" "I:'$SMTP_USERNAME'" "P:'$SMTP_PASSWORD'"' > auth_file
makemap hash auth < auth_file
sed -i '/MAILER_DEFINITIONS/i \
define(`SMART_HOST'\'',`'$SMTP_HOST''\'')dnl \
define(`RELAY_MAILER_ARGS'\'', `TCP '$SMTP_HOST' '$SMTP_PORT''\'')dnl \
define(`ESMTP_MAILER_ARGS'\'', `TCP '$SMTP_HOST' '$SMTP_PORT''\'')dnl \
define(`confAUTH_OPTIONS'\'', `'$SMTP_AUTH''\'')dnl \
TRUST_AUTH_MECH(`'$SMTP_TRUST_AUTH_MECH''\'')dnl \
define(`confAUTH_MECHANISMS'\'', `'$SMTP_AUTH_MECH''\'')dnl \
FEATURE(`authinfo'\'',`hash -o /etc/mail/authinfo/auth.db'\'')dnl' /etc/mail/sendmail.mc
}
case $SMTP_TYPE in
simple) smtp_simple ;;
custom) smtp_custom ;;
*)
echo "Unknown SMTP-Type '$SMTP_TYPE'"
exit 1
esac

View File

@ -1,18 +0,0 @@
FROM friendica/server:fpm-alpine
# at least you HAVE to set one SMTP_HOST (normally something like mail.example.org)
ENV SMTP_HOST mail
RUN set -ex; \
\
apk add --no-cache \
ssmtp \
; \
# disable the current mailhub
sed -i "s|mailhub=|#mailhub= |g" /etc/ssmtp/ssmtp.conf; \
# enable the new mailhub
echo "mailhub=${SMTP_HOST:-localhost}" >> /etc/ssmtp/ssmtp.conf;
# simple = using an smtp without any credentials (mostly in local networks)
# custom = you need to set host, port, auth_options, authinfo (e.g. for GMX support)
ENV SMTP_TYPE simple

View File

@ -1,45 +0,0 @@
#!/bin/sh
set -eu
IFS=\n
SMTP_TYPE=${SMTP_TYPE:-simple}
# config options
SMTP_HOST=${SMTP_HOST:-'localhost'}
SMTP_PORT=${SMTP_PORT:-'25'}
SMTP_AUTH=${SMTP_AUTH:-'A p'}
SMTP_TRUST_AUTH_MECH=${SMTP_TRUST_AUTH_MECH:-'EXTERNAL DIGEST-MD5 CRAM-MD5 LOGIN PLAIN'}
SMTP_AUTH_MECH=${SMTP_AUTH_MECH:-'EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN'}
SMTP_USERNAME=${SMTP_USERNAME:-''}
SMTP_PASSWORD=${SMTP_PASSWORD:-''}
smtp_simple() {
sed -i '/MAILER_DEFINITIONS/i define(`SMART_HOST'\'',`'$SMTP_HOST''\'')dnl/' /etc/mail/sendmail.mc
}
smtp_custom() {
cd /etc/mail
mkdir -m 700 authinfo
cd authinfo/
echo 'Authinfo: "U:www-data" "I:'$SMTP_USERNAME'" "P:'$SMTP_PASSWORD'"' > auth_file
makemap hash auth < auth_file
sed -i '/MAILER_DEFINITIONS/i \
define(`SMART_HOST'\'',`'$SMTP_HOST''\'')dnl \
define(`RELAY_MAILER_ARGS'\'', `TCP '$SMTP_HOST' '$SMTP_PORT''\'')dnl \
define(`ESMTP_MAILER_ARGS'\'', `TCP '$SMTP_HOST' '$SMTP_PORT''\'')dnl \
define(`confAUTH_OPTIONS'\'', `'$SMTP_AUTH''\'')dnl \
TRUST_AUTH_MECH(`'$SMTP_TRUST_AUTH_MECH''\'')dnl \
define(`confAUTH_MECHANISMS'\'', `'$SMTP_AUTH_MECH''\'')dnl \
FEATURE(`authinfo'\'',`hash -o /etc/mail/authinfo/auth.db'\'')dnl' /etc/mail/sendmail.mc
}
case $SMTP_TYPE in
simple) smtp_simple ;;
custom) smtp_custom ;;
*)
echo "Unknown SMTP-Type '$SMTP_TYPE'"
exit 1
esac

View File

@ -11,7 +11,7 @@ RUN set -ex; \
bzip2 \
git \
# For mail() support
sendmail \
ssmtp \
; \
rm -rf /var/lib/apt/lists/*;
@ -93,10 +93,19 @@ RUN {\
} > /usr/local/etc/php/conf.d/sendmail.ini;
ENV AUTOINSTALL false
ENV VALIDATION true
ENV SITENAME "Friendica Social Network"
ENV FRIENDICA_VERSION 2018.05
ENV FRIENDICA_ADDONS 2018.05
COPY bin/* /usr/local/bin/
COPY config/* /usr/src/config/
COPY *.sh /
RUN chmod +x /*.sh
RUN chmod +x /usr/local/bin/*
RUN set -ex; \
curl -fsSL -o friendica.tar.gz \
"https://github.com/friendica/friendica/archive/${FRIENDICA_VERSION}.tar.gz"; \
@ -108,13 +117,8 @@ RUN set -ex; \
"https://github.com/friendica/friendica-addons/archive/${FRIENDICA_ADDONS}.tar.gz"; \
mkdir /usr/src/friendica/addon; \
tar -xzf friendica_addons.tar.gz -C /usr/src/friendica/addon --strip-components=1; \
rm friendica_addons.tar.gz;
COPY bin/* /usr/local/bin/
COPY config/* /usr/src/config/
COPY *.sh /
RUN chmod +x /*.sh
RUN chmod +x /usr/local/bin/*
rm friendica_addons.tar.gz; \
friendica composer install;
ENTRYPOINT ["/entrypoint.sh"]
CMD ["apache2-foreground"]

View File

@ -1,18 +1,23 @@
#!/bin/sh
set -eu
FRIENDICA_VERSION=${FRIENDICA_VERSION:-develop}
FRIENDICA_ADDONS=${FRIENDICA_ADDONS:-develop}
AUTOINSTALL=${AUTOINSTALL:-false}
SMTP=${SMTP:-localhost}
SMTP_FROM=${SMTP_FROM:-no-reply}
SOURCEDIR=/usr/src
WORKDIR=/var/www/html
SOURCEDIR=${SOURCEDIR:-/usr/src}
WORKDIR=${WORKDIR:-/var/www/html}
SMTP_TLS=${SMTP_TLS:-}
SMTP_STARTTLS=${SMTP_STARTTLS:-}
SMTP_AUTH_USER=${SMTP_AUTH_USER:-}
SMTP_AUTH_PASS=${SMTP_AUTH_PASS:-}
SMTP_AUTH_METHOD=${SMTP_AUTH_METHOD:-}
VERBOSE=1
for arg; do
case "$arg" in
-q|--quit)
if [ "$VERBOSE" -eq "2" ]; then
if [ "$VERBOSE" -eq 2 ]; then
echo 'You cannot use verbose and quiet at the same time'
exit 1
fi
@ -20,7 +25,7 @@ for arg; do
break
;;
-v|--verbose)
if [ "$VERBOSE" -eq "0" ]; then
if [ "$VERBOSE" -eq 0 ]; then
echo 'You cannot use verbose and quiet at the same time'
exit 1
fi
@ -32,7 +37,7 @@ done
# run an command with the www-data user
run_as() {
if [ "$(id -u)" = 0 ]; then
if [ "$(id -u)" -eq 0 ]; then
su - www-data -s /bin/sh -c "$1"
else
sh -c "$1"
@ -42,7 +47,7 @@ run_as() {
# log event
log() {
currVerb=1
if [ $# -eq 2 ]; then
if [ "$#" -eq 2 ]; then
currVerb=$2
fi
if [ "$VERBOSE" -ge "$currVerb" ]; then
@ -105,6 +110,9 @@ console() {
composer() {
if [ -f $WORKDIR/bin/composer.phar ]; then
run_as "cd $WORKDIR;$WORKDIR/bin/composer.phar $@ -d $WORKDIR"
elif [ -f $SOURCEDIR/friendica/bin/composer.phar ]; then
cd $SOURCEDIR/friendica
$SOURCEDIR/friendica/bin/composer.phar "$@" -d $SOURCEDIR/friendica
fi
}
@ -133,7 +141,7 @@ copy_sources() {
fi
if version_greater "$image_version" "$installed_version"; then
if [ "$(id -u)" = 0 ]; then
if [ "$(id -u)" -eq 0 ]; then
rsync_options="-rlDog --chown=www-data:root"
else
rsync_options="-rlD"
@ -163,7 +171,7 @@ install() {
if [ ! -f ${WORKDIR}/.htconfig.php ] &&
[ -f ${SOURCEDIR}/config/htconfig.php ] &&
"$AUTOINSTALL" == "true"; then
[ "$AUTOINSTALL" = "true" ]; then
run_as "cp ${SOURCEDIR}/config/htconfig.php ${WORKDIR}/.htconfig.php"
console autoinstall -f .htconfig.php
# TODO Workaround because of a strange permission issue
@ -186,21 +194,37 @@ update() {
console dbstructure update
}
sendmail() {
if [ ! -f /etc/init.d/sendmail ]; then
# If sendmail isn't installed, exit this method
configmail() {
if [ "$SMTP" = "localhost" ]; then
# SMTP is a required setting
# do nothing if it is "localhost" (= not changed)
return
fi
line=$(head -n 1 /etc/hosts)
line2=$(echo $line | awk '{print $2}')
echo "$line $line2.localdomain" >> /etc/hosts
sed -i "s/:root:/:${SITENAME}:/g" /etc/passwd
sed -i "s/Linux\ User/${SITENAME}/g" /etc/passwd
log 'Starting sendmail for Mail-Support'
nohup /etc/init.d/sendmail start > /dev/null 2>&1 &
# add possible mail-senders
echo "www-data:$SMTP_FROM@$HOSTNAME:$SMTP" >> /etc/ssmtp/revaliases
echo "root:$SMTP_FROM@$HOSTNAME:$SMTP" >> /etc/ssmtp/revaliases
# replace ssmtp.conf settings
cat << EOF > /etc/ssmtp/ssmtp.conf
# /etc/ssmtp/ssmtp.conf
root=$SMTP_FROM@$HOSTNAME
hostname=$HOSTNAME
mailhub=$SMTP
FromLineOverride=YES
EOF
[ -z "$SMTP_TLS" ] || echo "UseTLS=$SMTP_TLS" >> /etc/ssmtp/ssmtp.conf
[ -z "$SMTP_STARTTLS" ] || echo "UseSTARTTLS=$SMTP_STARTTLS" >> /etc/ssmtp/ssmtp.conf
[ -z "$SMTP_AUTH_USER" ] || echo "AuthUser=$SMTP_AUTH_USER" >> /etc/ssmtp/ssmtp.conf
[ -z "$SMTP_AUTH_PASS" ] || echo "AuthPass=$SMTP_AUTH_PASS" >> /etc/ssmtp/ssmtp.conf
[ -z "$SMTP_AUTH_METHOD" ] || echo "AuthMethod=$SMTP_AUTH_METHOD" >> /etc/ssmtp/ssmtp.conf
}
if [ $# -eq 0 ]; then
if [ "$#" -eq 0 ]; then
friendica_help
exit 0
fi
@ -210,6 +234,6 @@ case "$1" in
update) shift; update $@ ;;
console) shift; console $@ ;;
composer) shift; composer $@ ;;
sendmail) shift; sendmail $@ ;;
configmail) shift; configmail $@ ;;
*) friendica_help ;;
esac

View File

@ -106,3 +106,8 @@ $a->config['system']['allowed_link_protocols'] = ['ftp', 'ftps', 'mailto', 'cid'
// Authentication cookie lifetime, in days
$a->config['system']['auth_cookie_lifetime'] = 7;
if (!empty(getenv('VALIDATION'))) {
$a->config['system']['disable_url_validation'] = strtolower(getenv('VALIDATION'));
$a->config['system']['disable_email_validation'] = strtolower(getenv('VALIDATION'));
}

View File

@ -2,6 +2,6 @@
set -eu
friendica install -q
friendica sendmail -q
friendica configmail -q
exec "$@"

View File

@ -4,10 +4,11 @@ LABEL maintainer="Philipp Holzer <admin@philipp.info>"
# entrypoint.sh and cron.sh dependencies
RUN set -ex; \
\
apk add --no-cache \
rsync \
git;
git \
# For mail() support
ssmtp;
# install the PHP extensions we need
# see https://friendi.ca/resources/requirements/
@ -74,10 +75,19 @@ RUN {\
} > /usr/local/etc/php/conf.d/sendmail.ini;
ENV AUTOINSTALL false
ENV VALIDATION true
ENV SITENAME "Friendica Social Network"
ENV FRIENDICA_VERSION 2018.05
ENV FRIENDICA_ADDONS 2018.05
COPY bin/* /usr/local/bin/
COPY config/* /usr/src/config/
COPY *.sh /
RUN chmod +x /*.sh
RUN chmod +x /usr/local/bin/*
RUN set -ex; \
curl -fsSL -o friendica.tar.gz \
"https://github.com/friendica/friendica/archive/${FRIENDICA_VERSION}.tar.gz"; \
@ -89,13 +99,8 @@ RUN set -ex; \
"https://github.com/friendica/friendica-addons/archive/${FRIENDICA_ADDONS}.tar.gz"; \
mkdir /usr/src/friendica/addon; \
tar -xzf friendica_addons.tar.gz -C /usr/src/friendica/addon --strip-components=1; \
rm friendica_addons.tar.gz;
COPY bin/* /usr/local/bin/
COPY config/* /usr/src/config/
COPY *.sh /
RUN chmod +x /*.sh
RUN chmod +x /usr/local/bin/*
rm friendica_addons.tar.gz; \
friendica composer install;
ENTRYPOINT ["/entrypoint.sh"]
CMD ["php-fpm"]

View File

@ -1,18 +1,23 @@
#!/bin/sh
set -eu
FRIENDICA_VERSION=${FRIENDICA_VERSION:-develop}
FRIENDICA_ADDONS=${FRIENDICA_ADDONS:-develop}
AUTOINSTALL=${AUTOINSTALL:-false}
SMTP=${SMTP:-localhost}
SMTP_FROM=${SMTP_FROM:-no-reply}
SOURCEDIR=/usr/src
WORKDIR=/var/www/html
SOURCEDIR=${SOURCEDIR:-/usr/src}
WORKDIR=${WORKDIR:-/var/www/html}
SMTP_TLS=${SMTP_TLS:-}
SMTP_STARTTLS=${SMTP_STARTTLS:-}
SMTP_AUTH_USER=${SMTP_AUTH_USER:-}
SMTP_AUTH_PASS=${SMTP_AUTH_PASS:-}
SMTP_AUTH_METHOD=${SMTP_AUTH_METHOD:-}
VERBOSE=1
for arg; do
case "$arg" in
-q|--quit)
if [ "$VERBOSE" -eq "2" ]; then
if [ "$VERBOSE" -eq 2 ]; then
echo 'You cannot use verbose and quiet at the same time'
exit 1
fi
@ -20,7 +25,7 @@ for arg; do
break
;;
-v|--verbose)
if [ "$VERBOSE" -eq "0" ]; then
if [ "$VERBOSE" -eq 0 ]; then
echo 'You cannot use verbose and quiet at the same time'
exit 1
fi
@ -32,7 +37,7 @@ done
# run an command with the www-data user
run_as() {
if [ "$(id -u)" = 0 ]; then
if [ "$(id -u)" -eq 0 ]; then
su - www-data -s /bin/sh -c "$1"
else
sh -c "$1"
@ -42,7 +47,7 @@ run_as() {
# log event
log() {
currVerb=1
if [ $# -eq 2 ]; then
if [ "$#" -eq 2 ]; then
currVerb=$2
fi
if [ "$VERBOSE" -ge "$currVerb" ]; then
@ -105,6 +110,9 @@ console() {
composer() {
if [ -f $WORKDIR/bin/composer.phar ]; then
run_as "cd $WORKDIR;$WORKDIR/bin/composer.phar $@ -d $WORKDIR"
elif [ -f $SOURCEDIR/friendica/bin/composer.phar ]; then
cd $SOURCEDIR/friendica
$SOURCEDIR/friendica/bin/composer.phar "$@" -d $SOURCEDIR/friendica
fi
}
@ -133,7 +141,7 @@ copy_sources() {
fi
if version_greater "$image_version" "$installed_version"; then
if [ "$(id -u)" = 0 ]; then
if [ "$(id -u)" -eq 0 ]; then
rsync_options="-rlDog --chown=www-data:root"
else
rsync_options="-rlD"
@ -163,7 +171,7 @@ install() {
if [ ! -f ${WORKDIR}/.htconfig.php ] &&
[ -f ${SOURCEDIR}/config/htconfig.php ] &&
"$AUTOINSTALL" == "true"; then
[ "$AUTOINSTALL" = "true" ]; then
run_as "cp ${SOURCEDIR}/config/htconfig.php ${WORKDIR}/.htconfig.php"
console autoinstall -f .htconfig.php
# TODO Workaround because of a strange permission issue
@ -186,21 +194,37 @@ update() {
console dbstructure update
}
sendmail() {
if [ ! -f /etc/init.d/sendmail ]; then
# If sendmail isn't installed, exit this method
configmail() {
if [ "$SMTP" = "localhost" ]; then
# SMTP is a required setting
# do nothing if it is "localhost" (= not changed)
return
fi
line=$(head -n 1 /etc/hosts)
line2=$(echo $line | awk '{print $2}')
echo "$line $line2.localdomain" >> /etc/hosts
sed -i "s/:root:/:${SITENAME}:/g" /etc/passwd
sed -i "s/Linux\ User/${SITENAME}/g" /etc/passwd
log 'Starting sendmail for Mail-Support'
nohup /etc/init.d/sendmail start > /dev/null 2>&1 &
# add possible mail-senders
echo "www-data:$SMTP_FROM@$HOSTNAME:$SMTP" >> /etc/ssmtp/revaliases
echo "root:$SMTP_FROM@$HOSTNAME:$SMTP" >> /etc/ssmtp/revaliases
# replace ssmtp.conf settings
cat << EOF > /etc/ssmtp/ssmtp.conf
# /etc/ssmtp/ssmtp.conf
root=$SMTP_FROM@$HOSTNAME
hostname=$HOSTNAME
mailhub=$SMTP
FromLineOverride=YES
EOF
[ -z "$SMTP_TLS" ] || echo "UseTLS=$SMTP_TLS" >> /etc/ssmtp/ssmtp.conf
[ -z "$SMTP_STARTTLS" ] || echo "UseSTARTTLS=$SMTP_STARTTLS" >> /etc/ssmtp/ssmtp.conf
[ -z "$SMTP_AUTH_USER" ] || echo "AuthUser=$SMTP_AUTH_USER" >> /etc/ssmtp/ssmtp.conf
[ -z "$SMTP_AUTH_PASS" ] || echo "AuthPass=$SMTP_AUTH_PASS" >> /etc/ssmtp/ssmtp.conf
[ -z "$SMTP_AUTH_METHOD" ] || echo "AuthMethod=$SMTP_AUTH_METHOD" >> /etc/ssmtp/ssmtp.conf
}
if [ $# -eq 0 ]; then
if [ "$#" -eq 0 ]; then
friendica_help
exit 0
fi
@ -210,6 +234,6 @@ case "$1" in
update) shift; update $@ ;;
console) shift; console $@ ;;
composer) shift; composer $@ ;;
sendmail) shift; sendmail $@ ;;
configmail) shift; configmail $@ ;;
*) friendica_help ;;
esac

View File

@ -106,3 +106,8 @@ $a->config['system']['allowed_link_protocols'] = ['ftp', 'ftps', 'mailto', 'cid'
// Authentication cookie lifetime, in days
$a->config['system']['auth_cookie_lifetime'] = 7;
if (!empty(getenv('VALIDATION'))) {
$a->config['system']['disable_url_validation'] = strtolower(getenv('VALIDATION'));
$a->config['system']['disable_email_validation'] = strtolower(getenv('VALIDATION'));
}

View File

@ -2,6 +2,6 @@
set -eu
friendica install -q
friendica sendmail -q
friendica configmail -q
exec "$@"

View File

@ -11,7 +11,7 @@ RUN set -ex; \
bzip2 \
git \
# For mail() support
sendmail \
ssmtp \
; \
rm -rf /var/lib/apt/lists/*;
@ -85,10 +85,19 @@ RUN {\
} > /usr/local/etc/php/conf.d/sendmail.ini;
ENV AUTOINSTALL false
ENV VALIDATION true
ENV SITENAME "Friendica Social Network"
ENV FRIENDICA_VERSION 2018.05
ENV FRIENDICA_ADDONS 2018.05
COPY bin/* /usr/local/bin/
COPY config/* /usr/src/config/
COPY *.sh /
RUN chmod +x /*.sh
RUN chmod +x /usr/local/bin/*
RUN set -ex; \
curl -fsSL -o friendica.tar.gz \
"https://github.com/friendica/friendica/archive/${FRIENDICA_VERSION}.tar.gz"; \
@ -100,13 +109,8 @@ RUN set -ex; \
"https://github.com/friendica/friendica-addons/archive/${FRIENDICA_ADDONS}.tar.gz"; \
mkdir /usr/src/friendica/addon; \
tar -xzf friendica_addons.tar.gz -C /usr/src/friendica/addon --strip-components=1; \
rm friendica_addons.tar.gz;
COPY bin/* /usr/local/bin/
COPY config/* /usr/src/config/
COPY *.sh /
RUN chmod +x /*.sh
RUN chmod +x /usr/local/bin/*
rm friendica_addons.tar.gz; \
friendica composer install;
ENTRYPOINT ["/entrypoint.sh"]
CMD ["php-fpm"]

View File

@ -1,18 +1,23 @@
#!/bin/sh
set -eu
FRIENDICA_VERSION=${FRIENDICA_VERSION:-develop}
FRIENDICA_ADDONS=${FRIENDICA_ADDONS:-develop}
AUTOINSTALL=${AUTOINSTALL:-false}
SMTP=${SMTP:-localhost}
SMTP_FROM=${SMTP_FROM:-no-reply}
SOURCEDIR=/usr/src
WORKDIR=/var/www/html
SOURCEDIR=${SOURCEDIR:-/usr/src}
WORKDIR=${WORKDIR:-/var/www/html}
SMTP_TLS=${SMTP_TLS:-}
SMTP_STARTTLS=${SMTP_STARTTLS:-}
SMTP_AUTH_USER=${SMTP_AUTH_USER:-}
SMTP_AUTH_PASS=${SMTP_AUTH_PASS:-}
SMTP_AUTH_METHOD=${SMTP_AUTH_METHOD:-}
VERBOSE=1
for arg; do
case "$arg" in
-q|--quit)
if [ "$VERBOSE" -eq "2" ]; then
if [ "$VERBOSE" -eq 2 ]; then
echo 'You cannot use verbose and quiet at the same time'
exit 1
fi
@ -20,7 +25,7 @@ for arg; do
break
;;
-v|--verbose)
if [ "$VERBOSE" -eq "0" ]; then
if [ "$VERBOSE" -eq 0 ]; then
echo 'You cannot use verbose and quiet at the same time'
exit 1
fi
@ -32,7 +37,7 @@ done
# run an command with the www-data user
run_as() {
if [ "$(id -u)" = 0 ]; then
if [ "$(id -u)" -eq 0 ]; then
su - www-data -s /bin/sh -c "$1"
else
sh -c "$1"
@ -42,7 +47,7 @@ run_as() {
# log event
log() {
currVerb=1
if [ $# -eq 2 ]; then
if [ "$#" -eq 2 ]; then
currVerb=$2
fi
if [ "$VERBOSE" -ge "$currVerb" ]; then
@ -105,6 +110,9 @@ console() {
composer() {
if [ -f $WORKDIR/bin/composer.phar ]; then
run_as "cd $WORKDIR;$WORKDIR/bin/composer.phar $@ -d $WORKDIR"
elif [ -f $SOURCEDIR/friendica/bin/composer.phar ]; then
cd $SOURCEDIR/friendica
$SOURCEDIR/friendica/bin/composer.phar "$@" -d $SOURCEDIR/friendica
fi
}
@ -133,7 +141,7 @@ copy_sources() {
fi
if version_greater "$image_version" "$installed_version"; then
if [ "$(id -u)" = 0 ]; then
if [ "$(id -u)" -eq 0 ]; then
rsync_options="-rlDog --chown=www-data:root"
else
rsync_options="-rlD"
@ -163,7 +171,7 @@ install() {
if [ ! -f ${WORKDIR}/.htconfig.php ] &&
[ -f ${SOURCEDIR}/config/htconfig.php ] &&
"$AUTOINSTALL" == "true"; then
[ "$AUTOINSTALL" = "true" ]; then
run_as "cp ${SOURCEDIR}/config/htconfig.php ${WORKDIR}/.htconfig.php"
console autoinstall -f .htconfig.php
# TODO Workaround because of a strange permission issue
@ -186,21 +194,37 @@ update() {
console dbstructure update
}
sendmail() {
if [ ! -f /etc/init.d/sendmail ]; then
# If sendmail isn't installed, exit this method
configmail() {
if [ "$SMTP" = "localhost" ]; then
# SMTP is a required setting
# do nothing if it is "localhost" (= not changed)
return
fi
line=$(head -n 1 /etc/hosts)
line2=$(echo $line | awk '{print $2}')
echo "$line $line2.localdomain" >> /etc/hosts
sed -i "s/:root:/:${SITENAME}:/g" /etc/passwd
sed -i "s/Linux\ User/${SITENAME}/g" /etc/passwd
log 'Starting sendmail for Mail-Support'
nohup /etc/init.d/sendmail start > /dev/null 2>&1 &
# add possible mail-senders
echo "www-data:$SMTP_FROM@$HOSTNAME:$SMTP" >> /etc/ssmtp/revaliases
echo "root:$SMTP_FROM@$HOSTNAME:$SMTP" >> /etc/ssmtp/revaliases
# replace ssmtp.conf settings
cat << EOF > /etc/ssmtp/ssmtp.conf
# /etc/ssmtp/ssmtp.conf
root=$SMTP_FROM@$HOSTNAME
hostname=$HOSTNAME
mailhub=$SMTP
FromLineOverride=YES
EOF
[ -z "$SMTP_TLS" ] || echo "UseTLS=$SMTP_TLS" >> /etc/ssmtp/ssmtp.conf
[ -z "$SMTP_STARTTLS" ] || echo "UseSTARTTLS=$SMTP_STARTTLS" >> /etc/ssmtp/ssmtp.conf
[ -z "$SMTP_AUTH_USER" ] || echo "AuthUser=$SMTP_AUTH_USER" >> /etc/ssmtp/ssmtp.conf
[ -z "$SMTP_AUTH_PASS" ] || echo "AuthPass=$SMTP_AUTH_PASS" >> /etc/ssmtp/ssmtp.conf
[ -z "$SMTP_AUTH_METHOD" ] || echo "AuthMethod=$SMTP_AUTH_METHOD" >> /etc/ssmtp/ssmtp.conf
}
if [ $# -eq 0 ]; then
if [ "$#" -eq 0 ]; then
friendica_help
exit 0
fi
@ -210,6 +234,6 @@ case "$1" in
update) shift; update $@ ;;
console) shift; console $@ ;;
composer) shift; composer $@ ;;
sendmail) shift; sendmail $@ ;;
configmail) shift; configmail $@ ;;
*) friendica_help ;;
esac

View File

@ -106,3 +106,8 @@ $a->config['system']['allowed_link_protocols'] = ['ftp', 'ftps', 'mailto', 'cid'
// Authentication cookie lifetime, in days
$a->config['system']['auth_cookie_lifetime'] = 7;
if (!empty(getenv('VALIDATION'))) {
$a->config['system']['disable_url_validation'] = strtolower(getenv('VALIDATION'));
$a->config['system']['disable_email_validation'] = strtolower(getenv('VALIDATION'));
}

View File

@ -2,6 +2,6 @@
set -eu
friendica install -q
friendica sendmail -q
friendica configmail -q
exec "$@"

View File

@ -11,7 +11,7 @@ RUN set -ex; \
bzip2 \
git \
# For mail() support
sendmail \
ssmtp \
; \
rm -rf /var/lib/apt/lists/*;
@ -93,16 +93,19 @@ RUN {\
} > /usr/local/etc/php/conf.d/sendmail.ini;
ENV AUTOINSTALL false
ENV VALIDATION true
ENV SITENAME "Friendica Social Network"
ENV FRIENDICA_VERSION 2018.08-dev
ENV FRIENDICA_ADDONS 2018.08-dev
COPY bin/* /usr/local/bin/
COPY config/* /usr/src/config/
COPY *.sh /
RUN chmod +x /*.sh
RUN chmod +x /usr/local/bin/*
ENTRYPOINT ["/entrypoint.sh"]
CMD ["apache2-foreground"]

View File

@ -1,18 +1,23 @@
#!/bin/sh
set -eu
FRIENDICA_VERSION=${FRIENDICA_VERSION:-develop}
FRIENDICA_ADDONS=${FRIENDICA_ADDONS:-develop}
AUTOINSTALL=${AUTOINSTALL:-false}
SMTP=${SMTP:-localhost}
SMTP_FROM=${SMTP_FROM:-no-reply}
SOURCEDIR=/usr/src
WORKDIR=/var/www/html
SOURCEDIR=${SOURCEDIR:-/usr/src}
WORKDIR=${WORKDIR:-/var/www/html}
SMTP_TLS=${SMTP_TLS:-}
SMTP_STARTTLS=${SMTP_STARTTLS:-}
SMTP_AUTH_USER=${SMTP_AUTH_USER:-}
SMTP_AUTH_PASS=${SMTP_AUTH_PASS:-}
SMTP_AUTH_METHOD=${SMTP_AUTH_METHOD:-}
VERBOSE=1
for arg; do
case "$arg" in
-q|--quit)
if [ "$VERBOSE" -eq "2" ]; then
if [ "$VERBOSE" -eq 2 ]; then
echo 'You cannot use verbose and quiet at the same time'
exit 1
fi
@ -20,7 +25,7 @@ for arg; do
break
;;
-v|--verbose)
if [ "$VERBOSE" -eq "0" ]; then
if [ "$VERBOSE" -eq 0 ]; then
echo 'You cannot use verbose and quiet at the same time'
exit 1
fi
@ -32,7 +37,7 @@ done
# run an command with the www-data user
run_as() {
if [ "$(id -u)" = 0 ]; then
if [ "$(id -u)" -eq 0 ]; then
su - www-data -s /bin/sh -c "$1"
else
sh -c "$1"
@ -42,7 +47,7 @@ run_as() {
# log event
log() {
currVerb=1
if [ $# -eq 2 ]; then
if [ "$#" -eq 2 ]; then
currVerb=$2
fi
if [ "$VERBOSE" -ge "$currVerb" ]; then
@ -105,6 +110,9 @@ console() {
composer() {
if [ -f $WORKDIR/bin/composer.phar ]; then
run_as "cd $WORKDIR;$WORKDIR/bin/composer.phar $@ -d $WORKDIR"
elif [ -f $SOURCEDIR/friendica/bin/composer.phar ]; then
cd $SOURCEDIR/friendica
$SOURCEDIR/friendica/bin/composer.phar "$@" -d $SOURCEDIR/friendica
fi
}
@ -133,7 +141,7 @@ copy_sources() {
fi
if version_greater "$image_version" "$installed_version"; then
if [ "$(id -u)" = 0 ]; then
if [ "$(id -u)" -eq 0 ]; then
rsync_options="-rlDog --chown=www-data:root"
else
rsync_options="-rlD"
@ -163,7 +171,7 @@ install() {
if [ ! -f ${WORKDIR}/.htconfig.php ] &&
[ -f ${SOURCEDIR}/config/htconfig.php ] &&
"$AUTOINSTALL" == "true"; then
[ "$AUTOINSTALL" = "true" ]; then
run_as "cp ${SOURCEDIR}/config/htconfig.php ${WORKDIR}/.htconfig.php"
console autoinstall -f .htconfig.php
# TODO Workaround because of a strange permission issue
@ -186,21 +194,37 @@ update() {
console dbstructure update
}
sendmail() {
if [ ! -f /etc/init.d/sendmail ]; then
# If sendmail isn't installed, exit this method
configmail() {
if [ "$SMTP" = "localhost" ]; then
# SMTP is a required setting
# do nothing if it is "localhost" (= not changed)
return
fi
line=$(head -n 1 /etc/hosts)
line2=$(echo $line | awk '{print $2}')
echo "$line $line2.localdomain" >> /etc/hosts
sed -i "s/:root:/:${SITENAME}:/g" /etc/passwd
sed -i "s/Linux\ User/${SITENAME}/g" /etc/passwd
log 'Starting sendmail for Mail-Support'
nohup /etc/init.d/sendmail start > /dev/null 2>&1 &
# add possible mail-senders
echo "www-data:$SMTP_FROM@$HOSTNAME:$SMTP" >> /etc/ssmtp/revaliases
echo "root:$SMTP_FROM@$HOSTNAME:$SMTP" >> /etc/ssmtp/revaliases
# replace ssmtp.conf settings
cat << EOF > /etc/ssmtp/ssmtp.conf
# /etc/ssmtp/ssmtp.conf
root=$SMTP_FROM@$HOSTNAME
hostname=$HOSTNAME
mailhub=$SMTP
FromLineOverride=YES
EOF
[ -z "$SMTP_TLS" ] || echo "UseTLS=$SMTP_TLS" >> /etc/ssmtp/ssmtp.conf
[ -z "$SMTP_STARTTLS" ] || echo "UseSTARTTLS=$SMTP_STARTTLS" >> /etc/ssmtp/ssmtp.conf
[ -z "$SMTP_AUTH_USER" ] || echo "AuthUser=$SMTP_AUTH_USER" >> /etc/ssmtp/ssmtp.conf
[ -z "$SMTP_AUTH_PASS" ] || echo "AuthPass=$SMTP_AUTH_PASS" >> /etc/ssmtp/ssmtp.conf
[ -z "$SMTP_AUTH_METHOD" ] || echo "AuthMethod=$SMTP_AUTH_METHOD" >> /etc/ssmtp/ssmtp.conf
}
if [ $# -eq 0 ]; then
if [ "$#" -eq 0 ]; then
friendica_help
exit 0
fi
@ -210,6 +234,6 @@ case "$1" in
update) shift; update $@ ;;
console) shift; console $@ ;;
composer) shift; composer $@ ;;
sendmail) shift; sendmail $@ ;;
configmail) shift; configmail $@ ;;
*) friendica_help ;;
esac

View File

@ -106,3 +106,8 @@ $a->config['system']['allowed_link_protocols'] = ['ftp', 'ftps', 'mailto', 'cid'
// Authentication cookie lifetime, in days
$a->config['system']['auth_cookie_lifetime'] = 7;
if (!empty(getenv('VALIDATION'))) {
$a->config['system']['disable_url_validation'] = strtolower(getenv('VALIDATION'));
$a->config['system']['disable_email_validation'] = strtolower(getenv('VALIDATION'));
}

View File

@ -2,6 +2,6 @@
set -eu
friendica install -q
friendica sendmail -q
friendica configmail -q
exec "$@"

View File

@ -4,10 +4,11 @@ LABEL maintainer="Philipp Holzer <admin@philipp.info>"
# entrypoint.sh and cron.sh dependencies
RUN set -ex; \
\
apk add --no-cache \
rsync \
git;
git \
# For mail() support
ssmtp;
# install the PHP extensions we need
# see https://friendi.ca/resources/requirements/
@ -74,16 +75,19 @@ RUN {\
} > /usr/local/etc/php/conf.d/sendmail.ini;
ENV AUTOINSTALL false
ENV VALIDATION true
ENV SITENAME "Friendica Social Network"
ENV FRIENDICA_VERSION 2018.08-dev
ENV FRIENDICA_ADDONS 2018.08-dev
COPY bin/* /usr/local/bin/
COPY config/* /usr/src/config/
COPY *.sh /
RUN chmod +x /*.sh
RUN chmod +x /usr/local/bin/*
ENTRYPOINT ["/entrypoint.sh"]
CMD ["php-fpm"]

View File

@ -1,18 +1,23 @@
#!/bin/sh
set -eu
FRIENDICA_VERSION=${FRIENDICA_VERSION:-develop}
FRIENDICA_ADDONS=${FRIENDICA_ADDONS:-develop}
AUTOINSTALL=${AUTOINSTALL:-false}
SMTP=${SMTP:-localhost}
SMTP_FROM=${SMTP_FROM:-no-reply}
SOURCEDIR=/usr/src
WORKDIR=/var/www/html
SOURCEDIR=${SOURCEDIR:-/usr/src}
WORKDIR=${WORKDIR:-/var/www/html}
SMTP_TLS=${SMTP_TLS:-}
SMTP_STARTTLS=${SMTP_STARTTLS:-}
SMTP_AUTH_USER=${SMTP_AUTH_USER:-}
SMTP_AUTH_PASS=${SMTP_AUTH_PASS:-}
SMTP_AUTH_METHOD=${SMTP_AUTH_METHOD:-}
VERBOSE=1
for arg; do
case "$arg" in
-q|--quit)
if [ "$VERBOSE" -eq "2" ]; then
if [ "$VERBOSE" -eq 2 ]; then
echo 'You cannot use verbose and quiet at the same time'
exit 1
fi
@ -20,7 +25,7 @@ for arg; do
break
;;
-v|--verbose)
if [ "$VERBOSE" -eq "0" ]; then
if [ "$VERBOSE" -eq 0 ]; then
echo 'You cannot use verbose and quiet at the same time'
exit 1
fi
@ -32,7 +37,7 @@ done
# run an command with the www-data user
run_as() {
if [ "$(id -u)" = 0 ]; then
if [ "$(id -u)" -eq 0 ]; then
su - www-data -s /bin/sh -c "$1"
else
sh -c "$1"
@ -42,7 +47,7 @@ run_as() {
# log event
log() {
currVerb=1
if [ $# -eq 2 ]; then
if [ "$#" -eq 2 ]; then
currVerb=$2
fi
if [ "$VERBOSE" -ge "$currVerb" ]; then
@ -105,6 +110,9 @@ console() {
composer() {
if [ -f $WORKDIR/bin/composer.phar ]; then
run_as "cd $WORKDIR;$WORKDIR/bin/composer.phar $@ -d $WORKDIR"
elif [ -f $SOURCEDIR/friendica/bin/composer.phar ]; then
cd $SOURCEDIR/friendica
$SOURCEDIR/friendica/bin/composer.phar "$@" -d $SOURCEDIR/friendica
fi
}
@ -133,7 +141,7 @@ copy_sources() {
fi
if version_greater "$image_version" "$installed_version"; then
if [ "$(id -u)" = 0 ]; then
if [ "$(id -u)" -eq 0 ]; then
rsync_options="-rlDog --chown=www-data:root"
else
rsync_options="-rlD"
@ -163,7 +171,7 @@ install() {
if [ ! -f ${WORKDIR}/.htconfig.php ] &&
[ -f ${SOURCEDIR}/config/htconfig.php ] &&
"$AUTOINSTALL" == "true"; then
[ "$AUTOINSTALL" = "true" ]; then
run_as "cp ${SOURCEDIR}/config/htconfig.php ${WORKDIR}/.htconfig.php"
console autoinstall -f .htconfig.php
# TODO Workaround because of a strange permission issue
@ -186,21 +194,37 @@ update() {
console dbstructure update
}
sendmail() {
if [ ! -f /etc/init.d/sendmail ]; then
# If sendmail isn't installed, exit this method
configmail() {
if [ "$SMTP" = "localhost" ]; then
# SMTP is a required setting
# do nothing if it is "localhost" (= not changed)
return
fi
line=$(head -n 1 /etc/hosts)
line2=$(echo $line | awk '{print $2}')
echo "$line $line2.localdomain" >> /etc/hosts
sed -i "s/:root:/:${SITENAME}:/g" /etc/passwd
sed -i "s/Linux\ User/${SITENAME}/g" /etc/passwd
log 'Starting sendmail for Mail-Support'
nohup /etc/init.d/sendmail start > /dev/null 2>&1 &
# add possible mail-senders
echo "www-data:$SMTP_FROM@$HOSTNAME:$SMTP" >> /etc/ssmtp/revaliases
echo "root:$SMTP_FROM@$HOSTNAME:$SMTP" >> /etc/ssmtp/revaliases
# replace ssmtp.conf settings
cat << EOF > /etc/ssmtp/ssmtp.conf
# /etc/ssmtp/ssmtp.conf
root=$SMTP_FROM@$HOSTNAME
hostname=$HOSTNAME
mailhub=$SMTP
FromLineOverride=YES
EOF
[ -z "$SMTP_TLS" ] || echo "UseTLS=$SMTP_TLS" >> /etc/ssmtp/ssmtp.conf
[ -z "$SMTP_STARTTLS" ] || echo "UseSTARTTLS=$SMTP_STARTTLS" >> /etc/ssmtp/ssmtp.conf
[ -z "$SMTP_AUTH_USER" ] || echo "AuthUser=$SMTP_AUTH_USER" >> /etc/ssmtp/ssmtp.conf
[ -z "$SMTP_AUTH_PASS" ] || echo "AuthPass=$SMTP_AUTH_PASS" >> /etc/ssmtp/ssmtp.conf
[ -z "$SMTP_AUTH_METHOD" ] || echo "AuthMethod=$SMTP_AUTH_METHOD" >> /etc/ssmtp/ssmtp.conf
}
if [ $# -eq 0 ]; then
if [ "$#" -eq 0 ]; then
friendica_help
exit 0
fi
@ -210,6 +234,6 @@ case "$1" in
update) shift; update $@ ;;
console) shift; console $@ ;;
composer) shift; composer $@ ;;
sendmail) shift; sendmail $@ ;;
configmail) shift; configmail $@ ;;
*) friendica_help ;;
esac

View File

@ -106,3 +106,8 @@ $a->config['system']['allowed_link_protocols'] = ['ftp', 'ftps', 'mailto', 'cid'
// Authentication cookie lifetime, in days
$a->config['system']['auth_cookie_lifetime'] = 7;
if (!empty(getenv('VALIDATION'))) {
$a->config['system']['disable_url_validation'] = strtolower(getenv('VALIDATION'));
$a->config['system']['disable_email_validation'] = strtolower(getenv('VALIDATION'));
}

View File

@ -2,6 +2,6 @@
set -eu
friendica install -q
friendica sendmail -q
friendica configmail -q
exec "$@"

View File

@ -11,7 +11,7 @@ RUN set -ex; \
bzip2 \
git \
# For mail() support
sendmail \
ssmtp \
; \
rm -rf /var/lib/apt/lists/*;
@ -85,16 +85,19 @@ RUN {\
} > /usr/local/etc/php/conf.d/sendmail.ini;
ENV AUTOINSTALL false
ENV VALIDATION true
ENV SITENAME "Friendica Social Network"
ENV FRIENDICA_VERSION 2018.08-dev
ENV FRIENDICA_ADDONS 2018.08-dev
COPY bin/* /usr/local/bin/
COPY config/* /usr/src/config/
COPY *.sh /
RUN chmod +x /*.sh
RUN chmod +x /usr/local/bin/*
ENTRYPOINT ["/entrypoint.sh"]
CMD ["php-fpm"]

View File

@ -1,18 +1,23 @@
#!/bin/sh
set -eu
FRIENDICA_VERSION=${FRIENDICA_VERSION:-develop}
FRIENDICA_ADDONS=${FRIENDICA_ADDONS:-develop}
AUTOINSTALL=${AUTOINSTALL:-false}
SMTP=${SMTP:-localhost}
SMTP_FROM=${SMTP_FROM:-no-reply}
SOURCEDIR=/usr/src
WORKDIR=/var/www/html
SOURCEDIR=${SOURCEDIR:-/usr/src}
WORKDIR=${WORKDIR:-/var/www/html}
SMTP_TLS=${SMTP_TLS:-}
SMTP_STARTTLS=${SMTP_STARTTLS:-}
SMTP_AUTH_USER=${SMTP_AUTH_USER:-}
SMTP_AUTH_PASS=${SMTP_AUTH_PASS:-}
SMTP_AUTH_METHOD=${SMTP_AUTH_METHOD:-}
VERBOSE=1
for arg; do
case "$arg" in
-q|--quit)
if [ "$VERBOSE" -eq "2" ]; then
if [ "$VERBOSE" -eq 2 ]; then
echo 'You cannot use verbose and quiet at the same time'
exit 1
fi
@ -20,7 +25,7 @@ for arg; do
break
;;
-v|--verbose)
if [ "$VERBOSE" -eq "0" ]; then
if [ "$VERBOSE" -eq 0 ]; then
echo 'You cannot use verbose and quiet at the same time'
exit 1
fi
@ -32,7 +37,7 @@ done
# run an command with the www-data user
run_as() {
if [ "$(id -u)" = 0 ]; then
if [ "$(id -u)" -eq 0 ]; then
su - www-data -s /bin/sh -c "$1"
else
sh -c "$1"
@ -42,7 +47,7 @@ run_as() {
# log event
log() {
currVerb=1
if [ $# -eq 2 ]; then
if [ "$#" -eq 2 ]; then
currVerb=$2
fi
if [ "$VERBOSE" -ge "$currVerb" ]; then
@ -105,6 +110,9 @@ console() {
composer() {
if [ -f $WORKDIR/bin/composer.phar ]; then
run_as "cd $WORKDIR;$WORKDIR/bin/composer.phar $@ -d $WORKDIR"
elif [ -f $SOURCEDIR/friendica/bin/composer.phar ]; then
cd $SOURCEDIR/friendica
$SOURCEDIR/friendica/bin/composer.phar "$@" -d $SOURCEDIR/friendica
fi
}
@ -133,7 +141,7 @@ copy_sources() {
fi
if version_greater "$image_version" "$installed_version"; then
if [ "$(id -u)" = 0 ]; then
if [ "$(id -u)" -eq 0 ]; then
rsync_options="-rlDog --chown=www-data:root"
else
rsync_options="-rlD"
@ -163,7 +171,7 @@ install() {
if [ ! -f ${WORKDIR}/.htconfig.php ] &&
[ -f ${SOURCEDIR}/config/htconfig.php ] &&
"$AUTOINSTALL" == "true"; then
[ "$AUTOINSTALL" = "true" ]; then
run_as "cp ${SOURCEDIR}/config/htconfig.php ${WORKDIR}/.htconfig.php"
console autoinstall -f .htconfig.php
# TODO Workaround because of a strange permission issue
@ -186,21 +194,37 @@ update() {
console dbstructure update
}
sendmail() {
if [ ! -f /etc/init.d/sendmail ]; then
# If sendmail isn't installed, exit this method
configmail() {
if [ "$SMTP" = "localhost" ]; then
# SMTP is a required setting
# do nothing if it is "localhost" (= not changed)
return
fi
line=$(head -n 1 /etc/hosts)
line2=$(echo $line | awk '{print $2}')
echo "$line $line2.localdomain" >> /etc/hosts
sed -i "s/:root:/:${SITENAME}:/g" /etc/passwd
sed -i "s/Linux\ User/${SITENAME}/g" /etc/passwd
log 'Starting sendmail for Mail-Support'
nohup /etc/init.d/sendmail start > /dev/null 2>&1 &
# add possible mail-senders
echo "www-data:$SMTP_FROM@$HOSTNAME:$SMTP" >> /etc/ssmtp/revaliases
echo "root:$SMTP_FROM@$HOSTNAME:$SMTP" >> /etc/ssmtp/revaliases
# replace ssmtp.conf settings
cat << EOF > /etc/ssmtp/ssmtp.conf
# /etc/ssmtp/ssmtp.conf
root=$SMTP_FROM@$HOSTNAME
hostname=$HOSTNAME
mailhub=$SMTP
FromLineOverride=YES
EOF
[ -z "$SMTP_TLS" ] || echo "UseTLS=$SMTP_TLS" >> /etc/ssmtp/ssmtp.conf
[ -z "$SMTP_STARTTLS" ] || echo "UseSTARTTLS=$SMTP_STARTTLS" >> /etc/ssmtp/ssmtp.conf
[ -z "$SMTP_AUTH_USER" ] || echo "AuthUser=$SMTP_AUTH_USER" >> /etc/ssmtp/ssmtp.conf
[ -z "$SMTP_AUTH_PASS" ] || echo "AuthPass=$SMTP_AUTH_PASS" >> /etc/ssmtp/ssmtp.conf
[ -z "$SMTP_AUTH_METHOD" ] || echo "AuthMethod=$SMTP_AUTH_METHOD" >> /etc/ssmtp/ssmtp.conf
}
if [ $# -eq 0 ]; then
if [ "$#" -eq 0 ]; then
friendica_help
exit 0
fi
@ -210,6 +234,6 @@ case "$1" in
update) shift; update $@ ;;
console) shift; console $@ ;;
composer) shift; composer $@ ;;
sendmail) shift; sendmail $@ ;;
configmail) shift; configmail $@ ;;
*) friendica_help ;;
esac

View File

@ -106,3 +106,8 @@ $a->config['system']['allowed_link_protocols'] = ['ftp', 'ftps', 'mailto', 'cid'
// Authentication cookie lifetime, in days
$a->config['system']['auth_cookie_lifetime'] = 7;
if (!empty(getenv('VALIDATION'))) {
$a->config['system']['disable_url_validation'] = strtolower(getenv('VALIDATION'));
$a->config['system']['disable_email_validation'] = strtolower(getenv('VALIDATION'));
}

View File

@ -2,6 +2,6 @@
set -eu
friendica install -q
friendica sendmail -q
friendica configmail -q
exec "$@"

View File

@ -3,10 +3,11 @@ LABEL maintainer="Philipp Holzer <admin@philipp.info>"
# entrypoint.sh and cron.sh dependencies
RUN set -ex; \
\
apk add --no-cache \
rsync \
git;
git \
# For mail() support
ssmtp;
# install the PHP extensions we need
# see https://friendi.ca/resources/requirements/
@ -73,10 +74,11 @@ RUN {\
} > /usr/local/etc/php/conf.d/sendmail.ini;
ENV AUTOINSTALL false
ENV VALIDATION true
ENV SITENAME "Friendica Social Network"
ENV FRIENDICA_VERSION %%VERSION%%
ENV FRIENDICA_ADDONS %%VERSION%%
%%INSTALL_EXTRAS%%
COPY bin/* /usr/local/bin/
COPY config/* /usr/src/config/
@ -84,5 +86,7 @@ COPY *.sh /
RUN chmod +x /*.sh
RUN chmod +x /usr/local/bin/*
%%INSTALL_EXTRAS%%
ENTRYPOINT ["/entrypoint.sh"]
CMD ["%%CMD%%"]

View File

@ -10,7 +10,7 @@ RUN set -ex; \
bzip2 \
git \
# For mail() support
sendmail \
ssmtp \
; \
rm -rf /var/lib/apt/lists/*;
@ -84,10 +84,11 @@ RUN {\
} > /usr/local/etc/php/conf.d/sendmail.ini;
ENV AUTOINSTALL false
ENV VALIDATION true
ENV SITENAME "Friendica Social Network"
ENV FRIENDICA_VERSION %%VERSION%%
ENV FRIENDICA_ADDONS %%VERSION%%
%%INSTALL_EXTRAS%%
COPY bin/* /usr/local/bin/
COPY config/* /usr/src/config/
@ -95,5 +96,7 @@ COPY *.sh /
RUN chmod +x /*.sh
RUN chmod +x /usr/local/bin/*
%%INSTALL_EXTRAS%%
ENTRYPOINT ["/entrypoint.sh"]
CMD ["%%CMD%%"]

View File

@ -121,6 +121,14 @@ You can preconfigure everything that is asked on the install page on first run.
- `AUTOINSTALL` if `true`, the automatic configuration will start (Default: `false`)
**SMTP/Mail Settings**:
- `SMTP` **required** address of the SMTP Mail-Gateway (Default: `localhost`)
- `SMTP_FROM` sender user-part of the address (Default: `no-reply` - e.g. no-reply@friendica.local)
- `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)
**MYSQL/MariaDB**:
- `MYSQL_USERNAME` Username for the database user using mysql.
@ -133,9 +141,10 @@ You can preconfigure everything that is asked on the install page on first run.
You can also predefine the following `.htconfig.php` values:
- `MAILNAME` E-Mail address of the administrator
- `TZ` The default localization of the Friendica server
- `LANGUAGE` The default language of the Friendica server
- `SITENAME` The default name of the Friendica server
- `TZ` The default localization of the Friendica server (Default: `America/Los_Angeles`)
- `LANGUAGE` The default language of the Friendica server (Default: `en`)
- `SITENAME` The default name of the Friendica server (Default: `Friendica Social Network` )
- `VALIDATION` The default setting if url/emails are getting validated (Default: `true`)
## Updating to a newer version

View File

@ -2,6 +2,6 @@
set -eu
friendica install -q
friendica sendmail -q
friendica configmail -q
exec "$@"

View File

@ -27,6 +27,8 @@ services:
- MYSQL_PASSWORD=friendica
- MYSQL_DATABASE=friendica
- MAILNAME=root@friendica.local
- SITENAME=Friendica PWD Test Node
- VALIDATION=false
hostname: friendica.local
depends_on:
- db
@ -44,6 +46,7 @@ services:
- MYSQL_PASSWORD=friendica
- MYSQL_DATABASE=friendica
- MAILNAME=root@friendica.local
- SITENAME=Friendica PWD Test Node
depends_on:
- db

View File

@ -28,7 +28,7 @@ declare -A pecl_versions=(
)
declare -A install_extras=(
['stable']='\nRUN set -ex; \\\n curl -fsSL -o friendica.tar.gz \\\n "https://github.com/friendica/friendica/archive/${FRIENDICA_VERSION}.tar.gz"; \\\n tar -xzf friendica.tar.gz -C /usr/src/; \\\n rm friendica.tar.gz; \\\n mv -f /usr/src/friendica-${FRIENDICA_VERSION}/ /usr/src/friendica; \\\n chmod 777 /usr/src/friendica/view/smarty3; \\\n curl -fsSL -o friendica_addons.tar.gz \\\n "https://github.com/friendica/friendica-addons/archive/${FRIENDICA_ADDONS}.tar.gz"; \\\n mkdir /usr/src/friendica/addon; \\\n tar -xzf friendica_addons.tar.gz -C /usr/src/friendica/addon --strip-components=1; \\\n rm friendica_addons.tar.gz;'
['stable']='\nRUN set -ex; \\\n curl -fsSL -o friendica.tar.gz \\\n "https://github.com/friendica/friendica/archive/${FRIENDICA_VERSION}.tar.gz"; \\\n tar -xzf friendica.tar.gz -C /usr/src/; \\\n rm friendica.tar.gz; \\\n mv -f /usr/src/friendica-${FRIENDICA_VERSION}/ /usr/src/friendica; \\\n chmod 777 /usr/src/friendica/view/smarty3; \\\n curl -fsSL -o friendica_addons.tar.gz \\\n "https://github.com/friendica/friendica-addons/archive/${FRIENDICA_ADDONS}.tar.gz"; \\\n mkdir /usr/src/friendica/addon; \\\n tar -xzf friendica_addons.tar.gz -C /usr/src/friendica/addon --strip-components=1; \\\n rm friendica_addons.tar.gz; \\\n friendica composer install;'
['develop']=''
)