From 6ca6f34577bb61cd1655ef7922c8de6b36dee420 Mon Sep 17 00:00:00 2001 From: rcourtman Date: Mon, 15 Dec 2025 04:03:06 +0000 Subject: [PATCH] fix(agent): stop running agent before TrueNAS reinstall to avoid "text file busy" On TrueNAS, the runtime binary may be in /root/bin or /var/tmp while the install script only checked INSTALL_DIR (/data/pulse-agent). This left the running process using the binary when the script tried to copy a new version, causing "Text file busy" errors. Now explicitly stop the service and kill any pulse-agent processes before modifying binaries on TrueNAS systems. Related to #846 --- scripts/install.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/scripts/install.sh b/scripts/install.sh index 8a14f7f82..39e8ea015 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -839,6 +839,20 @@ fi if [[ "$TRUENAS" == true ]]; then log_info "Configuring TrueNAS SCALE installation..." + # Stop any existing agent before we modify binaries + # The runtime binary may be in /root/bin or /var/tmp, not just INSTALL_DIR + if systemctl is-active --quiet "${AGENT_NAME}" 2>/dev/null; then + log_info "Stopping existing ${AGENT_NAME} service..." + systemctl stop "${AGENT_NAME}" 2>/dev/null || true + sleep 2 + fi + # Kill any remaining pulse-agent processes (may be running from different paths) + pkill -9 -f "pulse-agent" 2>/dev/null || true + sleep 1 + # Remove old runtime binaries that may be "text file busy" + rm -f /root/bin/pulse-agent 2>/dev/null || true + rm -f /var/tmp/pulse-agent 2>/dev/null || true + # Create directories mkdir -p "$TRUENAS_STATE_DIR" mkdir -p "$TRUENAS_LOG_DIR"