| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
set -euo pipefail |
| 24 |
|
| 25 |
BARE="${SANDO_UPSTREAM_URL:-/srv/sando/mnw.git}" |
| 26 |
BRANCH="${SANDO_DEPLOY_BRANCH:-main}" |
| 27 |
TOPOLOGY="${SANDO_TOPOLOGY:-/etc/sando/sando.toml}" |
| 28 |
|
| 29 |
[[ -f "$TOPOLOGY" ]] || { echo "check-topology-drift: no live topology at $TOPOLOGY" >&2; exit 2; } |
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
if ! REPO_COPY="$(git -C "$BARE" show "$BRANCH:sando/sando.toml" 2>/dev/null)"; then |
| 36 |
echo "check-topology-drift: cannot read $BRANCH:sando/sando.toml from $BARE" >&2 |
| 37 |
exit 2 |
| 38 |
fi |
| 39 |
|
| 40 |
if diff -u --label "$BARE ($BRANCH)" --label "$TOPOLOGY" <(printf '%s\n' "$REPO_COPY") "$TOPOLOGY"; then |
| 41 |
echo "check-topology-drift: live topology matches $BRANCH" |
| 42 |
exit 0 |
| 43 |
fi |
| 44 |
|
| 45 |
cat >&2 <<'MSG' |
| 46 |
|
| 47 |
check-topology-drift: the live topology and the repo have separated. |
| 48 |
|
| 49 |
Fix it by shipping, not by editing the live file: push the intended topology to |
| 50 |
main and trigger a sandod self-update, which installs it. Hand-editing |
| 51 |
/etc/sando/sando.toml is what this check exists to catch. |
| 52 |
MSG |
| 53 |
exit 1 |
| 54 |
|