`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.
44 lines
2.6 KiB
Bash
44 lines
2.6 KiB
Bash
#!/bin/bash
|
|
# SPDX-FileCopyrightText: 2026 Coffey Labs LLC
|
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
#
|
|
# inbuxa upgrade, the console and the webmail on the host: installed from
|
|
# older tarballs, moved to this installer's releases, the webmail answering
|
|
# as the new version afterwards and the console still pointed at the server.
|
|
#
|
|
# Run from the host with older tarballs:
|
|
# CONSOLE_TARBALL=… WEBMAIL_TARBALL=… e2e/vm/run.sh e2e/cases/upgrade-frontends-host.sh
|
|
set -uo pipefail
|
|
|
|
pass=0; fail=0
|
|
ok() { echo " ok $*"; pass=$((pass+1)); }
|
|
bad() { echo " FAIL $*"; fail=$((fail+1)); }
|
|
DIR=/var/lib/inbuxa
|
|
|
|
echo "==> installed from older tarballs"
|
|
OUT="$(INBUXA_CONSOLE_TARBALL=/tmp/inbuxa-console-test.tar.gz INBUXA_WEBMAIL_TARBALL=/tmp/inbuxa-webmail-test.tar.gz \
|
|
/tmp/inbuxa install --domain example.test --console host --webmail host --proxy snippets --install-deps --yes 2>&1)"; rc=$?
|
|
[ $rc -eq 0 ] && ok "installed (exit 0)" || { bad "install exit $rc"; echo "$OUT" | tail -8 | sed 's/^/ /'; }
|
|
OLDW=$(cat $DIR/webmail/VERSION)
|
|
echo " webmail $OLDW, console $(awk '{print $2}' $DIR/console/.inbuxa-release)"
|
|
|
|
echo
|
|
echo "==> upgrading"
|
|
DRY="$(/tmp/inbuxa upgrade --dry-run 2>&1)"
|
|
grep -q "console.*local -> " <<<"$DRY" && grep -q "webmail.*-> " <<<"$DRY" && ok "the dry run shows both to move" || { bad "dry run"; echo "$DRY" | sed 's/^/ /'; }
|
|
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"
|
|
NEWW=$(cat $DIR/webmail/VERSION)
|
|
[ "$NEWW" != "$OLDW" ] && ok "the webmail's files are $NEWW" || bad "the webmail's files are still $OLDW"
|
|
curl -fsS http://127.0.0.1:8080/api/health | grep -q "\"version\":\"$NEWW\"" && ok "and it answers as $NEWW" || bad "it doesn't answer as $NEWW"
|
|
grep -q "^IHASMAIL_VERSION=$NEWW$" $DIR/webmail.env && ok "its environment says so" || bad "webmail.env still says $(grep IHASMAIL_VERSION $DIR/webmail.env)"
|
|
[ "$(stat -c %U $DIR/webmail/server/dist/index.js)" = root ] && ok "its files are still root's" || bad "owner changed"
|
|
grep -q 'name="api-base-url" content="https://mail.example.test"' $DIR/console/index.html && ok "the console is still pointed at the server" || bad "the console lost the server's address"
|
|
[ "$(awk '{print $2}' $DIR/console/.inbuxa-release)" != local ] && ok "the console is release $(awk '{print $2}' $DIR/console/.inbuxa-release)" || bad "the console is still the local tarball"
|
|
[ ! -e $DIR/console.prev ] && [ ! -e $DIR/webmail.prev ] && ok "no previous copies left behind" || bad "a .prev directory was left"
|
|
|
|
echo
|
|
echo "==> $pass passed, $fail failed"
|
|
[ "$fail" -eq 0 ]
|