From 27.1 the store layout is inbuxa's own, and Stalwart is a migration source. The one Stalwart format inbuxa keeps reading is 0.16.27's, by export and import. docs/spec/import-0.16.md says what carries over, what changes on first start, and what the operator has to change. tests/resources/import-0.16.27 is a real 0.16.27 export (84K): accounts, a group, a custom role, a tenant, mail with threads and an attachment, sharing, calendars, contacts, Sieve and a vacation response, plus a snapshot of what 0.16.27 served. tools/import-check/check.sh imports it into an image, compares what that serves against the snapshot, less the known differences (inbuxa's own role and permissions), then checks delivery through the imported filter, search after the reindex, and re-saving a pre-rename filter. It passes on 27.1-rc.4. make-fixture.sh rebuilds the fixture from the pinned 0.16.27 image, with no internet, so no upstream download ends up in it. SPEC.md and migration.md no longer promise an unchanged store format.
48 lines
2.3 KiB
Bash
Executable File
48 lines
2.3 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# SPDX-FileCopyrightText: 2026 Coffey Labs LLC
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
#
|
|
# Build the Stalwart 0.16.27 import fixture in tests/resources/import-0.16.27/:
|
|
# a fresh 0.16.27 server from the official image, set up and filled over JMAP
|
|
# (populate.py), snapshotted (expected.json), then exported with its own
|
|
# --export. The export is what an operator moving from 0.16.27 hands to
|
|
# `inbuxa --import`.
|
|
#
|
|
# The server gets no internet: GitHub resolves to loopback and DNS goes
|
|
# nowhere, so the web interface and data files it fetches at first start
|
|
# never land in the fixture. Only needed when the fixture itself changes;
|
|
# check.sh is what runs against a release.
|
|
set -euo pipefail
|
|
HERE=$(cd "$(dirname "$0")" && pwd)
|
|
ROOT=$(cd "$HERE/../.." && pwd)
|
|
export FIXTURE="${FIXTURE:-$ROOT/tests/resources/import-0.16.27}"
|
|
IMAGE=stalwartlabs/stalwart@sha256:c429b311c93db5606598abc1c68225a85a6953183848ae01bee9c6a98885836c # v0.16.27
|
|
NAME=inbuxa-import-fixture PORT=18090 URL=http://127.0.0.1:18090
|
|
WORK=$(mktemp -d)
|
|
trap 'docker rm -f $NAME >/dev/null 2>&1 || true; rm -rf "$WORK"' EXIT
|
|
mkdir -p "$WORK/etc" "$WORK/data" "$WORK/export" && chmod 777 "$WORK"/*
|
|
export BOOT_PASSWORD=$(head -c 18 /dev/urandom | base64 | tr -d '/+=')
|
|
|
|
wait_live() {
|
|
for _ in $(seq 1 60); do curl -sf -o /dev/null $URL/healthz/live && return; sleep 1; done
|
|
echo "server never came up" >&2; docker logs $NAME | tail -20 >&2; exit 1
|
|
}
|
|
run() {
|
|
docker rm -f $NAME >/dev/null 2>&1 || true
|
|
docker run -d --name $NAME --dns 127.0.0.1 --add-host github.com:127.0.0.1 \
|
|
--add-host objects.githubusercontent.com:127.0.0.1 -p 127.0.0.1:$PORT:8080 \
|
|
-v "$WORK/etc:/etc/stalwart" -v "$WORK/data:/var/lib/stalwart" "$@" $IMAGE >/dev/null
|
|
wait_live
|
|
}
|
|
|
|
run -e STALWART_RECOVERY_ADMIN="admin:$BOOT_PASSWORD"
|
|
python3 -I "$HERE/bootstrap.py" $URL
|
|
run
|
|
python3 -I "$HERE/populate.py" $URL
|
|
python3 -I "$HERE/snapshot.py" $URL > "$FIXTURE/expected.json"
|
|
docker rm -f $NAME >/dev/null
|
|
docker run --rm -v "$WORK/etc:/etc/stalwart" -v "$WORK/data:/var/lib/stalwart" -v "$WORK/export:/export" \
|
|
$IMAGE --config /etc/stalwart/config.json --export /export >/dev/null
|
|
rm -rf "$FIXTURE/export" && cp -r "$WORK/export" "$FIXTURE/export"
|
|
echo "fixture written: $(du -sh "$FIXTURE/export" | cut -f1) export, expected.json, admin.json"
|