From f4c534c02015c6c3924f949f0452f2331e7232db Mon Sep 17 00:00:00 2001 From: Agent Date: Thu, 11 Jun 2026 18:48:23 -0400 Subject: [PATCH] fix: always use sudo for agent install (remove fallback check) The sudo -n check was incorrectly detecting that sudo required a password, causing fallback to plain bash without root permissions. Now we always run the installer via sudo bash, consistent with how all other SSH commands work (systemctl, reboot, etc.). --- install/agent-uninstall.sh | 10 +++++----- src/Services/AgentService.php | 4 +--- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/install/agent-uninstall.sh b/install/agent-uninstall.sh index c4ce3ee..e260733 100644 --- a/install/agent-uninstall.sh +++ b/install/agent-uninstall.sh @@ -9,14 +9,14 @@ SERVICE_FILE="/etc/systemd/system/servermanager-agent.service" echo "[1/3] Stopping and disabling service..." systemctl stop servermanager-agent 2>/dev/null || true systemctl disable servermanager-agent 2>/dev/null || true -systemctl daemon-reload +systemctl daemon-reload 2>/dev/null || true echo "[2/3] Removing files..." -rm -f "$AGENT_BIN" -rm -rf "$CONFIG_DIR" -rm -f "$SERVICE_FILE" +rm -f "$AGENT_BIN" 2>/dev/null || true +rm -rf "$CONFIG_DIR" 2>/dev/null || true +rm -f "$SERVICE_FILE" 2>/dev/null || true echo "[3/3] Reloading systemd..." -systemctl daemon-reload +systemctl daemon-reload 2>/dev/null || true echo "ServerManager Agent uninstalled successfully." diff --git a/src/Services/AgentService.php b/src/Services/AgentService.php index a9f0b9b..406ecaf 100644 --- a/src/Services/AgentService.php +++ b/src/Services/AgentService.php @@ -51,11 +51,9 @@ class AgentService $b64 = base64_encode($script); $remoteCommand = sprintf( - 'echo %s | base64 -d | (sudo -n true 2>/dev/null && sudo bash -s -- %s %s || bash -s -- %s %s) 2>&1', + 'echo %s | base64 -d | sudo bash -s -- %s %s 2>&1', escapeshellarg($b64), escapeshellarg($serverUrl), - escapeshellarg($agentKey), - escapeshellarg($serverUrl), escapeshellarg($agentKey) ); -- 2.43.0