mirror of
https://scm.tikali.ai/tikali/applications/monky/monky-deployd.git
synced 2026-09-18 06:56:15 +00:00
4ff2e29fbc
dpkg calls the OLD package's prerm on an UPGRADE as well as on a removal (rpm passes a remaining-instance count), and preremove.sh ran `systemctl disable --now monky-deployd.timer` unconditionally. Upgrading env-dev-01 and env-dev-08 to 0.1.8 today stopped and disabled both agents. The failure is silent, which is the dangerous part: the box stays reachable, the containers keep running, and nothing reports that check-ins have ceased — the backend just stops converging. A fleet upgrade would have taken every agent offline at once and looked like a success. preremove.sh now returns early for every upgrade shape (upgrade, failed-upgrade, deconfigure, rpm's 1) and only disables on a real removal. postinstall.sh try-restarts the long-lived proxy unit so it picks up the new code; the timer needs nothing, since each tick is a fresh process. Tests drive the script with a fake systemctl on PATH and assert an upgrade touches no units. OPERATIONS.md warns that a box coming FROM 0.1.8 or earlier still needs its timer re-enabled by hand, because the old prerm has already run by then. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KLB7jieMNRkTsJ2epr4Ds1
31 lines
1.8 KiB
Bash
Executable File
31 lines
1.8 KiB
Bash
Executable File
#!/bin/sh
|
|
set -e
|
|
# service account + dirs
|
|
if command -v systemd-sysusers >/dev/null 2>&1; then
|
|
systemd-sysusers /usr/lib/sysusers.d/monky-deployd.conf || true
|
|
else
|
|
getent passwd monky-deployd >/dev/null || useradd --system --home-dir /var/lib/monky-deployd --shell /usr/sbin/nologin monky-deployd
|
|
fi
|
|
if command -v systemd-tmpfiles >/dev/null 2>&1; then
|
|
systemd-tmpfiles --create /usr/lib/tmpfiles.d/monky-deployd.conf || true
|
|
fi
|
|
install -d -m 0700 -o monky-deployd -g monky-deployd /var/lib/monky-deployd
|
|
install -d -m 0750 -o root -g monky-deployd /etc/monky-deployd
|
|
# the agent drives docker compose: docker group membership (no root)
|
|
if getent group docker >/dev/null; then usermod -a -G docker monky-deployd || true; fi
|
|
# the agent reads the host's ziti identity (owned by the tunneller, mode 0640). ziti-edge-tunnel
|
|
# REWRITES that file whenever the controller sends a config update, and the rewrite drops any
|
|
# POSIX ACL granting the agent read — group membership is the grant that survives it.
|
|
# (env-dev-08, 2026-09-09: the agent went from applied to "no intercept" 6 minutes after a refresh.)
|
|
if getent group ziti >/dev/null; then usermod -a -G ziti monky-deployd || true; fi
|
|
# the venv is relocatable only to the path it was built at; refuse a broken interpreter early
|
|
/opt/monky-deployd/venv/bin/python -c 'import monky_deployd' || { echo "monky-deployd: venv unusable (python3 mismatch?)" >&2; exit 1; }
|
|
if [ -d /run/systemd/system ]; then
|
|
systemctl daemon-reload || true
|
|
# do NOT enable the timer here: install.sh / the ansible role do it after the config exists.
|
|
# An UPGRADE is different — the timer is already enabled and must keep running, so restart the
|
|
# long-lived proxy unit onto the new code. `try-restart` is a no-op when it is not running.
|
|
systemctl try-restart monky-deployd-proxy.service 2>/dev/null || true
|
|
fi
|
|
exit 0
|