From 6824b5339e745ca7206ecd6e23bb5a3e166d08c2 Mon Sep 17 00:00:00 2001 From: Jean-Yves <7360784+docjyJ@users.noreply.github.com> Date: Thu, 16 May 2024 00:02:28 +0200 Subject: [PATCH 1/4] Update start.sh Add data version test. Copy cert without waiting. Signed-off-by: Jean-Yves <7360784+docjyJ@users.noreply.github.com> --- start.sh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/start.sh b/start.sh index a05bae7..d29aba4 100644 --- a/start.sh +++ b/start.sh @@ -1,5 +1,21 @@ #!/bin/bash +# Test data +AIO_LOCK="/opt/stalwart-mail/aio.lock" +DATA_VERSION="0.7.0" + +if [ -f "$AIO_LOCK" ]; then + if ! cmp --silent <$(cat "$AIO_LOCK") <$(echo "$DATA_VERSION"); then + echo "Your data is in an old format." + echo "Make a backup and see https://github.com/nextcloud/all-in-one/blob/main/community-containers/stalwart/readme.md" + echo "To avoid any loss of data, Stalwart will not launch." + exit 1 + fi +else + echo "$DATA_VERSION" > "$DATA_VERSION" +fi + +# Get cert CERT_DIR="/opt/aio-certs" CERT_PRIV="$CERT_DIR/privkey.key" CERT_PUP="$CERT_DIR/fullchain.crt" @@ -11,12 +27,15 @@ rm -f "$CERT_PUP" AIO_PRIV="/caddy/caddy/certificates/acme-v02.api.letsencrypt.org-directory/mail.$NC_DOMAIN/mail.$NC_DOMAIN.key" AIO_PUB="/caddy/caddy/certificates/acme-v02.api.letsencrypt.org-directory/mail.$NC_DOMAIN/mail.$NC_DOMAIN.crt" + +[ -f "$AIO_PRIV" ] && cp "$AIO_PRIV" "$CERT_PRIV" while ! [ -f "$CERT_PRIV" ]; do echo "Waiting for key to get created..." sleep 5 [ -f "$AIO_PRIV" ] && cp "$AIO_PRIV" "$CERT_PRIV" done +[ -f "$AIO_PUB" ] && cp "$AIO_PUB" "$CERT_PUP" while ! [ -f $CERT_PUP ]; do echo "Waiting for cert to get created..." sleep 5 From 4f1bdb6e8fa5e0b065931438b671ecb9dd6c6ba4 Mon Sep 17 00:00:00 2001 From: Jean-Yves <7360784+docjyJ@users.noreply.github.com> Date: Sat, 18 May 2024 19:06:43 +0200 Subject: [PATCH 2/4] Fix script Signed-off-by: Jean-Yves <7360784+docjyJ@users.noreply.github.com> --- start.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/start.sh b/start.sh index d29aba4..399ee03 100644 --- a/start.sh +++ b/start.sh @@ -5,7 +5,7 @@ AIO_LOCK="/opt/stalwart-mail/aio.lock" DATA_VERSION="0.7.0" if [ -f "$AIO_LOCK" ]; then - if ! cmp --silent <$(cat "$AIO_LOCK") <$(echo "$DATA_VERSION"); then + if [ "$DATA_VERSION" != "$(cat "$AIO_LOCK")" ]; then echo "Your data is in an old format." echo "Make a backup and see https://github.com/nextcloud/all-in-one/blob/main/community-containers/stalwart/readme.md" echo "To avoid any loss of data, Stalwart will not launch." From 4a5e6a7783c3a3cc85d75ef7774f702b993a33ae Mon Sep 17 00:00:00 2001 From: Jean-Yves <7360784+docjyJ@users.noreply.github.com> Date: Sat, 18 May 2024 19:11:08 +0200 Subject: [PATCH 3/4] change url Signed-off-by: Jean-Yves <7360784+docjyJ@users.noreply.github.com> --- start.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/start.sh b/start.sh index 399ee03..ad88aa4 100644 --- a/start.sh +++ b/start.sh @@ -7,7 +7,7 @@ DATA_VERSION="0.7.0" if [ -f "$AIO_LOCK" ]; then if [ "$DATA_VERSION" != "$(cat "$AIO_LOCK")" ]; then echo "Your data is in an old format." - echo "Make a backup and see https://github.com/nextcloud/all-in-one/blob/main/community-containers/stalwart/readme.md" + echo "Make a backup and see https://github.com/nextcloud/all-in-one/blob/main/community-containers/stalwart/upgrading.md" echo "To avoid any loss of data, Stalwart will not launch." exit 1 fi From 85a9d07f87d4460145bb3d7a305f4e4c533ccb25 Mon Sep 17 00:00:00 2001 From: Jean-Yves <7360784+docjyJ@users.noreply.github.com> Date: Sat, 18 May 2024 19:40:50 +0200 Subject: [PATCH 4/4] Fix Signed-off-by: Jean-Yves <7360784+docjyJ@users.noreply.github.com> --- start.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/start.sh b/start.sh index ad88aa4..baa3094 100644 --- a/start.sh +++ b/start.sh @@ -12,7 +12,7 @@ if [ -f "$AIO_LOCK" ]; then exit 1 fi else - echo "$DATA_VERSION" > "$DATA_VERSION" + echo "$DATA_VERSION" > "$AIO_LOCK" fi # Get cert