homelab-control: fallback terminal öffnen wenn zenity fehlt — kitty + gum statt notification ohne reaktion

This commit is contained in:
2026-05-29 19:45:23 +02:00
parent ab0870db04
commit dc7ef3cc51

View File

@@ -9,23 +9,6 @@ notify() {
notify-send "Homelab" "$1" >/dev/null 2>&1 || true
}
if ! command -v ags >/dev/null 2>&1; then
notify "ags ist nicht installiert."
exit 1
fi
if ! command -v sshpass >/dev/null 2>&1; then
if command -v zenity >/dev/null 2>&1; then
zenity --question --title="sshpass" --text="sshpass wird benötigt. Installieren?" --width=300 && sudo pacman -S --noconfirm sshpass || true
elif [[ -t 0 ]] && command -v gum >/dev/null 2>&1; then
gum confirm "sshpass ist nicht installiert. Installieren?" && sudo pacman -S --noconfirm sshpass || true
fi
if ! command -v sshpass >/dev/null 2>&1; then
notify "sshpass wird benötigt. Bitte installieren: sudo pacman -S sshpass"
exit 1
fi
fi
setup_homelab() {
local server_address server_username server_port
@@ -43,7 +26,7 @@ setup_homelab() {
server_username="${server_username:-root}"
server_port="${server_port:-22}"
elif [[ -t 0 ]] && command -v gum >/dev/null 2>&1; then
elif command -v gum >/dev/null 2>&1; then
gum style --foreground 212 "Homelab Control Center Setup"
echo
server_address="$(gum input --prompt "Server address: " --placeholder "192.168.1.100")"
@@ -51,13 +34,13 @@ setup_homelab() {
server_username="$(gum input --prompt "SSH username: " --value "root")"
server_port="$(gum input --prompt "SSH port: " --value "22")"
elif [[ -t 0 ]] && command -v whiptail >/dev/null 2>&1; then
elif command -v whiptail >/dev/null 2>&1; then
server_address="$(whiptail --inputbox "Server address" 10 60 3>&1 1>&2 2>&3)" || return 1
[[ -z "$server_address" ]] && { notify "Keine Adresse angegeben."; return 1; }
server_username="$(whiptail --inputbox "SSH username" 10 60 "root" 3>&1 1>&2 2>&3)" || return 1
server_port="$(whiptail --inputbox "SSH port" 10 60 "22" 3>&1 1>&2 2>&3)" || return 1
elif [[ -t 0 ]]; then
else
echo "=== Homelab Control Center Setup ==="
echo
read -r -p "Server address (IP or domain): " server_address
@@ -66,10 +49,6 @@ setup_homelab() {
server_username="${server_username:-root}"
read -r -p "SSH port [22]: " server_port
server_port="${server_port:-22}"
else
notify "Kein grafischer Dialog (zenity) verfügbar. Bitte installieren: sudo pacman -S zenity"
return 1
fi
mkdir -p "$(dirname "$HOMELAB_CONFIG")"
@@ -93,12 +72,51 @@ CONFIG
notify-send "Homelab" "Konfiguration gespeichert" >/dev/null 2>&1 || true
}
if [[ "${1:-}" == "--setup" ]]; then
setup_homelab
exit $?
fi
if ! command -v ags >/dev/null 2>&1; then
notify "ags ist nicht installiert."
exit 1
fi
if ! command -v sshpass >/dev/null 2>&1; then
if command -v zenity >/dev/null 2>&1; then
zenity --question --title="sshpass" --text="sshpass wird benötigt. Installieren?" --width=300 && sudo pacman -S --noconfirm sshpass || true
elif [[ -t 0 ]] && command -v gum >/dev/null 2>&1; then
gum confirm "sshpass ist nicht installiert. Installieren?" && sudo pacman -S --noconfirm sshpass || true
fi
if ! command -v sshpass >/dev/null 2>&1; then
notify "sshpass wird benötigt. Bitte installieren: sudo pacman -S sshpass"
exit 1
fi
fi
if [[ -f "$HOMELAB_CONFIG" ]]; then
export HOMELAB_CONFIG
else
notify "Keine Homelab-Konfiguration gefunden. Setup startet..."
if ! setup_homelab; then
exit 1
if command -v zenity >/dev/null 2>&1; then
notify "Keine Homelab-Konfiguration gefunden. Setup startet..."
if ! setup_homelab; then
exit 1
fi
else
notify "Keine Konfiguration gefunden. Terminal wird geöffnet..."
local term=""
for t in "${TERMINAL:-}" kitty alacritty foot gnome-terminal xterm; do
[[ -z "$t" ]] && continue
command -v "$t" >/dev/null 2>&1 && { term="$t"; break; }
done
if [[ -z "$term" ]]; then
notify "Kein Terminal und kein zenity. sudo pacman -S zenity"
exit 1
fi
"$term" -e "$0" --setup
if [[ ! -f "$HOMELAB_CONFIG" ]]; then
exit 1
fi
fi
export HOMELAB_CONFIG
fi