`inbuxa upgrade [server|console|webmail] [--dry-run] [--yes] [--no-backup]` moves what is installed to the releases this installer pins; a newer installer is what brings newer releases. What is installed is read from the machine: the image tags in compose.yaml, the server binary's --version, the console's release marker, the webmail's VERSION. status now shows each component's version, and what this installer would make it. One component at a time, the server first, each checked once it is running again and put back if not, which stops the upgrade: - a container by its tag in compose.yaml, and its old tag to undo it; - the server on the host keeps its old binary as inbuxa-server.<version>; - the console and the webmail on the host keep their old directory until the new one is in and, for the webmail, answering; its environment's IHASMAIL_VERSION follows the files. Before the server, which may convert its store on first start, it is stopped and its own data archived into <dir>/backups -- the volumes with the server's own image, or <dir>/server -- unless --no-backup. A store kept elsewhere is said to be backed up where it lives. The release marker now records the version beside the checksum, and "local" for a tarball given by hand, which upgrade always replaces. Options and components can come in any order. Tests: the plan read from compose.yaml and the host's files, one image tag changed and no other, a directory put back when its replacement fails, options after components. e2e: upgrade-containers 17/17 (installed by v2026.10.12.1; archive, new images, the same mailbox signing in, a second run with nothing to do), upgrade-host-server 11/11 (a binary that won't start put back with the server answering, then the real release with the old binary kept and the data archived), upgrade-frontends-host 10/10 (older tarballs to the releases, the webmail answering as its new version, the console still pointed at the server). install-local, install-host, webmail-host, all-host and interface pass unchanged.
51 lines
2.6 KiB
Bash
51 lines
2.6 KiB
Bash
#!/bin/bash
|
|
# SPDX-FileCopyrightText: 2026 Coffey Labs LLC
|
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
#
|
|
# inbuxa upgrade, the server on the host: a binary that won't run is put back
|
|
# with the server answering as before, then the real release goes in, with
|
|
# the old binary kept beside it and the data archived first.
|
|
#
|
|
# Run from the host with:
|
|
# OLD_REF=v2026.10.12.1 e2e/vm/run.sh e2e/cases/upgrade-host-server.sh
|
|
set -uo pipefail
|
|
|
|
pass=0; fail=0
|
|
ok() { echo " ok $*"; pass=$((pass+1)); }
|
|
bad() { echo " FAIL $*"; fail=$((fail+1)); }
|
|
DIR=/var/lib/inbuxa
|
|
BIN=/usr/local/bin/inbuxa-server
|
|
ver() { $BIN --version 2>/dev/null | awk '{print $1}'; }
|
|
live() { curl -s -o /dev/null -w '%{http_code}' http://127.0.0.1:8081/.well-known/jmap | grep -qE '^(200|401|30[0-9])$'; }
|
|
|
|
echo "==> installed by the older installer, the server on the host"
|
|
OUT="$(/tmp/inbuxa-old install --local --domain example.test --server host --install-deps --yes 2>&1)"; rc=$?
|
|
[ $rc -eq 0 ] && ok "installed: server $(ver)" || { bad "old install exit $rc"; echo "$OUT" | tail -8 | sed 's/^/ /'; }
|
|
OLD=$(ver)
|
|
|
|
echo
|
|
echo "==> a release that won't start is put back"
|
|
printf '#!/bin/sh\necho "inbuxa 9.9.9 (broken)"\nexit 1\n' > /tmp/broken-server; chmod +x /tmp/broken-server
|
|
OUT="$(INBUXA_SERVER_BINARY=/tmp/broken-server /tmp/inbuxa upgrade server --no-backup --yes 2>&1)"; rc=$?
|
|
[ $rc -ne 0 ] && grep -q "put back" <<<"$OUT" && ok "the upgrade stopped and said it put the server back" || { bad "exit $rc"; echo "$OUT" | tail -6 | sed 's/^/ /'; }
|
|
[ "$(ver)" = "$OLD" ] && ok "the binary is $OLD again" || bad "the binary is now $(ver)"
|
|
for _ in $(seq 1 30); do live && break; sleep 2; done
|
|
live && ok "and the server answers" || bad "the server is down after the rollback"
|
|
|
|
echo
|
|
echo "==> the real release"
|
|
OUT="$(/tmp/inbuxa upgrade --yes 2>&1)"; rc=$?
|
|
echo "$OUT" | grep -v '^ |' | tail -10 | sed 's/^/ /'
|
|
[ $rc -eq 0 ] && ok "upgraded (exit 0)" || bad "upgrade exit $rc"
|
|
[ "$(ver)" != "$OLD" ] && ok "the server is $(ver) now" || bad "still $OLD"
|
|
[ -x $BIN.$OLD ] && ok "the old binary is kept as $BIN.$OLD" || bad "no $BIN.$OLD"
|
|
ls $DIR/backups/server-$OLD-*.tar.gz >/dev/null 2>&1 && ok "the data was archived first" || bad "no archive"
|
|
live && ok "the server answers" || bad "the server does not answer"
|
|
systemctl is-active --quiet inbuxa-server && ok "inbuxa-server is running" || bad "not running"
|
|
OUT="$(/tmp/inbuxa upgrade --yes 2>&1)"
|
|
grep -q "Nothing to do" <<<"$OUT" && ok "a second upgrade has nothing to do" || bad "a second upgrade did something"
|
|
|
|
echo
|
|
echo "==> $pass passed, $fail failed"
|
|
[ "$fail" -eq 0 ]
|