Skip to content
This repository has been archived by the owner on Jun 17, 2024. It is now read-only.

Commit

Permalink
Update start.sh
Browse files Browse the repository at this point in the history
Add data version test.
Copy cert without waiting.
  • Loading branch information
docjyJ authored May 15, 2024
1 parent 7e1880c commit ba3584b
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions start.sh
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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
Expand Down

0 comments on commit ba3584b

Please sign in to comment.