From 5d7d466df8fe5981234e4685bcc46fedfc31e0e5 Mon Sep 17 00:00:00 2001 From: "manuel.maier" Date: Wed, 18 Feb 2026 10:35:32 +0100 Subject: [PATCH] =?UTF-8?q?install=5Fnewt-msp-site-win=5Fv2.sh=20hinzugef?= =?UTF-8?q?=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- install_newt-msp-site-win_v2.sh | 70 +++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 install_newt-msp-site-win_v2.sh diff --git a/install_newt-msp-site-win_v2.sh b/install_newt-msp-site-win_v2.sh new file mode 100644 index 0000000..28de0df --- /dev/null +++ b/install_newt-msp-site-win_v2.sh @@ -0,0 +1,70 @@ +$Repo = "fosrl/newt" +$InstallDir = "C:\Program Files\me-msp-newt" +$ServiceName = "MAIEREDV-Managed-Site-Client" +$Symlink = "$InstallDir\newt_latest.exe" + +# 1. Latest Version holen +function Get-LatestVersion { + $url = "https://api.github.com/repos/$Repo/releases/latest" + $json = Invoke-RestMethod -Uri $url + return $json.tag_name.TrimStart('v') +} + +# 2. Download & Symlink (Copy) +function Install-Newt { + param($Version) + $Arch = if ([Environment]::Is64BitOperatingSystem) { "newt_windows_amd64.exe" } else { "newt_windows_386.exe" } + $Url = "https://github.com/$Repo/releases/download/v$Version/$Arch" + $Target = "$InstallDir\newt_$Version.exe" + + if (!(Test-Path $InstallDir)) { New-Item -ItemType Directory -Path $InstallDir } + + Write-Host "⬇️ Downloading $Url..." -ForegroundColor Cyan + Invoke-WebRequest -Uri $Url -OutFile "$Target" + + # "Symlink" unter Windows ist zickig, wir kopieren einfach zur 'latest' + Copy-Item -Path $Target -Destination $Symlink -Force + Write-Host "✅ Installed version $Version" -ForegroundColor Green +} + +# 3. Dienst nativ erstellen +function Setup-Service { + $PangolinID = Read-Host "ID" + $Secret = Read-Host "Secret" -AsSecureString + $Endpoint = Read-Host "Endpoint" + + $BSTR = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($Secret) + $PlainSecret = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($BSTR) + + $Args = "--id $PangolinID --secret $PlainSecret --endpoint $Endpoint" + + # Prüfen ob Dienst existiert, sonst erstellen + if (Get-Service $ServiceName -ErrorAction SilentlyContinue) { + Stop-Service $ServiceName + $service = Get-CimInstance Win32_Service -Filter "Name='$ServiceName'" + $service.Change($null, $null, $null, $null, $null, "$Symlink $Args") + } else { + New-Service -Name $ServiceName ` + -BinaryPathName "$Symlink $Args" ` + -DisplayName "MAIEREDV Managed Site Client" ` + -StartupType Automatic + } + Start-Service $ServiceName +} + +# 4. Update Task (statt systemd timer) +function Setup-UpdateTask { + $TaskName = "Newt-Updater" + $Action = New-ScheduledTaskAction -Execute "PowerShell.exe" ` + -Argument "-NoProfile -WindowStyle Hidden -Command ""& {Invoke-WebRequest -Uri 'DEINE_URL_ZUM_PS1' | PowerShell}""" + $Trigger = New-ScheduledTaskTrigger -Daily -At 3am + + Register-ScheduledTask -Action $Action -Trigger $Trigger -TaskName $TaskName -User "SYSTEM" -Force + Write-Host "✅ Daily update task created." -ForegroundColor Green +} + +# Main Logic (vereinfacht) +$Latest = Get-LatestVersion +Install-Newt $Latest +Setup-Service +Setup-UpdateTask \ No newline at end of file