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.).
23 lines
688 B
Bash
23 lines
688 B
Bash
#!/bin/bash
|
|
# ServerManager Agent Uninstaller
|
|
set -e
|
|
|
|
AGENT_BIN="/usr/local/bin/servermanager-agent"
|
|
CONFIG_DIR="/etc/servermanager"
|
|
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 2>/dev/null || true
|
|
|
|
echo "[2/3] Removing files..."
|
|
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 2>/dev/null || true
|
|
|
|
echo "ServerManager Agent uninstalled successfully."
|