diff --git a/internal/web/register/quick.sh.tmpl b/internal/web/register/quick.sh.tmpl index 6385323..886ed64 100644 --- a/internal/web/register/quick.sh.tmpl +++ b/internal/web/register/quick.sh.tmpl @@ -193,13 +193,19 @@ install_agent() { fi echo "Installing vetting-reporter service..." install -d /etc/vetting /usr/local/bin - if ! curl -fsSL "${ORCH_URL}/assets/vetting-agent-linux-amd64" \ - -o /usr/local/bin/vetting-agent; then + # Download to a staging path, then use `install` — it unlinks the + # target before writing, so re-running quick.sh on a host where + # vetting-reporter is already running doesn't hit ETXTBSY + # (curl error 23: write error on a busy executable). + local staged="/usr/local/bin/.vetting-agent.new" + if ! curl -fsSL "${ORCH_URL}/assets/vetting-agent-linux-amd64" -o "${staged}"; then echo "WARN: could not download agent from ${ORCH_URL}/assets/vetting-agent-linux-amd64" echo "WARN: registration succeeded but the host won't heartbeat." + rm -f "${staged}" return fi - chmod +x /usr/local/bin/vetting-agent + install -m 0755 "${staged}" /usr/local/bin/vetting-agent + rm -f "${staged}" cat >/etc/vetting/host-agent.yaml <