From f3bc510d2bbe43e2c361f235f574ce43342daf86 Mon Sep 17 00:00:00 2001 From: Jake Stenger Date: Tue, 21 Jul 2026 07:28:35 -0700 Subject: [PATCH] Fix Linux uninstall script failing with a relative path (#49592) systemd-run runs the detached child as a transient unit with WorkingDirectory=/, so a relative $0 (e.g. ./uninstall-fleetd-linux.sh per the uninstall guide) couldn't be found and the removal silently never ran. Resolve $0 to an absolute path before re-exec. Fixes #49411 ## Summary by CodeRabbit - **Bug Fixes** - Improved the Linux uninstall process so the detached cleanup task always runs from the correct script location. - Enhanced compatibility between systemd-based environments and non-systemd systems. - Better supports script paths that include spaces or special characters. --- it-and-security/lib/linux/scripts/uninstall-fleetd-linux.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/it-and-security/lib/linux/scripts/uninstall-fleetd-linux.sh b/it-and-security/lib/linux/scripts/uninstall-fleetd-linux.sh index 46e156785d..12d8021c17 100755 --- a/it-and-security/lib/linux/scripts/uninstall-fleetd-linux.sh +++ b/it-and-security/lib/linux/scripts/uninstall-fleetd-linux.sh @@ -47,10 +47,11 @@ else # Use systemd-run to spawn the removal process in a separate transient unit. # This ensures the process escapes the orbit.service cgroup, so when # orbit.service is stopped, the removal script continues running. + SCRIPT_PATH="$(readlink -f "$0")" if command -v systemd-run > /dev/null; then - systemd-run --quiet bash "$0" remove + systemd-run --quiet bash "$SCRIPT_PATH" remove else # Fallback for non-systemd systems (rare for modern Linux) - bash -c "bash $0 remove >/dev/null 2>/dev/null /dev/null 2>&1