feat: Workflow deploy und sicherer Deploy-Zugang für den Gitea-Runner, noch nicht eingerichtet (#1253, #1254, #1255)
All checks were successful
ci / pruefen (push) Successful in 3m11s
All checks were successful
ci / pruefen (push) Successful in 3m11s
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GmHhg7bzeoxrPsLnJ4nor4
This commit is contained in:
11
scripts/srv04-deploy/nexus-deploy
Executable file
11
scripts/srv04-deploy/nexus-deploy
Executable file
@ -0,0 +1,11 @@
|
||||
#!/usr/bin/env bash
|
||||
# Erzwungenes Kommando des Deploy-Schlüssels (→ #1253): Der Runner darf per SSH genau eines, nämlich eine Version nennen.
|
||||
# Liegt root-eigen unter /usr/local/sbin; der SSH-Zugang `nexus-deploy` kann es nicht ändern. Ruft per sudo nur
|
||||
# nexus-deploy-install auf, das die Version noch einmal prüft.
|
||||
set -euo pipefail
|
||||
v="${SSH_ORIGINAL_COMMAND:-}"
|
||||
if ! [[ "$v" =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}(-rc[0-9]{1,3})?$ ]]; then
|
||||
echo "Aufruf: genau eine Version, zum Beispiel 0.1.33 oder 0.1.33-rc3." >&2
|
||||
exit 2
|
||||
fi
|
||||
exec sudo -n /usr/local/sbin/nexus-deploy-install "$v"
|
||||
24
scripts/srv04-deploy/nexus-deploy-install
Executable file
24
scripts/srv04-deploy/nexus-deploy-install
Executable file
@ -0,0 +1,24 @@
|
||||
#!/usr/bin/env bash
|
||||
# Installiert ein vom Gitea-Runner gebautes Release auf srv04 (→ #1253). Läuft als root (per sudo aus nexus-deploy).
|
||||
# srv04 lädt das Binary selbst aus dem Gitea-Release, prüft die SHA-256-Prüfsumme und ruft den mitinstallierten
|
||||
# install.sh auf (Sicherung der Datenbank, Umschalten, Neustart, Warten auf Bereitschaft). Der Runner schickt nur die
|
||||
# Versionsnummer, nie Dateien. Die Prüfsumme stammt vom selben Server wie das Binary: sie schützt vor beschädigten
|
||||
# Downloads, nicht vor einem manipulierten Gitea.
|
||||
set -euo pipefail
|
||||
[ "$(id -u)" -eq 0 ] || { echo "Nur als root." >&2; exit 1; }
|
||||
v="${1:-}"
|
||||
[[ "$v" =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}(-rc[0-9]{1,3})?$ ]] || { echo "Ungültige Version." >&2; exit 2; }
|
||||
GITEA="https://git.wlkns.org/wlkns-dev/nexus"
|
||||
datei="nexus-$v-linux-x86_64-musl"
|
||||
dir="/var/lib/nexus-deploy/$v"
|
||||
rm -rf "$dir"
|
||||
install -d -m 0755 /var/lib/nexus-deploy "$dir"
|
||||
logger -t nexus-deploy "lade $v aus dem Gitea-Release"
|
||||
curl -fsSL --connect-timeout 20 --max-time 300 -o "$dir/$datei" "$GITEA/releases/download/v$v/$datei"
|
||||
curl -fsSL --connect-timeout 20 --max-time 60 -o "$dir/$datei.sha256" "$GITEA/releases/download/v$v/$datei.sha256"
|
||||
(cd "$dir" && sha256sum -c "$datei.sha256")
|
||||
install -m 0755 "$dir/$datei" "$dir/nexus"
|
||||
install -m 0755 /usr/local/lib/nexus-deploy/install.sh "$dir/install.sh"
|
||||
logger -t nexus-deploy "installiere $v"
|
||||
VERSION="$v" bash "$dir/install.sh" --start
|
||||
logger -t nexus-deploy "$v installiert"
|
||||
Reference in New Issue
Block a user