fix(install): stop a running host agent before upgrading it (#365)

Re-running the install command on a host that runs the agent failed:
onboarding refuses to race the agent holding the host lock. The
installer now stops `nestri-host.service` first; onboarding starts it
again on the new binary.
This commit is contained in:
Wanjohi
2026-10-07 16:09:11 +00:00
committed by GitHub
+11
View File
@@ -100,6 +100,17 @@ mv "$TMP/$ASSET" "$BIN_DIR/nestri-host"
say "Installed $BIN_DIR/nestri-host"
say ""
# --- upgrade ----------------------------------------------------------------
# On a host that already runs the agent, this is an upgrade: the agent holds
# the host lock, and onboarding refuses to race it. Stopped here, and started
# again by onboarding on the new binary. A host with nothing running is
# unaffected.
if command -v systemctl >/dev/null 2>&1 &&
systemctl --user is-active --quiet nestri-host.service 2>/dev/null; then
say "Stopping the running host agent to upgrade it…"
systemctl --user stop nestri-host.service
fi
# --- onboard ----------------------------------------------------------------
# The token goes through the environment rather than argv, so it is not in
# `ps` for the length of the run.