Fix: use Go ZIP instead of MSI (avoids exit 1603 on Server 2016)
This commit is contained in:
@ -1,10 +1,10 @@
|
|||||||
# TLS aktivieren
|
# TLS aktivieren (Windows Server 2016)
|
||||||
[Net.ServicePointManager]::SecurityProtocol = `
|
[Net.ServicePointManager]::SecurityProtocol = `
|
||||||
[Net.SecurityProtocolType]::Tls12 -bor `
|
[Net.SecurityProtocolType]::Tls12 -bor `
|
||||||
[Net.SecurityProtocolType]::Tls11 -bor `
|
[Net.SecurityProtocolType]::Tls11 -bor `
|
||||||
[Net.SecurityProtocolType]::Tls
|
[Net.SecurityProtocolType]::Tls
|
||||||
|
|
||||||
# Adminrechte pruefen und ggf. neu starten
|
# Adminrechte pruefen
|
||||||
$isAdmin = ([Security.Principal.WindowsPrincipal] `
|
$isAdmin = ([Security.Principal.WindowsPrincipal] `
|
||||||
[Security.Principal.WindowsIdentity]::GetCurrent() `
|
[Security.Principal.WindowsIdentity]::GetCurrent() `
|
||||||
).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
|
).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
|
||||||
@ -21,13 +21,13 @@ Write-Host " upterm Build-Setup (Go from Source)"
|
|||||||
Write-Host "============================================================"
|
Write-Host "============================================================"
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
|
|
||||||
# Hilfsfunktion: Datei herunterladen mit SSL-Bypass-Fallback
|
# Hilfsfunktion: Download mit SSL-Bypass-Fallback
|
||||||
function Download-File($url, $dest) {
|
function Download-File($url, $dest) {
|
||||||
try {
|
try {
|
||||||
(New-Object System.Net.WebClient).DownloadFile($url, $dest)
|
(New-Object System.Net.WebClient).DownloadFile($url, $dest)
|
||||||
return $true
|
return $true
|
||||||
} catch {}
|
} catch {}
|
||||||
Write-Host " Standard-Download fehlgeschlagen, versuche SSL-Bypass..."
|
Write-Host " SSL-Bypass aktiv (Server 2016 Zertifikatskette)..."
|
||||||
$cb = [Net.ServicePointManager]::ServerCertificateValidationCallback
|
$cb = [Net.ServicePointManager]::ServerCertificateValidationCallback
|
||||||
[Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}
|
[Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}
|
||||||
try {
|
try {
|
||||||
@ -41,33 +41,37 @@ function Download-File($url, $dest) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# 1. Go pruefen / installieren
|
# 1. Go pruefen / als ZIP installieren (kein MSI = kein Exit 1603)
|
||||||
Write-Host "[1/3] Pruefe Go..."
|
Write-Host "[1/3] Pruefe Go..."
|
||||||
$goExe = "C:\Go\bin\go.exe"
|
$goRoot = "C:\Go"
|
||||||
|
$goExe = "$goRoot\bin\go.exe"
|
||||||
|
|
||||||
if (-not (Test-Path $goExe)) {
|
if (-not (Test-Path $goExe)) {
|
||||||
$goVersion = "1.22.4"
|
$goVersion = "1.22.4"
|
||||||
$goMsi = "$env:TEMP\go-installer.msi"
|
$goZip = "C:\Windows\Temp\go-windows.zip"
|
||||||
$goUrl = "https://golang.org/dl/go$goVersion.windows-amd64.msi"
|
$goUrl = "https://golang.org/dl/go$goVersion.windows-amd64.zip"
|
||||||
|
|
||||||
Write-Host " Go nicht gefunden - lade go$goVersion herunter..."
|
Write-Host " Go nicht gefunden - lade go$goVersion (ZIP) herunter..."
|
||||||
if (-not (Download-File $goUrl $goMsi)) {
|
if (-not (Download-File $goUrl $goZip)) {
|
||||||
Read-Host "Enter zum Beenden"; exit 1
|
Read-Host "Enter zum Beenden"; exit 1
|
||||||
}
|
}
|
||||||
Write-Host " Installiere Go (MSI silent)..."
|
|
||||||
$p = Start-Process msiexec.exe -ArgumentList "/i `"$goMsi`" /quiet /norestart" `
|
Write-Host " Entpacke nach $goRoot ..."
|
||||||
-Wait -PassThru
|
if (Test-Path $goRoot) { Remove-Item -Recurse -Force $goRoot }
|
||||||
if ($p.ExitCode -ne 0) {
|
Expand-Archive -Path $goZip -DestinationPath "C:\" -Force
|
||||||
Write-Host "FEHLER: Go-Installation fehlgeschlagen (Exit $($p.ExitCode))."
|
Remove-Item $goZip -ErrorAction SilentlyContinue
|
||||||
|
|
||||||
|
if (-not (Test-Path $goExe)) {
|
||||||
|
Write-Host "FEHLER: go.exe nach Entpacken nicht gefunden."
|
||||||
Read-Host "Enter zum Beenden"; exit 1
|
Read-Host "Enter zum Beenden"; exit 1
|
||||||
}
|
}
|
||||||
Remove-Item $goMsi -ErrorAction SilentlyContinue
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Go in PATH dieser Session
|
# Go in PATH dieser Session
|
||||||
if ($env:PATH -notlike "*C:\Go\bin*") {
|
if ($env:PATH -notlike "*$goRoot\bin*") {
|
||||||
$env:PATH = "$env:PATH;C:\Go\bin"
|
$env:PATH = "$env:PATH;$goRoot\bin"
|
||||||
}
|
}
|
||||||
$goVer = & "$goExe" version 2>&1
|
$goVer = & $goExe version 2>&1
|
||||||
Write-Host " OK ($goVer)"
|
Write-Host " OK ($goVer)"
|
||||||
|
|
||||||
# 2. upterm bauen via go install
|
# 2. upterm bauen via go install
|
||||||
@ -77,7 +81,7 @@ if ($env:PATH -notlike "*$env:GOPATH\bin*") {
|
|||||||
$env:PATH = "$env:PATH;$env:GOPATH\bin"
|
$env:PATH = "$env:PATH;$env:GOPATH\bin"
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
& "$goExe" install github.com/owenthereal/upterm/cmd/upterm@latest
|
& $goExe install github.com/owenthereal/upterm/cmd/upterm@latest
|
||||||
} catch {
|
} catch {
|
||||||
Write-Host "FEHLER: go install fehlgeschlagen: $_"
|
Write-Host "FEHLER: go install fehlgeschlagen: $_"
|
||||||
Read-Host "Enter zum Beenden"; exit 1
|
Read-Host "Enter zum Beenden"; exit 1
|
||||||
@ -90,15 +94,14 @@ if (-not (Test-Path $uptermExe)) {
|
|||||||
}
|
}
|
||||||
Write-Host " OK ($uptermExe)"
|
Write-Host " OK ($uptermExe)"
|
||||||
|
|
||||||
# 3. Binary systemweit verfuegbar machen
|
# 3. Systemweit verfuegbar machen
|
||||||
Write-Host "[3/3] Kopiere upterm.exe nach C:\Windows\System32..."
|
Write-Host "[3/3] Kopiere upterm.exe nach C:\Windows\System32..."
|
||||||
try {
|
try {
|
||||||
Copy-Item $uptermExe "C:\Windows\System32\upterm.exe" -Force
|
Copy-Item $uptermExe "C:\Windows\System32\upterm.exe" -Force
|
||||||
Write-Host " OK - upterm steht allen Nutzern zur Verfuegung"
|
Write-Host " OK - upterm steht allen Nutzern zur Verfuegung"
|
||||||
} catch {
|
} catch {
|
||||||
Write-Host " Hinweis: Kopieren fehlgeschlagen - upterm ist nur unter:"
|
Write-Host " Hinweis: Kopieren fehlgeschlagen."
|
||||||
Write-Host " $uptermExe"
|
Write-Host " Binary liegt unter: $uptermExe"
|
||||||
Write-Host " verfuegbar (PATH-Eintrag manuell noetig)"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
|
|||||||
Reference in New Issue
Block a user