From 607ea4400d896c13d2f28775a824239eb35e4f31 Mon Sep 17 00:00:00 2001 From: Alberto Bertogli Date: Mon, 22 Feb 2021 23:41:06 +0000 Subject: [PATCH] docker: Set the hostname option unconditionally In commit 5305d584 we fixed an issue with the way the Docker image adds the "hostname" option to chasquid.conf. Currently, the Docker entrypoint sets the "hostname" option in chasquid.conf if it's missing. That works fine, except when there is a configuration change and the domain is removed. In that case, the hostname option will have a stale value, forcing the user to re-create the container, which can be cumbersome. This patch fixes the issue by unconditionally setting the hostname option to one of the available domains at the time of start up. Thanks to Jaywann@github for finding and reporting this problem on https://github.com/albertito/chasquid/issues/16, and suggesting an alternative fix! --- docker/entrypoint.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index a14f578..3bb9e9f 100755 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -95,9 +95,10 @@ done >> /etc/dovecot/auto-ssl.conf # Pick the default domain as default hostname for chasquid. This is only used # in plain text sessions and on very rare cases, and it's mostly for aesthetic # purposes. -if ! grep -iq "hostname:" /etc/chasquid/chasquid.conf; then - echo "hostname: '$ONE_DOMAIN'" >> /etc/chasquid/chasquid.conf -fi +# Since the list of domains could have changed since the last run, always +# remove and re-add the setting for consistency. +sed -i '/^hostname:/d' /etc/chasquid/chasquid.conf +echo "hostname: '$ONE_DOMAIN'" >> /etc/chasquid/chasquid.conf # Start the services: dovecot in background, chasquid in foreground. start-stop-daemon --start --quiet --pidfile /run/dovecot.pid \