fix: hyprland config globbing error (source=~), dotfiles deploy stabilität (cp -aT, set -e fix), homelab AGS setup form

This commit is contained in:
2026-05-30 19:56:57 +02:00
parent d367c4edd0
commit 1a06ffa0dc
6 changed files with 76 additions and 115 deletions

View File

@@ -9,118 +9,17 @@ notify() {
notify-send "Homelab" "$1" >/dev/null 2>&1 || true notify-send "Homelab" "$1" >/dev/null 2>&1 || true
} }
setup_homelab() {
local server_address server_username server_port
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 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")"
[[ -z "$server_address" ]] && { notify "Keine Adresse angegeben."; return 1; }
server_username="$(gum input --prompt "SSH username: " --value "root")"
server_port="$(gum input --prompt "SSH port: " --value "22")"
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
else
echo "=== Homelab Control Center Setup ==="
echo
read -r -p "Server address (IP or domain): " server_address
[[ -z "$server_address" ]] && { echo "Keine Adresse eingegeben."; return 1; }
read -r -p "SSH username [root]: " server_username
server_username="${server_username:-root}"
read -r -p "SSH port [22]: " server_port
server_port="${server_port:-22}"
fi
mkdir -p "$(dirname "$HOMELAB_CONFIG")"
cat > "$HOMELAB_CONFIG" <<CONFIG
# Homelab Configuration
server:
address: "${server_address}"
username: "${server_username}"
port: ${server_port:-22}
control_center:
refresh_interval: 5
theme: "dark"
features:
docker: true
services: true
storage: true
network: true
monitoring: true
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 if ! command -v ags >/dev/null 2>&1; then
notify "ags ist nicht installiert." notify "ags ist nicht installiert."
exit 1 exit 1
fi 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 if ! command -v sshpass >/dev/null 2>&1; then
notify "sshpass wird benötigt. Bitte installieren: sudo pacman -S sshpass" notify "sshpass wird benötigt. Bitte installieren: sudo pacman -S sshpass"
exit 1 exit 1
fi fi
fi
if [[ -f "$HOMELAB_CONFIG" ]]; then
export HOMELAB_CONFIG export HOMELAB_CONFIG
else
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
cd "$HYPR_DIR" cd "$HYPR_DIR"
ags quit --instance homelab-control >/dev/null 2>&1 || true ags quit --instance homelab-control >/dev/null 2>&1 || true
exec ags run "$HYPR_DIR/ags/homelab.tsx" exec ags run "$HYPR_DIR/ags/homelab.tsx"

View File

@@ -4,14 +4,25 @@ import { execAsync } from "ags/process";
import css from "./homelab.css"; import css from "./homelab.css";
import GLib from "gi://GLib"; import GLib from "gi://GLib";
let hasConfig = false;
const CONFIG_PATH = GLib.getenv("HOMELAB_CONFIG") || `${GLib.getenv("HOME")}/.config/homelab/config.yaml`;
function saveConfig(host: string, user: string, port: string) {
const yaml = `# Homelab Configuration\ngenerated_by: Omeron\n\nserver:\n address: "${host}"\n username: "${user}"\n port: ${port}\n\ncontrol_center:\n refresh_interval: 5\n theme: "dark"\n\nfeatures:\n docker: true\n services: true\n storage: true\n network: true\n monitoring: true\n`;
GLib.file_set_contents(CONFIG_PATH, new TextEncoder().encode(yaml));
hasConfig = true;
const win = app.get_window("homelab-control");
if (win) win.set_child(<box marginTop={WINDOW_MARGIN_TOP}>{authed ? <DashboardView /> : <LoginView />}</box> as Gtk.Widget);
}
function loadConfig() { function loadConfig() {
const configPath = GLib.getenv("HOMELAB_CONFIG") || `${GLib.getenv("HOME")}/.config/homelab/config.yaml`;
const defaults = { host: "10.0.0.15", user: "root", port: 22 }; const defaults = { host: "10.0.0.15", user: "root", port: 22 };
try { try {
const [ok, contents] = GLib.file_get_contents(configPath); const [ok, contents] = GLib.file_get_contents(CONFIG_PATH);
if (!ok || !contents) return defaults; if (!ok || !contents) return defaults;
hasConfig = true;
const text = new TextDecoder().decode(contents); const text = new TextDecoder().decode(contents);
const lines = text.split("\n"); const lines = text.split("\n");
let host = defaults.host; let host = defaults.host;
@@ -1113,6 +1124,55 @@ function startRefreshTimer() {
}); });
} }
function SetupView() {
let host = "";
let user = "root";
let port = "22";
return (
<box class="login-panel" orientation={Gtk.Orientation.VERTICAL} spacing={14}>
<box orientation={Gtk.Orientation.VERTICAL} spacing={4}>
<label class="title" xalign={0} label="Homelab Control Center" />
<label class="subtitle" xalign={0} label="Ersteinrichtung — Serververbindung konfigurieren" />
</box>
<entry
placeholderText="Server-Adresse (IP oder Domain)"
hexpand
onChanged={entry => { host = entry.get_text(); }}
onActivate={() => {
if (host && user && port) saveConfig(host, user, port);
}}
/>
<entry
placeholderText="SSH-Benutzer"
text="root"
hexpand
onChanged={entry => { user = entry.get_text() || "root"; }}
onActivate={() => {
if (host && user && port) saveConfig(host, user, port);
}}
/>
<entry
placeholderText="SSH-Port"
text="22"
hexpand
onChanged={entry => { port = entry.get_text() || "22"; }}
onActivate={() => {
if (host && user && port) saveConfig(host, user, port);
}}
/>
<button
class="button primary"
label="Speichern"
onClicked={() => {
if (!host) return;
saveConfig(host, user, port);
}}
/>
</box>
);
}
function HomelabWindow() { function HomelabWindow() {
return ( return (
<window <window
@@ -1132,7 +1192,7 @@ function HomelabWindow() {
return false; return false;
}} /> }} />
<box marginTop={WINDOW_MARGIN_TOP}> <box marginTop={WINDOW_MARGIN_TOP}>
{authed ? <DashboardView /> : <LoginView />} {!hasConfig ? <SetupView /> : (authed ? <DashboardView /> : <LoginView />)}
</box> </box>
</window> </window>
); );
@@ -1143,7 +1203,7 @@ function rebuild() {
if (!win) { if (!win) {
return; return;
} }
win.set_child(<box marginTop={WINDOW_MARGIN_TOP}>{authed ? <DashboardView /> : <LoginView />}</box> as Gtk.Widget); win.set_child(<box marginTop={WINDOW_MARGIN_TOP}>{!hasConfig ? <SetupView /> : (authed ? <DashboardView /> : <LoginView />)}</box> as Gtk.Widget);
} }
app.start({ app.start({

View File

@@ -80,7 +80,7 @@ general {
layout = dwindle layout = dwindle
} }
source = ~/.config/hypr/current-theme.conf source = /home/pascal/.config/hypr/current-theme.conf
# https://wiki.hypr.land/Configuring/Variables/#decoration # https://wiki.hypr.land/Configuring/Variables/#decoration
decoration { decoration {

View File

@@ -100,9 +100,9 @@ copy_path() {
local target="$2" local target="$2"
backup_file "$target" backup_file "$target"
rm -rf "$target" rm -rf "$target" 2>/dev/null || true
mkdir -p "$(dirname "$target")" mkdir -p "$(dirname "$target")"
cp -a "$source" "$target" cp -aT "$source" "$target"
log_info "Copied $source -> $target" log_info "Copied $source -> $target"
} }

View File

@@ -28,7 +28,7 @@ with open('$OMERON_PROJECT_DIR/config/omeron.yaml') as f:
data = yaml.safe_load(f) data = yaml.safe_load(f)
items = data.get('dotfiles', {}).get('items', []) items = data.get('dotfiles', {}).get('items', [])
print(' '.join(items)) print(' '.join(items))
" 2>/dev/null)" " 2>/dev/null)" || true
if [[ -n "$raw_items" ]]; then if [[ -n "$raw_items" ]]; then
read -ra config_items <<< "$raw_items" read -ra config_items <<< "$raw_items"
@@ -44,8 +44,10 @@ print(' '.join(items))
return 0 return 0
fi fi
backup_dir="$(backup_file "$HOME/.config/hypr" "$HOME/.dotfiles-backup/$(date +%Y%m%d-%H%M%S)")" local backup_timestamp
backup_dir="$(dirname "$backup_dir" 2>/dev/null || printf '%s' "$HOME/.dotfiles-backup/$(date +%Y%m%d-%H%M%S)")" backup_timestamp="$(date +%Y%m%d-%H%M%S)"
backup_file "$HOME/.config/hypr" "$HOME/.dotfiles-backup/$backup_timestamp" >/dev/null
backup_dir="$HOME/.dotfiles-backup/$backup_timestamp"
for item in "${config_items[@]}"; do for item in "${config_items[@]}"; do
local source="$dotfiles_dir/$item" local source="$dotfiles_dir/$item"

View File

@@ -27,7 +27,7 @@ with open('$OMERON_PROJECT_DIR/config/omeron.yaml') as f:
data = yaml.safe_load(f) data = yaml.safe_load(f)
svcs = data.get('services', []) svcs = data.get('services', [])
print(' '.join(svcs)) print(' '.join(svcs))
" 2>/dev/null)" " 2>/dev/null)" || true
if [[ -n "$raw_services" ]]; then if [[ -n "$raw_services" ]]; then
read -ra services <<< "$raw_services" read -ra services <<< "$raw_services"