From 0e4cf82476a0f4cec642b879102498160084aeaf Mon Sep 17 00:00:00 2001 From: Jean-Yves <7360784+docjyJ@users.noreply.github.com> Date: Mon, 7 Oct 2024 11:31:54 +0200 Subject: [PATCH] Add way to update webadmin and inprouve doc (#34) * Create webadmin.sh Signed-off-by: Jean-Yves <7360784+docjyJ@users.noreply.github.com> * Update doc and dockerfile Signed-off-by: Jean-Yves <7360784+docjyJ@users.noreply.github.com> --------- Signed-off-by: Jean-Yves <7360784+docjyJ@users.noreply.github.com> --- Dockerfile | 1 + README.md | 68 ++++++++++++++++++++++++++++++----------------------- webadmin.sh | 3 +++ 3 files changed, 42 insertions(+), 30 deletions(-) create mode 100644 webadmin.sh diff --git a/Dockerfile b/Dockerfile index fa4c7d3..0038557 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,6 +3,7 @@ FROM stalwartlabs/mail-server:v0.10.2 COPY --chmod=775 entrypoint.sh /entrypoint.sh COPY --chmod=775 healthcheck.sh /healthcheck.sh +COPY --chmod=775 webadmin.sh /webadmin.sh RUN apt-get install --no-install-recommends -y curl=7.88.1-10+deb12u7 diff --git a/README.md b/README.md index a087682..357f4d5 100644 --- a/README.md +++ b/README.md @@ -9,9 +9,9 @@ > > If you have any suggestions, questions, or want to report a bug, [open an issue](https://github.com/docjyj/aio-stalwart/issues)! -# Stalwart Community Container for Nextcloud All-in-One +# Stalwart Community Container for Nextcloud All-In-One -This container is used in [Nextcloud All-in-One](https://github.com/nextcloud/all-in-one/tree/main/community-containers/stalwart) to provide a mail server. It works with the [Caddy community container](https://github.com/nextcloud/all-in-one/tree/main/community-containers/caddy) as a reverse proxy. +This container is used in [Nextcloud All-In-One](https://github.com/nextcloud/all-in-one/tree/main/community-containers/stalwart) to provide a mail server. It works with the [Caddy community container](https://github.com/nextcloud/all-in-one/tree/main/community-containers/caddy) as a reverse proxy. ## Table of Contents 1. [Features](#features) @@ -23,7 +23,7 @@ This container is used in [Nextcloud All-in-One](https://github.com/nextcloud/al - [Use a Custom Domain](#use-a-custom-domain) - [Use Your Own Reverse Proxy](#use-your-own-reverse-proxy) - [Use Your Own Certificate](#use-your-own-certificate) -4. [Options](#options) +4. [Managed Settings](#managed-settings) 5. [Manual Backup](#manual-backup) - [Create Backup in 0.x.x](#create-backup-in-0xx) - [Restore Backup in 0.x.x](#restore-backup-in-0xx) @@ -36,7 +36,7 @@ This container is used in [Nextcloud All-in-One](https://github.com/nextcloud/al Compared to a default Stalwart container, this container allows: - Automatic configuration of a mail server. -- Compatibility with Nextcloud AIO backups. +- Compatibility with Nextcloud All-In-One backups. - *(Planned)* Synchronization of Nextcloud and Stalwart accounts. ## Getting Started @@ -63,7 +63,8 @@ Additionally, you might want to install and configure [Snappymail](https://apps. > [!IMPORTANT] > This image overrides the configuration of Stalwart on every start. -> This prevents you from making changes that break links with Nextcloud and the Caddy Community Container. +> You can find the list of all managed settings in the [Managed Settings](#managed-settings) section. +> The managed settings prevent breaking links with Nextcloud and the Caddy community container. See the [Stalwart FAQ](https://stalw.art/docs/faq) for all possibilities. @@ -71,15 +72,15 @@ For any questions, [open an issue](https://github.com/docjyj/aio-stalwart/issues ### Change the Admin Password -Before changing the password, disable the automatic configuration of the fallback admin. See [Options](#options). +Before changing the password, disable the managed credential of fallback admin. See [Managed Settings](#managed-settings). -Then you can remove or change the password in the web-admin. +Then you can change the password in the WebAdmin. ### Use a Custom Domain -You can use a custom domain for the mail server. To configure it follow this step: +To configure a custom domain for the mail server, follow these steps: -1. Disable the automatic configuration of certificates. See [Options](#options). +1. Disable the managed configuration of certificates. See [Managed Settings](#managed-settings). 2. Configure your own reverse proxy. See [Use Your Own Reverse Proxy](#use-your-own-reverse-proxy). 3. Add your own certificate. See [Stalwart Certificate](https://stalw.art/docs/server/tls/certificates). @@ -109,26 +110,26 @@ If you're using Caddy, mount the volume `nextcloud_aio_caddy` to your Caddy cont } ``` -If you're using another domain, disable the automatic configuration of certificates. See [Options](#options) and [Stalwart Certificate](https://stalw.art/docs/server/tls/certificates). +**If you're using another domain**, disable the managed configuration of certificates. See [Managed Settings](#managed-settings) and [Stalwart Certificate](https://stalw.art/docs/server/tls/certificates). -## Options +## Managed Settings Disable some automatic override configurations with environment variables in the file `/opt/stalwart-mail/etc/aio-config.env`. | Variable | Description | Default | WebAdmin URL | |----------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------|---------|------------------------------------------------------------------| | `SECURE_DATA_AFTER_UPGRADE` | Prevent the server from starting if the data is in an old format. | `ON` | | -| `ENSURE_MAIL_PORT_CONFIG` | Force mail exchange port configuration.
This port is used to receive emails. | `ON` | `https://mail.$NC_DOMAIN/settings/listener/aio-mail/edit` | -| `ENSURE_SUBMISSION_PORT_CONFIG` | Force mail submission port configuration.
This port is used to send emails. | `ON` | `https://mail.$NC_DOMAIN/settings/listener/aio-submission/edit` | -| `ENSURE_IMAP_PORT_CONFIG` | Force IMAP port configuration.
This port is used to read emails. | `ON` | `https://mail.$NC_DOMAIN/settings/listener/aio-imap/edit` | -| `ENSURE_WEB_PORT_CONFIG` | Force web port configuration.
This port is used to access the web-admin. | `ON` | `https://mail.$NC_DOMAIN/settings/listener/aio-caddy/edit` | -| `ENSURE_MANAGESIEVE_PORT_CONFIG` | Force managesieve port configuration.
This port is used to manage filters. | `ON` | `https://mail.$NC_DOMAIN/settings/listener/aio-managesieve/edit` | -| `ENSURE_STORAGE_CONFIG` | Force storage configuration. | `ON` | `https://mail.$NC_DOMAIN/settings/store/aio-rocksdb/edit` | -| `ENSURE_DIRECTORY_CONFIG` | Force directory configuration.
This is the system to manage users. | `ON` | `https://mail.$NC_DOMAIN/settings/directory/aio-rocksdb/edit` | -| `ENSURE_FILE_LOGGING_CONFIG` | Force file logging configuration.
This provides access to logs from the web-admin. | `ON` | `https://mail.$NC_DOMAIN/settings/tracing/aio-log/edit` | -| `ENSURE_CONSOLE_LOGGING_CONFIG` | Force console logging configuration.
This provides access to logs from Docker and the master container interface. | `ON` | `https://mail.$NC_DOMAIN/settings/tracing/aio-stdout/edit` | -| `ENSURE_FALLBACK_ADMIN_CONFIG` | Force fallback admin configuration.
This is the admin account to access the web-admin. | `ON` | `https://mail.$NC_DOMAIN/settings/authentication/edit` | -| `AUTO_CONFIG_TLS_CERT` | Automatically configure TLS certificates from the Caddy community container.
This is used to secure the connection for the mail protocol. | `ON` | `https://mail.$NC_DOMAIN/settings/certificate/caddy-aio/edit` | +| `ENSURE_MAIL_PORT_CONFIG` | Manage mail exchange port configuration.
This port is used to receive emails. | `ON` | `https://mail.$NC_DOMAIN/settings/listener/aio-mail/edit` | +| `ENSURE_SUBMISSION_PORT_CONFIG` | Manage mail submission port configuration.
This port is used to send emails. | `ON` | `https://mail.$NC_DOMAIN/settings/listener/aio-submission/edit` | +| `ENSURE_IMAP_PORT_CONFIG` | Manage IMAP port configuration.
This port is used to read emails. | `ON` | `https://mail.$NC_DOMAIN/settings/listener/aio-imap/edit` | +| `ENSURE_WEB_PORT_CONFIG` | Manage web port configuration.
This port is used to access the WebAdmin. | `ON` | `https://mail.$NC_DOMAIN/settings/listener/aio-caddy/edit` | +| `ENSURE_MANAGESIEVE_PORT_CONFIG` | Manage managesieve port configuration.
This port is used to manage filters. | `ON` | `https://mail.$NC_DOMAIN/settings/listener/aio-managesieve/edit` | +| `ENSURE_STORAGE_CONFIG` | Manage storage configuration. | `ON` | `https://mail.$NC_DOMAIN/settings/store/aio-rocksdb/edit` | +| `ENSURE_DIRECTORY_CONFIG` | Manage directory configuration.
This is the system to manage users. | `ON` | `https://mail.$NC_DOMAIN/settings/directory/aio-rocksdb/edit` | +| `ENSURE_FILE_LOGGING_CONFIG` | Manage file logging configuration.
This provides access to logs from the WebAdmin. | `ON` | `https://mail.$NC_DOMAIN/settings/tracing/aio-log/edit` | +| `ENSURE_CONSOLE_LOGGING_CONFIG` | Manage console logging configuration.
This provides access to logs from Docker and the master container interface. | `ON` | `https://mail.$NC_DOMAIN/settings/tracing/aio-stdout/edit` | +| `ENSURE_FALLBACK_ADMIN_CONFIG` | Manage fallback admin configuration.
This is the admin account to access the WebAdmin. | `ON` | `https://mail.$NC_DOMAIN/settings/authentication/edit` | +| `AUTO_CONFIG_TLS_CERT` | Manage configuration of TLS certificates from the Caddy community container.
This is used to secure the connection for the mail protocol. | `ON` | `https://mail.$NC_DOMAIN/settings/certificate/caddy-aio/edit` | ## Manual Backup @@ -190,33 +191,40 @@ To avoid any loss of data, Stalwart will not launch. > [!CAUTION] > Before each update, don't forget to make a backup. + +### Issue with Upgrade from 0.10.x to 0.10.x + +Some changes break WebAdmin access. If you have an issue, you try to update the WebAdmin with the following command: `docker exec -it nextcloud-aio-stalwart bash /WebAdmin.sh` + +If you change the fallback admin password use this command: `docker exec -it nextcloud-aio-stalwart curl -k -u 'USER:PASSWORD' http://127.0.0.1:10003/api/update/webadmin` + ### Upgrading from 0.9.x to 0.10.x To upgrade from 0.9.x to 0.10.x, run the following command: 1. Stop the stalwart-mail container: `docker stop nextcloud-aio-stalwart` 2. Check the data version is in `0.9`: `docker run --rm -v nextcloud_aio_stalwart:/opt/stalwart-mail --entrypoint /bin/cat stalwartlabs/mail-server:v0.9.4 /opt/stalwart-mail/aio.lock` -3. *Now you can do a backup in AIO interface or manually in version 0.9.4 (see [Create Backup in 0.x.x](#create-backup-in-0xx)) if you haven't done it yet.* +3. *Now you can do a backup in All-In-One interface or manually in version 0.9.4 (see [Create Backup in 0.x.x](#create-backup-in-0xx)) if you haven't done it yet.* 4. Finally, enable the new data version by running the following command: `docker run --rm -v nextcloud_aio_stalwart:/opt/stalwart-mail --entrypoint /bin/sed stalwartlabs/mail-server:v0.10.0 -i 's/^0.9$/0.10/g' /opt/stalwart-mail/aio.lock` -Then, go inside your AIO panel and restart your container. +Then, go inside your All-In-One panel and restart your container. ### Upgrading from 0.8.x to 0.9.x This migration does not require any action, but the organization of the database and autoconfiguration script has changed. -1. Be vigilant about possible data loss, see [Stalwart 0.9.0](https://github.com/stalwartlabs/mail-server/releases/tag/v0.9.0) -2. Be careful if you have made any settings, the autoconfiguration script might overwrite them, see [Options](#options). +1. Be vigilant about possible the data loss, see [Stalwart 0.9.0](https://github.com/stalwartlabs/mail-server/releases/tag/v0.9.0) +2. Be careful if you have made any settings, the autoconfiguration script might overwrite them, see [Managed Settings](#managed-settings). To upgrade from 0.8.x to 0.9.x, run the following steps: 1. Stop the stalwart-mail container: `docker stop nextcloud-aio-stalwart` 2. Check the data version is in `0.8.0`: `docker run --rm -v nextcloud_aio_stalwart:/opt/stalwart-mail --entrypoint /bin/cat stalwartlabs/mail-server:v0.8.0 /opt/stalwart-mail/aio.lock` 3. **Backup your configuration file** by copying out of this command: `docker run --rm -v nextcloud_aio_stalwart:/opt/stalwart-mail --entrypoint /bin/cat stalwartlabs/mail-server /opt/stalwart-mail/etc/config.toml` -4. *Now you can do a backup in AIO interface or manually in version 0.8.5 (see [Create Backup in 0.x.x](#create-backup-in-0xx)) if you haven't done it yet.* +4. *Now you can do a backup in All-In-One interface or manually in version 0.8.5 (see [Create Backup in 0.x.x](#create-backup-in-0xx)) if you haven't done it yet.* 5. Finally, enable the new data version by running the following command: `docker run --rm -v nextcloud_aio_stalwart:/opt/stalwart-mail --entrypoint /bin/sed stalwartlabs/mail-server:v0.9.0 -i 's/^0.8.0$/0.9/g' /opt/stalwart-mail/aio.lock` -Then, go inside your AIO panel and restart your container. +Then, go inside your All-In-One panel and restart your container. You can verify your config file with the following command after starting the container: ```bash @@ -230,8 +238,8 @@ To upgrade from 0.7.x to 0.8.x, run the following steps: 1. Stop the stalwart-mail container: `docker stop nextcloud-aio-stalwart` 2. Check the data version is in `0.7.0`: `docker run --rm -v nextcloud_aio_stalwart:/opt/stalwart-mail --entrypoint /bin/cat stalwartlabs/mail-server:v0.7.3 /opt/stalwart-mail/aio.lock` 3. **You must export your data before upgrading.** Use stalwart version `0.7.3` and follow steps [Create Backup in 0.x.x](#create-backup-in-0xx). -4. *Now you can do a backup in AIO interface if you haven't done it yet.* +4. *Now you can do a backup in All-In-One interface if you haven't done it yet.* 5. After exporting, import your data by using stalwart version `0.8.0` and follow steps [Restore Backup in 0.x.x](#restore-backup-in-0xx). 6. Finally, enable the new data version by running the following command: `docker run --rm -v nextcloud_aio_stalwart:/opt/stalwart-mail --entrypoint /bin/sed stalwartlabs/mail-server:v0.8.0 -i 's/^0.7.0$/0.8.0/g' /opt/stalwart-mail/aio.lock` -Now go inside your AIO panel and restart and upgrade your container. +Now go inside your All-In-One panel and restart and upgrade your container. diff --git a/webadmin.sh b/webadmin.sh new file mode 100644 index 0000000..890a4a0 --- /dev/null +++ b/webadmin.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +curl -k -u "admin:$STALWART_USER_PASS" http://127.0.0.1:10003/api/update/webadmin