#!/usr/bin/env bash # Started by a one-shot systemd timer after an agent update (src/update.ts). If the new agent # hasn't polled the Hub by now, update-pending.json is still there: switch back to the previous # release and restart. Copied to /opt/crosscode/agent/revert.sh by install.sh. set -euo pipefail ROOT=/opt/crosscode/agent PENDING=/var/lib/crosscode-agent/update-pending.json [ -f "$PENDING" ] || exit 0 [ -L "$ROOT/previous" ] || { echo "crosscode-agent revert: no previous release" >&2; exit 1; } ln -sfn "$(readlink "$ROOT/previous")" "$ROOT/current.tmp" mv -T "$ROOT/current.tmp" "$ROOT/current" rm -f "$PENDING" systemctl restart crosscode-agent echo "crosscode-agent revert: the new agent didn't poll in time; back on $(readlink "$ROOT/current")" >&2