From 0dfc7538f0dc5320601d9cd282de810763bcd91b Mon Sep 17 00:00:00 2001 From: Pulse Monitor Date: Wed, 20 Aug 2025 16:00:36 +0000 Subject: [PATCH] fix: stop service before updating binary to avoid 'Text file busy' error Move service stop to happen before attempting to copy the binary file. This prevents the error when the binary is still in use by the running service. Added 2-second delay to ensure process fully releases the file. --- install.sh | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/install.sh b/install.sh index 36033ad8e..752af3e03 100755 --- a/install.sh +++ b/install.sh @@ -224,21 +224,20 @@ download_pulse() { DOWNLOAD_URL="https://github.com/$GITHUB_REPO/releases/download/$LATEST_RELEASE/pulse-${LATEST_RELEASE}-linux-${PULSE_ARCH}.tar.gz" print_info "Downloading from: $DOWNLOAD_URL" + # Detect and stop existing service BEFORE downloading (to free the binary) + EXISTING_SERVICE=$(detect_service_name) + if systemctl is-active --quiet $EXISTING_SERVICE; then + print_info "Stopping existing Pulse service ($EXISTING_SERVICE)..." + systemctl stop $EXISTING_SERVICE + sleep 2 # Give the process time to fully stop and release the binary + fi + cd /tmp if ! wget -q -O pulse.tar.gz "$DOWNLOAD_URL"; then print_error "Failed to download Pulse release" exit 1 fi - # Detect existing service name - EXISTING_SERVICE=$(detect_service_name) - - # Stop service if running (for updates) - if systemctl is-active --quiet $EXISTING_SERVICE; then - print_info "Stopping existing Pulse service ($EXISTING_SERVICE)..." - systemctl stop $EXISTING_SERVICE - fi - # Extract to temporary directory first TEMP_EXTRACT="/tmp/pulse-extract-$$" mkdir -p "$TEMP_EXTRACT"