From 38b38e48f0366b97d267fa2108d1f71af63c8f7e Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Mon, 25 Feb 2019 11:19:26 +0100 Subject: [PATCH 1/4] Install nextcloud rainloop plugin during setup --- scripts/postinstall.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/postinstall.sh b/scripts/postinstall.sh index b4b5c71..c94efe9 100755 --- a/scripts/postinstall.sh +++ b/scripts/postinstall.sh @@ -26,6 +26,8 @@ touch /mnt/repo-base/volumes/nextcloud/data/.ocdata echo "Installing nextcloud plugin" docker-compose exec --user www-data nextcloud php /var/www/html/occ app:install user_backend_sql_raw +docker-compose exec --user www-data nextcloud php /var/www/html/occ app:install rainloop +docker-compose exec --user www-data nextcloud php /var/www/html/occ config:app:set rainloop rainloop-autologin --value 1 docker-compose exec --user www-data nextcloud php /var/www/html/occ upgrade echo "Restarting Nextcloud container" -- GitLab From 08a5c78fcaf8f1ff10c6ef17fe5b3cd64dcf51f6 Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Mon, 25 Feb 2019 11:22:22 +0100 Subject: [PATCH 2/4] Remove rainloop docker image and nginx config --- .../docker-compose/docker-compose-base.yml | 17 ---------- templates/nginx/sites-enabled/webmail | 31 ------------------- 2 files changed, 48 deletions(-) delete mode 100644 templates/nginx/sites-enabled/webmail diff --git a/templates/docker-compose/docker-compose-base.yml b/templates/docker-compose/docker-compose-base.yml index a16168a..049c66a 100644 --- a/templates/docker-compose/docker-compose-base.yml +++ b/templates/docker-compose/docker-compose-base.yml @@ -63,23 +63,6 @@ services: - eelomailserver - mariadb - # Webmail (Optional) - # https://github.com/hardware/rainloop - # https://www.rainloop.net/ - # Configuration : https://github.com/hardware/mailserver/wiki/Rainloop-initial-configuration - rainloop: - #image: hardware/rainloop - image: registry.gitlab.e.foundation:5000/e/infra/docker-rainloop:0.1.1 - container_name: rainloop - restart: unless-stopped - networks: - - serverbase - volumes: - - /mnt/repo-base/volumes/rainloop/data:/rainloop/data - depends_on: - - eelomailserver - - mariadb - # Database # https://github.com/docker-library/mariadb # https://mariadb.org/ diff --git a/templates/nginx/sites-enabled/webmail b/templates/nginx/sites-enabled/webmail deleted file mode 100644 index cc7277e..0000000 --- a/templates/nginx/sites-enabled/webmail +++ /dev/null @@ -1,31 +0,0 @@ -server { - listen 8000; - server_name webmail.@@@DOMAIN@@@; - return 301 https://$host$request_uri; -} - -server { - listen 4430 ssl http2; - server_name webmail.@@@DOMAIN@@@; - - ssl_certificate /certs/live/webmail.@@@DOMAIN@@@/fullchain.pem; - ssl_certificate_key /certs/live/webmail.@@@DOMAIN@@@/privkey.pem; - - include /etc/nginx/params/ssl_params; - include /etc/nginx/params/headers_params; - - #add_header Strict-Transport-Security "max-age=;"; - #client_max_body_size M; - - #auth_basic "Who's this?"; - #auth_basic_user_file /passwds/.htpasswd; - - location / { - proxy_pass http://rainloop:8888; - include /etc/nginx/params/proxy_params; - } - - location /.well-known/acme-challenge/ { - alias /etc/letsencrypt/acme-challenge/.well-known/acme-challenge/; - } -} -- GitLab From 9d66ea6c6bacb1c2a1602e360248fe250532947e Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Mon, 25 Feb 2019 12:27:43 +0100 Subject: [PATCH 3/4] Configure rainloop automatically --- scripts/postinstall.sh | 29 +++++++++++++++++----------- templates/rainloop/domain-config.ini | 16 +++++++++++++++ 2 files changed, 34 insertions(+), 11 deletions(-) create mode 100644 templates/rainloop/domain-config.ini diff --git a/scripts/postinstall.sh b/scripts/postinstall.sh index c94efe9..29f2514 100755 --- a/scripts/postinstall.sh +++ b/scripts/postinstall.sh @@ -11,7 +11,7 @@ do printf "." sleep 0.1 done -while docker-compose exec --user www-data nextcloud php occ | grep -q "Nextcloud is not installed"; +while docker-compose exec -T --user www-data nextcloud php occ | grep -q "Nextcloud is not installed"; do printf "." sleep 0.1 @@ -25,31 +25,38 @@ cat /mnt/repo-base/templates/nextcloud/plugin-config/user_sql_raw_config.conf | touch /mnt/repo-base/volumes/nextcloud/data/.ocdata echo "Installing nextcloud plugin" -docker-compose exec --user www-data nextcloud php /var/www/html/occ app:install user_backend_sql_raw -docker-compose exec --user www-data nextcloud php /var/www/html/occ app:install rainloop -docker-compose exec --user www-data nextcloud php /var/www/html/occ config:app:set rainloop rainloop-autologin --value 1 -docker-compose exec --user www-data nextcloud php /var/www/html/occ upgrade +docker-compose exec -T --user www-data nextcloud php /var/www/html/occ app:install user_backend_sql_raw +docker-compose exec -T --user www-data nextcloud php /var/www/html/occ app:install rainloop +docker-compose exec -T --user www-data nextcloud php /var/www/html/occ config:app:set rainloop rainloop-autologin --value 1 +docker-compose exec -T --user www-data nextcloud php /var/www/html/occ upgrade echo "Restarting Nextcloud container" docker-compose restart nextcloud +echo "Configuring Rainloop" +mkdir -p "/mnt/repo-base/volumes/nextcloud/data/rainloop-storage/_data_/_default_/domains/" +echo "$ADD_DOMAINS" | tr "," "\n" | while read add_domain; do + cat "templates/rainloop/domain-config.ini" | sed "s/@@@EMAIL_DOMAIN@@@/$DOMAIN/g" > "/mnt/repo-base/volumes/nextcloud/data/rainloop-storage/_data_/_default_/domains/$add_domain.ini" +done +chown www-data:www-data /mnt/repo-base/volumes/nextcloud/ -R + echo "Creating postfix database schema" curl --silent -L https://mail.$DOMAIN/setup.php > /dev/null echo "Setting Postfix admin setup password" docker cp /mnt/repo-base/deployment/postfixadmin/pwgen.php postfixadmin:/postfixadmin -SETUPPW_HASH=$(docker-compose exec postfixadmin php /postfixadmin/pwgen.php "$PFA_SETUP_PASSWORD" | tail -n1) -docker-compose exec postfixadmin sed -i "s|\($CONF\['setup_password'\].*=\).*|\1 '${SETUPPW_HASH}';|" /postfixadmin/config.inc.php -docker-compose exec postfixadmin rm /postfixadmin/pwgen.php +SETUPPW_HASH=$(docker-compose exec -T postfixadmin php /postfixadmin/pwgen.php "$PFA_SETUP_PASSWORD" | tail -n1) +docker-compose exec -T postfixadmin sed -i "s|\($CONF\['setup_password'\].*=\).*|\1 '${SETUPPW_HASH}';|" /postfixadmin/config.inc.php +docker-compose exec -T postfixadmin rm /postfixadmin/pwgen.php echo "Adding Postfix admin superadmin account" -docker-compose exec postfixadmin php /postfixadmin/scripts/postfixadmin-cli.php admin add $ALT_EMAIL --password $PFA_SUPERADMIN_PASSWORD --password2 $PFA_SUPERADMIN_PASSWORD --superadmin +docker-compose exec -T postfixadmin php /postfixadmin/scripts/postfixadmin-cli.php admin add $ALT_EMAIL --password $PFA_SUPERADMIN_PASSWORD --password2 $PFA_SUPERADMIN_PASSWORD --superadmin echo "Adding domains to Postfix" -echo "$ADD_DOMAINS" | tr "," "\n" | while read line; do docker-compose exec postfixadmin php /postfixadmin/scripts/postfixadmin-cli.php domain add $line; done +echo "$ADD_DOMAINS" | tr "," "\n" | while read line; do docker-compose exec -T postfixadmin php /postfixadmin/scripts/postfixadmin-cli.php domain add $line; done echo "Adding email accounts used by system senders (drive, ...)" -docker-compose exec postfixadmin php /postfixadmin/scripts/postfixadmin-cli.php mailbox add drive@$DOMAIN --password $DRIVE_SMTP_PASSWORD --password2 $DRIVE_SMTP_PASSWORD --name "drive" --email-other $ALT_EMAIL +docker-compose exec -T postfixadmin php /postfixadmin/scripts/postfixadmin-cli.php mailbox add drive@$DOMAIN --password $DRIVE_SMTP_PASSWORD --password2 $DRIVE_SMTP_PASSWORD --name "drive" --email-other $ALT_EMAIL # display DKIM DNS setup info/instructions to the user echo -e "\n\n\n" diff --git a/templates/rainloop/domain-config.ini b/templates/rainloop/domain-config.ini new file mode 100644 index 0000000..a36e2aa --- /dev/null +++ b/templates/rainloop/domain-config.ini @@ -0,0 +1,16 @@ +imap_host = "@@@EMAIL_DOMAIN@@@" +imap_port = 143 +imap_secure = "TLS" +imap_short_login = Off +sieve_use = Off +sieve_allow_raw = Off +sieve_host = "" +sieve_port = 4190 +sieve_secure = "None" +smtp_host = "@@@EMAIL_DOMAIN@@@" +smtp_port = 587 +smtp_secure = "TLS" +smtp_short_login = Off +smtp_auth = On +smtp_php_mail = Off +white_list = "" -- GitLab From 3e5e273866e5eae7e0ea1d9630800bd00b5d7f06 Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Tue, 26 Feb 2019 14:49:47 +0100 Subject: [PATCH 4/4] Provide config for postfixadmin --- config-dynamic/postfixadmin/.keep | 0 deployment/postfixadmin/pwgen.php | 16 ---------------- scripts/postinstall.sh | 6 ------ templates/docker-compose/docker-compose-base.yml | 3 +++ templates/postfixadmin/config.local.php | 3 +++ 5 files changed, 6 insertions(+), 22 deletions(-) create mode 100644 config-dynamic/postfixadmin/.keep delete mode 100644 deployment/postfixadmin/pwgen.php create mode 100644 templates/postfixadmin/config.local.php diff --git a/config-dynamic/postfixadmin/.keep b/config-dynamic/postfixadmin/.keep new file mode 100644 index 0000000..e69de29 diff --git a/deployment/postfixadmin/pwgen.php b/deployment/postfixadmin/pwgen.php deleted file mode 100644 index 81ccca9..0000000 --- a/deployment/postfixadmin/pwgen.php +++ /dev/null @@ -1,16 +0,0 @@ - \ No newline at end of file diff --git a/scripts/postinstall.sh b/scripts/postinstall.sh index 29f2514..7665895 100755 --- a/scripts/postinstall.sh +++ b/scripts/postinstall.sh @@ -43,12 +43,6 @@ chown www-data:www-data /mnt/repo-base/volumes/nextcloud/ -R echo "Creating postfix database schema" curl --silent -L https://mail.$DOMAIN/setup.php > /dev/null -echo "Setting Postfix admin setup password" -docker cp /mnt/repo-base/deployment/postfixadmin/pwgen.php postfixadmin:/postfixadmin -SETUPPW_HASH=$(docker-compose exec -T postfixadmin php /postfixadmin/pwgen.php "$PFA_SETUP_PASSWORD" | tail -n1) -docker-compose exec -T postfixadmin sed -i "s|\($CONF\['setup_password'\].*=\).*|\1 '${SETUPPW_HASH}';|" /postfixadmin/config.inc.php -docker-compose exec -T postfixadmin rm /postfixadmin/pwgen.php - echo "Adding Postfix admin superadmin account" docker-compose exec -T postfixadmin php /postfixadmin/scripts/postfixadmin-cli.php admin add $ALT_EMAIL --password $PFA_SUPERADMIN_PASSWORD --password2 $PFA_SUPERADMIN_PASSWORD --superadmin diff --git a/templates/docker-compose/docker-compose-base.yml b/templates/docker-compose/docker-compose-base.yml index 049c66a..4dabc44 100644 --- a/templates/docker-compose/docker-compose-base.yml +++ b/templates/docker-compose/docker-compose-base.yml @@ -59,6 +59,9 @@ services: environment: - DBPASS=${DBPASS} - POSTFIXADMIN_SSH_PASSWORD=${POSTFIXADMIN_SSH_PASSWORD} + - POSTFIXADMIN_SETUP_PASSWORD=${PFA_SETUP_PASSWORD} + volumes: + - /mnt/repo-base/config-dynamic/postfixadmin/config.local.php:/postfixadmin/config.local.php depends_on: - eelomailserver - mariadb diff --git a/templates/postfixadmin/config.local.php b/templates/postfixadmin/config.local.php new file mode 100644 index 0000000..58af54d --- /dev/null +++ b/templates/postfixadmin/config.local.php @@ -0,0 +1,3 @@ + -- GitLab