Files
lightOps/scripts/uninstall-agent.sh

28 lines
681 B
Bash
Executable File

#!/usr/bin/env sh
set -eu
if [ "$(id -u)" -ne 0 ]; then
echo "请使用 root 用户运行" >&2
exit 1
fi
PURGE="0"
while [ "$#" -gt 0 ]; do
case "$1" in
--purge) PURGE="1"; shift 1 ;;
*) echo "未知参数:$1" >&2; exit 1 ;;
esac
done
systemctl disable --now lightops-agent 2>/dev/null || true
rm -f /etc/systemd/system/lightops-agent.service
systemctl daemon-reload
rm -f /usr/local/bin/lightops-agent
rm -f /usr/local/bin/lightops-agent.bak.*
if [ "$PURGE" = "1" ]; then
rm -rf /etc/lightops
echo "LightOps Agent 已卸载,配置已清理"
else
echo "LightOps Agent 已卸载,配置保留在 /etc/lightops。需要完全清理请追加 --purge"
fi