mirror of
https://github.com/nezhahq/scripts.git
synced 2025-07-12 13:29:32 +08:00
feat: command to uninstall all agent services (#30)
* feat: command to uninstall all agent services * fix: file extension
This commit is contained in:
parent
3d31005c61
commit
7ed0dda9dc
@ -1,5 +1,3 @@
|
||||
#Get server and key
|
||||
param($server, $key, $tls)
|
||||
# Download latest release from github
|
||||
if($PSVersionTable.PSVersion.Major -lt 5){
|
||||
Write-Host "Require PS >= 5,your PSVersion:"$PSVersionTable.PSVersion.Major -BackgroundColor DarkGreen -ForegroundColor White
|
||||
@ -82,6 +80,6 @@ Move-Item -Path "C:\temp\nezha-agent.exe" -Destination "C:\nezha\nezha-agent.exe
|
||||
Remove-Item "C:\nezha.zip"
|
||||
Remove-Item "C:\temp" -Recurse
|
||||
#安装部分
|
||||
C:\nezha\nezha-agent.exe service install -s $server -p $key $tls
|
||||
C:\nezha\nezha-agent.exe service install
|
||||
#enjoy
|
||||
Write-Host "Enjoy It!" -BackgroundColor DarkGreen -ForegroundColor Red
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user