whiptail-Menü (Standard/Erweitert) wie community-scripts

Interaktives Setup auf echtem Terminal: ID, CPU, RAM, Disk, Storage, Bridge,
DHCP/statische IP, Root-PW + Bestätigung. Fällt über SSH/Pipe automatisch auf
Env-Vars zurück (deploy-local.sh bleibt non-interaktiv). NONINTERACTIVE=1
schaltet das Menü explizit ab.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-05-30 12:33:48 +02:00
parent 1227e2716d
commit 7187748643
2 changed files with 66 additions and 5 deletions
+8 -2
View File
@@ -59,10 +59,16 @@ die Schwester-Repos unter `~/RAPPORT/SERVER-CONTAINER` und `~/RAPPORT/APP`
Auf der **Proxmox-Host-Shell** (als root):
```bash
bash -c "$(curl -fsSL https://git.kgva.ch/karim/rapport-server-proxmox-lxc/raw/branch/main/rapport-lxc.sh)"
bash -c "$(curl -fsSL http://git.kgva.ch/karim/rapport-server-proxmox-lxc/raw/branch/main/rapport-lxc.sh)"
```
Danach erreichbar unter `http://<container-ip>:8080`.
Es erscheint ein **whiptail-Menü** (Standard / Erweitert) zum Setzen von ID,
CPU, RAM, Disk und Netzwerk — wie bei den Proxmox-Community-Scripts. Danach
erreichbar unter `http://<container-ip>:8080`.
> Das Menü erscheint nur auf einem echten Terminal. Über SSH/Pipe (Variante A)
> läuft alles non-interaktiv über die Env-Vars. Mit `NONINTERACTIVE=1` lässt
> sich das Menü auch interaktiv abschalten.
### Parameter (per Env-Var)
+58 -3
View File
@@ -9,10 +9,10 @@
#
# bash -c "$(curl -fsSL https://git.kgva.ch/karim/rapport-server-proxmox-lxc/raw/branch/main/rapport-lxc.sh)"
#
# …oder lokal: bash rapport-lxc.sh
#
# Alle Parameter sind per Env-Var überschreibbar, z.B.:
# Auf einem echten Terminal erscheint ein whiptail-Menü (Standard/Erweitert).
# Per SSH/Pipe (z.B. deploy-local.sh) läuft es non-interaktiv auf Env-Vars:
# RAM_MB=8192 NET_IP=192.168.1.50/24 NET_GW=192.168.1.1 bash rapport-lxc.sh
# Menü erzwingen-aus: NONINTERACTIVE=1
# ─────────────────────────────────────────────────────────────────────────────
set -euo pipefail
@@ -34,6 +34,7 @@ PASSWORD="${PASSWORD:-}" # root-PW im Container (leer =
REPO_URL="${REPO_URL:-http://git.kgva.ch/karim/RAPPORT-SERVER.git}"
REPO_REF="${REPO_REF:-main}"
TEMPLATE="${TEMPLATE:-debian-12-standard}" # pveam-Template-Name (Präfix)
NONINTERACTIVE="${NONINTERACTIVE:-0}" # 1 = whiptail-Dialoge überspringen
# ── Local-Modus (kein Gitea nötig) ──────────────────────────────────────────
# Wenn gesetzt, werden diese Tarballs (Pfade AUF DEM PROXMOX-HOST) per
@@ -55,6 +56,60 @@ echo -e "${BL}RAPPORT Server — Proxmox-LXC-Installer v${VERSION}${CL}"
command -v pct >/dev/null || die "pct nicht gefunden — läuft das auf einem Proxmox-VE-Host?"
command -v pveam >/dev/null || die "pveam nicht gefunden — Proxmox-VE-Host erwartet."
# ═══ Interaktive Einstellungen (whiptail) ═══════════════════════════════════
# Läuft nur auf einem echten Terminal (also beim curl-Einzeiler in der
# Proxmox-Shell). Über SSH/Pipe (z.B. deploy-local.sh) fällt es automatisch
# auf die Env-Var-Defaults zurück.
whip() { whiptail --backtitle "RAPPORT Server — Proxmox-LXC v${VERSION}" "$@" 3>&1 1>&2 2>&3; }
gather_settings() {
command -v whiptail >/dev/null || return 0
[[ -t 0 && "$NONINTERACTIVE" != "1" ]] || { info "Nicht-interaktiv — verwende Env-Vars/Defaults."; return 0; }
local mode
mode=$(whip --title "Installationsmodus" --menu "\nWie möchtest du den Rapport-Server-Container anlegen?" 15 64 3 \
"standard" "Standard-Einstellungen (empfohlen)" \
"erweitert" "Erweitert — alle Werte anpassen" \
"abbrechen" "Abbrechen") || die "Abgebrochen."
[[ "$mode" == "abbrechen" ]] && die "Abgebrochen."
if [[ "$mode" == "erweitert" ]]; then
CTID=$(whip --title "Container-ID" --inputbox "Eindeutige LXC-ID" 8 60 "$CTID") || die "Abgebrochen."
CT_HOSTNAME=$(whip --title "Hostname" --inputbox "Hostname des Containers" 8 60 "$CT_HOSTNAME") || die "Abgebrochen."
CORES=$(whip --title "CPU" --inputbox "Anzahl CPU-Kerne" 8 60 "$CORES") || die "Abgebrochen."
RAM_MB=$(whip --title "RAM" --inputbox "Arbeitsspeicher in MB (min. 4096)" 8 60 "$RAM_MB") || die "Abgebrochen."
DISK_GB=$(whip --title "Disk" --inputbox "Festplatte in GB (min. 16)" 8 60 "$DISK_GB") || die "Abgebrochen."
STORAGE=$(whip --title "Storage" --inputbox "Proxmox-Storage für rootfs" 8 60 "$STORAGE") || die "Abgebrochen."
BRIDGE=$(whip --title "Netzwerk-Bridge" --inputbox "Bridge" 8 60 "$BRIDGE") || die "Abgebrochen."
local netmode
netmode=$(whip --title "Netzwerk" --menu "\nIP-Adresse" 12 60 2 \
"dhcp" "Automatisch (DHCP)" \
"static" "Statische IP") || die "Abgebrochen."
if [[ "$netmode" == "static" ]]; then
NET_IP=$(whip --title "Statische IP" --inputbox "IP in CIDR-Notation, z.B. 192.168.1.50/24" 8 64 "${NET_IP/dhcp/192.168.1.50/24}") || die "Abgebrochen."
NET_GW=$(whip --title "Gateway" --inputbox "Gateway-IP, z.B. 192.168.1.1" 8 64 "$NET_GW") || die "Abgebrochen."
else
NET_IP="dhcp"
fi
PASSWORD=$(whip --title "Root-Passwort" --passwordbox "Root-Passwort im Container (leer = kein Login)" 8 64 "") || die "Abgebrochen."
fi
# Zusammenfassung + Bestätigung
whip --title "Bitte bestätigen" --yesno "\
Container anlegen mit:
ID: $CTID
Hostname: $CT_HOSTNAME
CPU/RAM: ${CORES} Kerne / ${RAM_MB} MB
Disk: ${DISK_GB} GB auf ${STORAGE}
Netzwerk: ${NET_IP}$([[ "$NET_IP" != dhcp ]] && echo " gw ${NET_GW}") @ ${BRIDGE}
Jetzt starten?" 17 64 || die "Abgebrochen."
}
gather_settings
# ═══ 1 · Debian-Template sicherstellen ══════════════════════════════════════
info "Suche Debian-12-Template …"
pveam update >/dev/null 2>&1 || true