summaryrefslogtreecommitdiffstats
path: root/packaging/rpm/meshbay-node.spec
diff options
context:
space:
mode:
authorChristophe Besson <cbesson@gmail.com>2026-10-01 17:04:21 +0200
committerChristophe Besson <cbesson@gmail.com>2026-10-01 17:04:21 +0200
commitfee265e0046e85c3db0e5bb9608b666d2e9547ab (patch)
tree11eb8906fd3dc6f193eaf91cf98b6d7d0bedc5a5 /packaging/rpm/meshbay-node.spec
parent03f560bb4aaeda0e06c95684c187a394593c88e3 (diff)
downloadmeshbay-fee265e0046e85c3db0e5bb9608b666d2e9547ab.tar.gz
fix(packaging): an upgrade reloads every user's systemd and restarts a running node
The node runs as a user service; the system-wide daemon-reload did not reach the user managers, so systemctl warned that the unit had changed and the old code kept running until restarted by hand. The deb postinst and the rpm %posttrans reload each running user manager and try-restart the node there (and any meshbay-node@ instance) on an upgrade. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'packaging/rpm/meshbay-node.spec')
-rw-r--r--packaging/rpm/meshbay-node.spec34
1 files changed, 34 insertions, 0 deletions
diff --git a/packaging/rpm/meshbay-node.spec b/packaging/rpm/meshbay-node.spec
index 1ba7f26..9b9c6bf 100644
--- a/packaging/rpm/meshbay-node.spec
+++ b/packaging/rpm/meshbay-node.spec
@@ -35,6 +35,40 @@ if [ -d /run/systemd/system ]; then
systemctl daemon-reload || true
fi
+# After the whole transaction, so that meshbay-common is in place too. A
+# marker left by %pre says whether this was an upgrade.
+%pre
+if [ "$1" -ge 2 ]; then
+ touch /run/meshbay-node-upgrade 2>/dev/null || true
+fi
+
+%posttrans
+# The node runs as a user service, in every signed-in user's own systemd
+# manager: the system-wide reload does not reach those, and each would keep
+# the old unit and the old code until restarted by hand. Every running user
+# manager reloads, and restarts the node where it was running.
+reload_user_managers() {
+ for bus in /run/user/*/systemd/private; do
+ [ -S "$bus" ] || continue
+ uid=$(basename "$(dirname "$(dirname "$bus")")")
+ user=$(id -nu "$uid" 2>/dev/null) || continue
+ systemctl --user -M "$user@" daemon-reload 2>/dev/null || true
+ [ -n "$upgraded" ] && systemctl --user -M "$user@" try-restart meshbay-node.service 2>/dev/null || true
+ done
+}
+upgraded=
+if [ -e /run/meshbay-node-upgrade ]; then
+ upgraded=1
+ rm -f /run/meshbay-node-upgrade
+fi
+if [ -d /run/systemd/system ]; then
+ systemctl daemon-reload || true
+ if [ -n "$upgraded" ]; then
+ systemctl try-restart 'meshbay-node@*.service' 2>/dev/null || true
+ fi
+ reload_user_managers
+fi
+
%preun
if [ -d /run/systemd/system ]; then
systemctl daemon-reload || true