From 60d28bff57a52fd92c9f4a4eb52a45456468f947 Mon Sep 17 00:00:00 2001 From: sharky Date: Sun, 4 Oct 2026 22:00:48 +0200 Subject: [PATCH] manager.sh aktualisiert --- manager.sh | 270 ++++++++++++++++++++++++++++++++++------------------- 1 file changed, 176 insertions(+), 94 deletions(-) diff --git a/manager.sh b/manager.sh index 77055c4..eec9a3e 100644 --- a/manager.sh +++ b/manager.sh @@ -58,11 +58,13 @@ wt_menu() { wt_yesno() { local title="$1" text="$2" default="${3:-no}" args=() [[ "$default" == "no" ]] && args+=(--defaultno) - whiptail "${args[@]}" --title "$title" --yesno "$text" 12 78 &1 1>&2 2>&3 &1 1>&2 2>&3 &1 1>&2 2>&3 /dev/null 2>&1 && ! systemd-analyze calendar "$x" >/dev/null 2>&1; then - wt_msg "Fehler" "Dieser systemd-Zeitplan ist ungueltig." - continue - fi - ONCALENDAR="$x" - ;; - esac + SCHEDULE_TYPE="$choice" - set +e - review_schedule - rc=$? - set -e - case "$rc" in - 0) return ;; - 1) return ;; - 2) continue ;; - esac - done + case "$choice" in + daily) + result="$(whiptail --title "Zeitplan - Taeglich" --ok-button "Pruefen" --cancel-button "Zurueck" \ + --form "Taeglicher automatischer Lauf." 14 82 4 \ + "Uhrzeit (HH:MM):" 1 1 "$SCHEDULE_TIME" 1 35 8 0 \ + 3>&1 1>&2 2>&3 &1 1>&2 2>&3 &1 1>&2 2>&3 &1 1>&2 2>&3 &1 1>&2 2>&3 /dev/null 2>&1 && ! systemd-analyze calendar "$ONCALENDAR" >/dev/null 2>&1; then + wt_msg "Ungueltiger Zeitplan" "systemd akzeptiert diesen Zeitplan nicht: + +$ONCALENDAR" + return + fi + + set +e + review_schedule + rc=$? + set -e + [[ "$rc" -eq 0 ]] || return } exclusions_menu() { @@ -543,42 +599,68 @@ Markierte Gaeste werden NICHT automatisch aktualisiert." \ } notifications_menu() { - local choice json - choice="$(wt_menu "Benachrichtigungen" "Proxmox-Benachrichtigung nach jedem Lauf" \ - yes "Aktivieren" no "Deaktivieren" BACK "Zurueck")" || return - [[ "$choice" == BACK ]] && return - NOTIFY_ENABLED="$choice" - [[ "$choice" == no ]] && { NOTIFY_TARGET=""; return; } + local json result name state + local -a args=() + + args+=("OFF" "Benachrichtigungen deaktivieren" "$([[ "$NOTIFY_ENABLED" == no ]] && echo ON || echo OFF)") json="$(pvesh get /cluster/notifications/targets --output-format json 2>/dev/null || true)" - local -a args=() if [[ -n "$json" ]]; then - while IFS= read -r choice; do - [[ -n "$choice" ]] && args+=("$choice" "Notification-Target") + while IFS= read -r name; do + [[ -z "$name" ]] && continue + state=OFF + [[ "$NOTIFY_ENABLED" == yes && "$NOTIFY_TARGET" == "$name" ]] && state=ON + args+=("$name" "Proxmox Notification Target" "$state") done < <(TARGETS="$json" python3 - <<'PY' -import json,os +import json, os try: for x in json.loads(os.environ["TARGETS"]): - if x.get("name"): print(x["name"]) -except: pass + n=x.get("name") + if n: print(n) +except Exception: + pass PY ) fi - (( ${#args[@]} > 0 )) || { NOTIFY_ENABLED="no"; wt_msg "Benachrichtigungen" "Keine Notification-Targets gefunden."; return; } - args+=(BACK "Zurueck") - choice="$(wt_menu "Benachrichtigungen" "Target auswaehlen" "${args[@]}")" || return - [[ "$choice" == BACK ]] && return - NOTIFY_TARGET="$choice" + + result="$(whiptail --title "Benachrichtigungen" \ + --ok-button "Uebernehmen" --cancel-button "Zurueck" \ + --radiolist "Eine Einstellung auswaehlen. + +Mit LEERTASTE markieren, danach Uebernehmen." \ + 20 88 10 "${args[@]}" 3>&1 1>&2 2>&3 &1 1>&2 2>&3