feat: command to uninstall all agent services (#30)

* feat: command to uninstall all agent services

* fix: file extension
This commit is contained in:
UUBulb
2024-12-05 17:07:05 +08:00
committed by GitHub
parent 3d31005c61
commit 7ed0dda9dc
2 changed files with 19 additions and 3 deletions

View File

@ -5,6 +5,7 @@ NZ_AGENT_PATH="${NZ_BASE_PATH}/agent"
red='\033[0;31m'
green='\033[0;32m'
yellow='\033[0;33m'
plain='\033[0m'
err() {
@ -15,6 +16,10 @@ success() {
printf "${green}%s${plain}\n" "$*"
}
info() {
printf "${yellow}%s${plain}\n" "$*"
}
sudo() {
myEUID=$(id -ru)
if [ "$myEUID" -ne 0 ]; then
@ -176,5 +181,18 @@ install() {
success "nezha-agent successfully installed"
}
uninstall() {
find "$NZ_AGENT_PATH" -type f -name "*config*.yml" | while read -r file; do
sudo "$NZ_AGENT_PATH/nezha-agent" service -c "$file" uninstall
sudo rm "$file"
done
info "Uninstallation completed."
}
if [ "$1" = "uninstall" ]; then
uninstall
exit
fi
init
install