From ba3584b5c1ed5b7b8e7f7b2725579f90d7416c9f 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] Update start.sh Add data version test. Copy cert without waiting. --- 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