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

Adds version testing in start.sh to prevent data loss #17

Merged
merged 4 commits into from
May 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 [ "$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/upgrading.md"
echo "To avoid any loss of data, Stalwart will not launch."
exit 1
fi
else
echo "$DATA_VERSION" > "$AIO_LOCK"
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