diff --git a/agent/install.ps1 b/agent/install.ps1 index 778383c..7b83990 100644 --- a/agent/install.ps1 +++ b/agent/install.ps1 @@ -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 diff --git a/agent/install.sh b/agent/install.sh index 9925e6a..00ecbdc 100644 --- a/agent/install.sh +++ b/agent/install.sh @@ -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