homelab-control.sh: zenity als primärer setup-dialog (funktioniert aus rofi/ags-menüs), terminal-check vor gum/whiptail/read
This commit is contained in:
@@ -15,17 +15,13 @@ if ! command -v ags >/dev/null 2>&1; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if ! command -v sshpass >/dev/null 2>&1; then
|
if ! command -v sshpass >/dev/null 2>&1; then
|
||||||
if command -v gum >/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
|
gum confirm "sshpass ist nicht installiert. Installieren?" && sudo pacman -S --noconfirm sshpass || true
|
||||||
else
|
|
||||||
read -r -p "sshpass ist nicht installiert. Installieren? [Y/n] " response
|
|
||||||
response="${response:-Y}"
|
|
||||||
if [[ "$response" =~ ^[yY](es)?$ ]]; then
|
|
||||||
sudo pacman -S --noconfirm sshpass
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
if ! command -v sshpass >/dev/null 2>&1; then
|
if ! command -v sshpass >/dev/null 2>&1; then
|
||||||
notify "sshpass wird benötigt."
|
notify "sshpass wird benötigt. Bitte installieren: sudo pacman -S sshpass"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@@ -33,19 +29,35 @@ fi
|
|||||||
setup_homelab() {
|
setup_homelab() {
|
||||||
local server_address server_username server_port
|
local server_address server_username server_port
|
||||||
|
|
||||||
if command -v gum >/dev/null 2>&1; then
|
if command -v zenity >/dev/null 2>&1; then
|
||||||
|
local data
|
||||||
|
data="$(zenity --forms --title="Homelab Control Center" \
|
||||||
|
--text="Server-Zugangsdaten eingeben" \
|
||||||
|
--add-entry="Server-Adresse" \
|
||||||
|
--add-entry="SSH-Benutzer" \
|
||||||
|
--add-entry="SSH-Port")" || return 1
|
||||||
|
server_address="$(printf '%s\n' "$data" | cut -d'|' -f1)"
|
||||||
|
server_username="$(printf '%s\n' "$data" | cut -d'|' -f2)"
|
||||||
|
server_port="$(printf '%s\n' "$data" | cut -d'|' -f3)"
|
||||||
|
[[ -z "$server_address" ]] && { notify "Keine Adresse angegeben."; return 1; }
|
||||||
|
server_username="${server_username:-root}"
|
||||||
|
server_port="${server_port:-22}"
|
||||||
|
|
||||||
|
elif [[ -t 0 ]] && command -v gum >/dev/null 2>&1; then
|
||||||
gum style --foreground 212 "Homelab Control Center Setup"
|
gum style --foreground 212 "Homelab Control Center Setup"
|
||||||
echo
|
echo
|
||||||
server_address="$(gum input --prompt "Server address: " --placeholder "192.168.1.100")"
|
server_address="$(gum input --prompt "Server address: " --placeholder "192.168.1.100")"
|
||||||
[[ -z "$server_address" ]] && { notify "Keine Adresse angegeben."; return 1; }
|
[[ -z "$server_address" ]] && { notify "Keine Adresse angegeben."; return 1; }
|
||||||
server_username="$(gum input --prompt "SSH username: " --value "root")"
|
server_username="$(gum input --prompt "SSH username: " --value "root")"
|
||||||
server_port="$(gum input --prompt "SSH port: " --value "22")"
|
server_port="$(gum input --prompt "SSH port: " --value "22")"
|
||||||
elif command -v whiptail >/dev/null 2>&1; then
|
|
||||||
|
elif [[ -t 0 ]] && command -v whiptail >/dev/null 2>&1; then
|
||||||
server_address="$(whiptail --inputbox "Server address" 10 60 3>&1 1>&2 2>&3)" || return 1
|
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; }
|
[[ -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_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
|
server_port="$(whiptail --inputbox "SSH port" 10 60 "22" 3>&1 1>&2 2>&3)" || return 1
|
||||||
else
|
|
||||||
|
elif [[ -t 0 ]]; then
|
||||||
echo "=== Homelab Control Center Setup ==="
|
echo "=== Homelab Control Center Setup ==="
|
||||||
echo
|
echo
|
||||||
read -r -p "Server address (IP or domain): " server_address
|
read -r -p "Server address (IP or domain): " server_address
|
||||||
@@ -54,6 +66,10 @@ setup_homelab() {
|
|||||||
server_username="${server_username:-root}"
|
server_username="${server_username:-root}"
|
||||||
read -r -p "SSH port [22]: " server_port
|
read -r -p "SSH port [22]: " server_port
|
||||||
server_port="${server_port:-22}"
|
server_port="${server_port:-22}"
|
||||||
|
|
||||||
|
else
|
||||||
|
notify "Kein grafischer Dialog (zenity) verfügbar. Bitte installieren: sudo pacman -S zenity"
|
||||||
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mkdir -p "$(dirname "$HOMELAB_CONFIG")"
|
mkdir -p "$(dirname "$HOMELAB_CONFIG")"
|
||||||
|
|||||||
Reference in New Issue
Block a user