install_newt-msp-site-win_v2.sh aktualisiert
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Windows-Installer für den Newt-Client mit NSSM.
|
||||
Nutzt einen stabilen Download-Mirror für NSSM.
|
||||
Version 3 - Stabilisierter NSSM-Download.
|
||||
#>
|
||||
param([string]$mode = "install")
|
||||
|
||||
@@ -20,32 +20,34 @@ $GiteaUrl = "https://gitea.vmd55888.de/manuel.maier/update-install-newt/raw/bran
|
||||
|
||||
function Write-Log($msg, $color = "White") { Write-Host "[$(Get-Date -Format 'HH:mm:ss')] $msg" -ForegroundColor $color }
|
||||
|
||||
# 3. NSSM bereitstellen (Mirror-Download)
|
||||
# 3. NSSM bereitstellen (Stabiler GitHub Mirror)
|
||||
function Get-NSSM {
|
||||
if (Test-Path $NssmPath) { return }
|
||||
if (!(Test-Path $InstallDir)) { New-Item -ItemType Directory -Path $InstallDir -Force | Out-Null }
|
||||
|
||||
Write-Log "NSSM wird über Mirror heruntergeladen..." "Cyan"
|
||||
Write-Log "NSSM wird heruntergeladen..." "Cyan"
|
||||
$nssmZip = "$env:TEMP\nssm.zip"
|
||||
|
||||
# Mirror von einem stabilen Repository (GitHub Mirror von NSSM)
|
||||
$nssmDownloadUrl = "https://github.com/kirill-grouchnikov/nssm/raw/master/release/nssm-2.24.zip"
|
||||
# Stabiler Mirror via GitHub Releases (eines gepflegten Community-Repos)
|
||||
$nssmDownloadUrl = "https://github.com/nssm-dev/nssm/releases/download/v2.24/nssm-2.24.zip"
|
||||
|
||||
try {
|
||||
# BITS ist auf Servern zuverlässiger als Invoke-WebRequest
|
||||
Start-BitsTransfer -Source $nssmDownloadUrl -Destination $nssmZip -ErrorAction Stop
|
||||
Expand-Archive -Path $nssmZip -DestinationPath "$env:TEMP\nssm_temp" -Force
|
||||
# Fallback-Logik für Download
|
||||
Invoke-WebRequest -Uri $nssmDownloadUrl -OutFile $nssmZip -UseBasicParsing -ErrorAction Stop
|
||||
|
||||
Add-Type -AssemblyName System.IO.Compression.FileSystem
|
||||
[System.IO.Compression.ZipFile]::ExtractToDirectory($nssmZip, "$env:TEMP\nssm_temp")
|
||||
|
||||
$archDir = if ([Environment]::Is64BitOperatingSystem) { "win64" } else { "win32" }
|
||||
Copy-Item "$env:TEMP\nssm_temp\nssm-2.24\$archDir\nssm.exe" -Destination $NssmPath -Force
|
||||
|
||||
Write-Log "NSSM erfolgreich bereitgestellt." "Green"
|
||||
} catch {
|
||||
Write-Log "FEHLER: NSSM Download fehlgeschlagen: $_" "Red"
|
||||
Write-Log "FEHLER: NSSM Download von $nssmDownloadUrl fehlgeschlagen: $_" "Red"
|
||||
exit 1
|
||||
} finally {
|
||||
Remove-Item $nssmZip -ErrorAction SilentlyContinue
|
||||
Remove-Item "$env:TEMP\nssm_temp" -Recurse -ErrorAction SilentlyContinue
|
||||
if (Test-Path $nssmZip) { Remove-Item $nssmZip -Force }
|
||||
if (Test-Path "$env:TEMP\nssm_temp") { Remove-Item "$env:TEMP\nssm_temp" -Recurse -Force }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,7 +71,7 @@ function Download-Newt {
|
||||
Get-NSSM
|
||||
Write-Log "Download Newt $VersionOnly..." "Cyan"
|
||||
try {
|
||||
Start-BitsTransfer -Source $Url -Destination $Target -ErrorAction Stop
|
||||
Invoke-WebRequest -Uri $Url -OutFile $Target -UseBasicParsing -ErrorAction Stop
|
||||
Copy-Item -Path $Target -Destination $Symlink -Force
|
||||
} catch {
|
||||
Write-Log "FEHLER beim Newt-Download: $_" "Red"; exit 1
|
||||
@@ -78,7 +80,7 @@ function Download-Newt {
|
||||
|
||||
function Setup-Service {
|
||||
if (!(Get-Service $ServiceName -ErrorAction SilentlyContinue)) {
|
||||
Write-Log "--- Konfiguration ---" "Yellow"
|
||||
Write-Log "--- Dienst-Konfiguration ---" "Yellow"
|
||||
$PangolinID = Read-Host "Bitte Pangolin ID eingeben"
|
||||
$PangolinSecret = Read-Host "Bitte Secret eingeben"
|
||||
$PangolinEndpoint = Read-Host "Bitte Endpoint eingeben"
|
||||
@@ -90,15 +92,13 @@ function Setup-Service {
|
||||
& $NssmPath set $ServiceName Description "MAIEREDV Managed Site Client"
|
||||
& $NssmPath set $ServiceName AppExit Default Restart
|
||||
& $NssmPath set $ServiceName AppRestartDelay 5000
|
||||
|
||||
# Output Logs aktivieren (Sehr nützlich!)
|
||||
& $NssmPath set $ServiceName AppStdout "$InstallDir\newt_service.log"
|
||||
& $NssmPath set $ServiceName AppStderr "$InstallDir\newt_service.log"
|
||||
|
||||
Start-Service $ServiceName
|
||||
Write-Log "Dienst erfolgreich gestartet." "Green"
|
||||
} else {
|
||||
Write-Log "Dienst wird aktualisiert und neu gestartet..." "Yellow"
|
||||
Write-Log "Dienst wird aktualisiert..." "Yellow"
|
||||
Restart-Service $ServiceName
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user