feat: UpdateAgent Selbstaktualisierung & kopflose Installation, .NET 10 Migration, Backend- & SDK-Fixes
- .NET 10 Migration: Alle .NET-Projekte auf net10.0 umgestellt (#459) - Client-SDK: ResolveAgentPath bereinigt und DLL-Pruefung ergaenzt (#458) - Packager: Commit-Ermittlung aus publishDir / Assembly InformationalVersion (#456) - BuildInfo.targets: ExitCode-Abfang und Regex-Validierung gegen Git-Fehlertexte (#363) - UpdateService: Re-Publish erhaelt bestehende Manifeste und Werte (#457) - Bugtracker API: on_roadmap-Filter in manage?action=list durchgereicht (#349) - Watchdog API: project_slug-Filter in GET /status ergaenzt (#420) - UpdateService API: no_release_for_platform mit verfuegbaren Plattformen (#421) - Bugtracker Core: Fehler-Normalisierung gegen zersplitterte error_hashes (#419) - UpdateAgent: Kopfloser Installationsmodus via --answers (#89) - Installer & Agent: Automatische Selbstaktualisierung beim Start - Tooling: AGENTS.md, CLAUDE.md und Standalone-CLI scripts/dc.py hinzugefuegt
This commit is contained in:
@@ -10,11 +10,41 @@
|
||||
Muster, vor dem man Nutzer sonst warnt.
|
||||
#>
|
||||
|
||||
param(
|
||||
[switch] $Check,
|
||||
[switch] $Force
|
||||
)
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
$baseUrl = if ($env:DC_BASE_URL) { $env:DC_BASE_URL.TrimEnd('/') } else { 'https://dc.mhdf.de' }
|
||||
$targetDir = if ($env:DC_INSTALL_DIR) { $env:DC_INSTALL_DIR } else { $PWD.Path }
|
||||
|
||||
function Get-WebContentString([string] $uri, [int] $timeoutSec = 10) {
|
||||
$resp = Invoke-WebRequest -Uri $uri -UseBasicParsing -TimeoutSec $timeoutSec
|
||||
if ($resp.Content -is [byte[]]) {
|
||||
return [System.Text.Encoding]::UTF8.GetString($resp.Content)
|
||||
}
|
||||
return [string]$resp.Content
|
||||
}
|
||||
|
||||
# --------------------------------------------------- Selbstaktualisierung Skript
|
||||
# Falls das Skript als Datei von der Festplatte ausgefuehrt wird, prueft es
|
||||
# sich selbst gegen die Server-Fassung und aktualisiert sich.
|
||||
$scriptPath = $MyInvocation.MyCommand.Path
|
||||
if ($scriptPath -and (Test-Path $scriptPath)) {
|
||||
try {
|
||||
$remoteScript = Get-WebContentString "$baseUrl/installer/install.ps1" 5
|
||||
if ($remoteScript) {
|
||||
$currentScript = Get-Content -Path $scriptPath -Raw
|
||||
if ($remoteScript.Trim() -ne $currentScript.Trim()) {
|
||||
Set-Content -Path $scriptPath -Value $remoteScript -Force
|
||||
Write-Host "Installer-Skript ($scriptPath) wurde selbststaendig aktualisiert." -ForegroundColor Cyan
|
||||
}
|
||||
}
|
||||
} catch { }
|
||||
}
|
||||
|
||||
# ------------------------------------------------------------------ Plattform
|
||||
$arch = [System.Runtime.InteropServices.RuntimeInformation]::ProcessArchitecture
|
||||
|
||||
@@ -28,8 +58,39 @@ switch ($arch) {
|
||||
|
||||
$binary = "update-agent-$rid.exe"
|
||||
$target = Join-Path $targetDir 'update-agent.exe'
|
||||
$temp = Join-Path ([System.IO.Path]::GetTempPath()) ("dc-installer-" + [guid]::NewGuid().ToString('N'))
|
||||
|
||||
# --------------------------------------------------------- Versionsabgleich
|
||||
try {
|
||||
$rawExpected = Get-WebContentString "$baseUrl/installer/$binary.sha256" 10
|
||||
$expected = $rawExpected.Trim().ToLower()
|
||||
} catch {
|
||||
Write-Error "Konnte Pruefsumme von $baseUrl/installer/$binary.sha256 nicht abrufen: $_"
|
||||
return
|
||||
}
|
||||
|
||||
if ((Test-Path $target) -and -not $Force) {
|
||||
$currentHash = (Get-FileHash $target -Algorithm SHA256).Hash.ToLower()
|
||||
if ($currentHash -eq $expected) {
|
||||
Write-Host "Update-Agent ist bereits auf dem neuesten Stand ($target)." -ForegroundColor Green
|
||||
if ($Check) { return }
|
||||
Write-Host ''
|
||||
Write-Host 'Weiter mit:'
|
||||
Write-Host " & '$target' --action install"
|
||||
Write-Host ''
|
||||
Write-Host 'Nur diese Maschine ueberwachen, ohne etwas zu installieren:'
|
||||
Write-Host " & '$target' --action monitor"
|
||||
return
|
||||
} else {
|
||||
Write-Host "Aktualisierung fuer Update-Agent verfuegbar. Lade neue Fassung..." -ForegroundColor Cyan
|
||||
}
|
||||
}
|
||||
|
||||
if ($Check) {
|
||||
Write-Host "Neue Version von $binary ist verfuegbar (SHA256: $expected)."
|
||||
return
|
||||
}
|
||||
|
||||
$temp = Join-Path ([System.IO.Path]::GetTempPath()) ("dc-installer-" + [guid]::NewGuid().ToString('N'))
|
||||
New-Item -ItemType Directory -Path $temp -Force | Out-Null
|
||||
|
||||
try {
|
||||
@@ -37,7 +98,6 @@ try {
|
||||
|
||||
$tempBinary = Join-Path $temp 'agent.exe'
|
||||
Invoke-WebRequest -Uri "$baseUrl/installer/$binary" -OutFile $tempBinary -UseBasicParsing
|
||||
$expected = (Invoke-WebRequest -Uri "$baseUrl/installer/$binary.sha256" -UseBasicParsing).Content.Trim().ToLower()
|
||||
|
||||
# --------------------------------------------------------- Pruefsumme
|
||||
$actual = (Get-FileHash $tempBinary -Algorithm SHA256).Hash.ToLower()
|
||||
|
||||
@@ -14,6 +14,35 @@ set -eu
|
||||
|
||||
BASE_URL="${DC_BASE_URL:-https://dc.mhdf.de}"
|
||||
TARGET_DIR="${DC_INSTALL_DIR:-}"
|
||||
CHECK_ONLY=0
|
||||
FORCE=0
|
||||
|
||||
for arg in "$@"; do
|
||||
case "$arg" in
|
||||
--check|--pruefen) CHECK_ONLY=1 ;;
|
||||
--force) FORCE=1 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
# --------------------------------------------------- Selbstaktualisierung Skript
|
||||
if [ -f "$0" ] && [ "$0" != "sh" ] && [ "$0" != "bash" ]; then
|
||||
if command -v curl >/dev/null 2>&1; then
|
||||
remote_script="$(curl -fsSL "$BASE_URL/installer/install.sh" 2>/dev/null || true)"
|
||||
elif command -v wget >/dev/null 2>&1; then
|
||||
remote_script="$(wget -qO- "$BASE_URL/installer/install.sh" 2>/dev/null || true)"
|
||||
else
|
||||
remote_script=""
|
||||
fi
|
||||
|
||||
if [ -n "$remote_script" ]; then
|
||||
current_script="$(cat "$0")"
|
||||
if [ "$remote_script" != "$current_script" ]; then
|
||||
printf '%s\n' "$remote_script" > "$0"
|
||||
chmod +x "$0" 2>/dev/null || true
|
||||
echo "Installer-Skript ($0) wurde selbststaendig aktualisiert."
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# ---------------------------------------------------------------- Plattform
|
||||
os="$(uname -s)"
|
||||
@@ -62,15 +91,48 @@ fi
|
||||
|
||||
tmp="$(mktemp -d)"
|
||||
# shellcheck disable=SC2064
|
||||
trap "rm -rf '$tmp'" EXIT INT TERM
|
||||
trap 'rm -rf "$tmp"' EXIT INT TERM
|
||||
|
||||
# ------------------------------------------------------------- Pruefsumme abrufen
|
||||
fetch "$BASE_URL/installer/$binary.sha256" "$tmp/agent.sha256"
|
||||
expected="$(tr -d ' \t\r\n' < "$tmp/agent.sha256")"
|
||||
|
||||
# ------------------------------------------------------------- Bestandspruefung
|
||||
if [ -f "$target" ] && [ "$FORCE" -eq 0 ]; then
|
||||
if command -v sha256sum >/dev/null 2>&1; then
|
||||
current_hash="$(sha256sum "$target" | cut -d' ' -f1)"
|
||||
elif command -v shasum >/dev/null 2>&1; then
|
||||
current_hash="$(shasum -a 256 "$target" | cut -d' ' -f1)"
|
||||
else
|
||||
current_hash=""
|
||||
fi
|
||||
|
||||
if [ -n "$current_hash" ] && [ "$current_hash" = "$expected" ]; then
|
||||
echo "Update-Agent ist bereits auf dem neuesten Stand ($target)."
|
||||
if [ "$CHECK_ONLY" -eq 1 ]; then
|
||||
exit 0
|
||||
fi
|
||||
echo ""
|
||||
echo "Weiter mit:"
|
||||
echo " $target --action install"
|
||||
echo ""
|
||||
echo "Nur diese Maschine ueberwachen, ohne etwas zu installieren:"
|
||||
echo " $target --action monitor"
|
||||
exit 0
|
||||
else
|
||||
echo "Aktualisierung fuer Update-Agent verfuegbar. Lade neue Fassung..."
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$CHECK_ONLY" -eq 1 ]; then
|
||||
echo "Neue Version von $binary ist verfuegbar (SHA256: $expected)."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "Lade $binary von $BASE_URL ..."
|
||||
fetch "$BASE_URL/installer/$binary" "$tmp/agent"
|
||||
fetch "$BASE_URL/installer/$binary.sha256" "$tmp/agent.sha256"
|
||||
|
||||
# ------------------------------------------------------------- Pruefsumme
|
||||
expected="$(tr -d ' \t\r\n' < "$tmp/agent.sha256")"
|
||||
|
||||
# ------------------------------------------------------------- Pruefsumme pruefen
|
||||
if command -v sha256sum >/dev/null 2>&1; then
|
||||
actual="$(sha256sum "$tmp/agent" | cut -d' ' -f1)"
|
||||
elif command -v shasum >/dev/null 2>&1; then
|
||||
|
||||
Reference in New Issue
Block a user