Add build-windows: compile upterm from source via Go, no Scoop needed
This commit is contained in:
116
build-windows.ps1
Normal file
116
build-windows.ps1
Normal file
@ -0,0 +1,116 @@
|
|||||||
|
# TLS aktivieren
|
||||||
|
[Net.ServicePointManager]::SecurityProtocol = `
|
||||||
|
[Net.SecurityProtocolType]::Tls12 -bor `
|
||||||
|
[Net.SecurityProtocolType]::Tls11 -bor `
|
||||||
|
[Net.SecurityProtocolType]::Tls
|
||||||
|
|
||||||
|
# Adminrechte pruefen und ggf. neu starten
|
||||||
|
$isAdmin = ([Security.Principal.WindowsPrincipal] `
|
||||||
|
[Security.Principal.WindowsIdentity]::GetCurrent() `
|
||||||
|
).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
|
||||||
|
|
||||||
|
if (-not $isAdmin) {
|
||||||
|
Start-Process powershell.exe `
|
||||||
|
"-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" `
|
||||||
|
-Verb RunAs
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host "============================================================"
|
||||||
|
Write-Host " upterm Build-Setup (Go from Source)"
|
||||||
|
Write-Host "============================================================"
|
||||||
|
Write-Host ""
|
||||||
|
|
||||||
|
# Hilfsfunktion: Datei herunterladen mit SSL-Bypass-Fallback
|
||||||
|
function Download-File($url, $dest) {
|
||||||
|
try {
|
||||||
|
(New-Object System.Net.WebClient).DownloadFile($url, $dest)
|
||||||
|
return $true
|
||||||
|
} catch {}
|
||||||
|
Write-Host " Standard-Download fehlgeschlagen, versuche SSL-Bypass..."
|
||||||
|
$cb = [Net.ServicePointManager]::ServerCertificateValidationCallback
|
||||||
|
[Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}
|
||||||
|
try {
|
||||||
|
(New-Object System.Net.WebClient).DownloadFile($url, $dest)
|
||||||
|
return $true
|
||||||
|
} catch {
|
||||||
|
Write-Host "FEHLER: Download fehlgeschlagen: $_"
|
||||||
|
return $false
|
||||||
|
} finally {
|
||||||
|
[Net.ServicePointManager]::ServerCertificateValidationCallback = $cb
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# 1. Go pruefen / installieren
|
||||||
|
Write-Host "[1/3] Pruefe Go..."
|
||||||
|
$goExe = "C:\Go\bin\go.exe"
|
||||||
|
if (-not (Test-Path $goExe)) {
|
||||||
|
$goVersion = "1.22.4"
|
||||||
|
$goMsi = "$env:TEMP\go-installer.msi"
|
||||||
|
$goUrl = "https://golang.org/dl/go$goVersion.windows-amd64.msi"
|
||||||
|
|
||||||
|
Write-Host " Go nicht gefunden - lade go$goVersion herunter..."
|
||||||
|
if (-not (Download-File $goUrl $goMsi)) {
|
||||||
|
Read-Host "Enter zum Beenden"; exit 1
|
||||||
|
}
|
||||||
|
Write-Host " Installiere Go (MSI silent)..."
|
||||||
|
$p = Start-Process msiexec.exe -ArgumentList "/i `"$goMsi`" /quiet /norestart" `
|
||||||
|
-Wait -PassThru
|
||||||
|
if ($p.ExitCode -ne 0) {
|
||||||
|
Write-Host "FEHLER: Go-Installation fehlgeschlagen (Exit $($p.ExitCode))."
|
||||||
|
Read-Host "Enter zum Beenden"; exit 1
|
||||||
|
}
|
||||||
|
Remove-Item $goMsi -ErrorAction SilentlyContinue
|
||||||
|
}
|
||||||
|
|
||||||
|
# Go in PATH dieser Session
|
||||||
|
if ($env:PATH -notlike "*C:\Go\bin*") {
|
||||||
|
$env:PATH = "$env:PATH;C:\Go\bin"
|
||||||
|
}
|
||||||
|
$goVer = & "$goExe" version 2>&1
|
||||||
|
Write-Host " OK ($goVer)"
|
||||||
|
|
||||||
|
# 2. upterm bauen via go install
|
||||||
|
Write-Host "[2/3] Baue upterm (go install)..."
|
||||||
|
$env:GOPATH = "$env:USERPROFILE\go"
|
||||||
|
if ($env:PATH -notlike "*$env:GOPATH\bin*") {
|
||||||
|
$env:PATH = "$env:PATH;$env:GOPATH\bin"
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
& "$goExe" install github.com/owenthereal/upterm/cmd/upterm@latest
|
||||||
|
} catch {
|
||||||
|
Write-Host "FEHLER: go install fehlgeschlagen: $_"
|
||||||
|
Read-Host "Enter zum Beenden"; exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
$uptermExe = "$env:USERPROFILE\go\bin\upterm.exe"
|
||||||
|
if (-not (Test-Path $uptermExe)) {
|
||||||
|
Write-Host "FEHLER: upterm.exe nicht gefunden nach Build."
|
||||||
|
Read-Host "Enter zum Beenden"; exit 1
|
||||||
|
}
|
||||||
|
Write-Host " OK ($uptermExe)"
|
||||||
|
|
||||||
|
# 3. Binary systemweit verfuegbar machen
|
||||||
|
Write-Host "[3/3] Kopiere upterm.exe nach C:\Windows\System32..."
|
||||||
|
try {
|
||||||
|
Copy-Item $uptermExe "C:\Windows\System32\upterm.exe" -Force
|
||||||
|
Write-Host " OK - upterm steht allen Nutzern zur Verfuegung"
|
||||||
|
} catch {
|
||||||
|
Write-Host " Hinweis: Kopieren fehlgeschlagen - upterm ist nur unter:"
|
||||||
|
Write-Host " $uptermExe"
|
||||||
|
Write-Host " verfuegbar (PATH-Eintrag manuell noetig)"
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host "============================================================"
|
||||||
|
Write-Host " Build abgeschlossen!"
|
||||||
|
Write-Host "============================================================"
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host " PowerShell NEU STARTEN, dann Session teilen mit:"
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host " upterm host --server ssh://upterm.ebesch.de:2222 --accept"
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host " Client verbindet sich mit:"
|
||||||
|
Write-Host " ssh TOKEN:HASH@upterm.ebesch.de -p 2222"
|
||||||
|
Write-Host ""
|
||||||
|
Read-Host "Enter zum Beenden"
|
||||||
Reference in New Issue
Block a user