From 4043a33b33bb0493437e74fe0827cda42f3b72b3 Mon Sep 17 00:00:00 2001 From: dysf888 <47450409+dysf888@users.noreply.github.com> Date: Tue, 10 May 2022 12:37:30 +0800 Subject: [PATCH 1/2] =?UTF-8?q?Win=E9=87=8D=E5=A4=8D=E8=BF=90=E8=A1=8C?= =?UTF-8?q?=E8=87=AA=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 判断C:/nezha文件夹是否存在 --- script/install.ps1 | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/script/install.ps1 b/script/install.ps1 index f685c38..b6aac6d 100644 --- a/script/install.ps1 +++ b/script/install.ps1 @@ -10,6 +10,14 @@ else { $file = "nezha-agent_windows_386.zip" } $releases = "https://api.github.com/repos/$repo/releases" +#重复运行自动更新 +if (Test-Path "C:\nezha") { + Write-Host "Nezha monitoring already exists, delete and reinstall" -BackgroundColor DarkGreen -ForegroundColor White + C:/nezha/nssm.exe stop nezha + C:/nezha/nssm.exe remove nezha + Remove-Item "C:\nezha" -Recurse +} +#TLS/SSL Write-Host "Determining latest nezha release" -BackgroundColor DarkGreen -ForegroundColor White [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 $tag = (Invoke-WebRequest -Uri $releases -UseBasicParsing | ConvertFrom-Json)[0].tag_name From 813d0b42826a2760da6efcde80412f47fcf51b5a Mon Sep 17 00:00:00 2001 From: dysf888 <47450409+dysf888@users.noreply.github.com> Date: Tue, 10 May 2022 12:56:37 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=98=A5fix=E6=94=B9=E5=90=8D=E5=BC=95?= =?UTF-8?q?=E8=B5=B7=E7=9A=84=E8=87=AA=E6=9B=B4=E6=96=B0=E5=A4=B1=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix改名引起的自更新失效 --- script/install.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/script/install.ps1 b/script/install.ps1 index b6aac6d..dae762e 100644 --- a/script/install.ps1 +++ b/script/install.ps1 @@ -47,7 +47,7 @@ Expand-Archive "C:\nezha.zip" -DestinationPath "C:\temp" -Force Expand-Archive "C:\nssm.zip" -DestinationPath "C:\temp" -Force if (!(Test-Path "C:\nezha")) { New-Item -Path "C:\nezha" -type directory } #整理文件 -Move-Item -Path "C:\temp\nezha-agent.exe" -Destination "C:\nezha\nezha.exe" +Move-Item -Path "C:\temp\nezha-agent.exe" -Destination "C:\nezha\nezha-agent.exe" if ($file = "nezha-agent_windows_amd64.zip") { Move-Item -Path "C:\temp\nssm-2.24\win64\nssm.exe" -Destination "C:\nezha\nssm.exe" } @@ -59,7 +59,7 @@ Remove-Item "C:\nezha.zip" Remove-Item "C:\nssm.zip" Remove-Item "C:\temp" -Recurse #安装部分 -C:\nezha\nssm.exe install nezha C:\nezha\nezha.exe -s $server -p $key -d +C:\nezha\nssm.exe install nezha C:\nezha\nezha-agent.exe -s $server -p $key -d C:\nezha\nssm.exe start nezha #enjoy Write-Host "Enjoy It!" -BackgroundColor DarkGreen -ForegroundColor Red