diff --git a/install.sh b/install.sh index dbabe8b..6ca5f70 100644 --- a/install.sh +++ b/install.sh @@ -42,6 +42,9 @@ UPDATE_STOPPED="no" AUTO_REBOOT_HOST="yes" EXCLUDE_GUESTS="" +NOTIFY_ENABLED="no" +NOTIFY_TARGET="" + DAY="7" DAY_SYSTEMD="Sun" DAY_NAME="Sonntag" @@ -68,6 +71,8 @@ if [[ -f "$CONFIG" ]]; then UPDATE_STOPPED="${UPDATE_STOPPED:-no}" AUTO_REBOOT_HOST="${AUTO_REBOOT_HOST:-yes}" EXCLUDE_GUESTS="${EXCLUDE_GUESTS:-}" + NOTIFY_ENABLED="${NOTIFY_ENABLED:-no}" + NOTIFY_TARGET="${NOTIFY_TARGET:-}" # Vorhandenen systemd-Zeitplan auslesen if [[ -f "$TIMER" ]]; then @@ -116,6 +121,10 @@ if [[ "$EXISTING_INSTALL" == "yes" ]]; then echo " VMs automatisch aktualisieren: $UPDATE_VMS" echo " Gestoppte Gäste starten: $UPDATE_STOPPED" echo " Automatischer Host-Reboot: $AUTO_REBOOT_HOST" + echo " Benachrichtigungen: $NOTIFY_ENABLED" + if [[ "$NOTIFY_ENABLED" == "yes" ]]; then + echo " Notification-Target: ${NOTIFY_TARGET:-nicht gesetzt}" + fi echo " Zeitplan: $DAY_NAME $UPDATE_TIME Uhr" echo " Ausgeschlossene Gäste: ${EXCLUDE_GUESTS:-keine}" echo @@ -185,6 +194,50 @@ echo ask_yes_no "Proxmox automatisch neu starten, wenn erforderlich?" "$AUTO_REBOOT_HOST" AUTO_REBOOT_HOST="$REPLY" +echo +ask_yes_no "Proxmox-Benachrichtigung nach Update-Läufen senden?" "$NOTIFY_ENABLED" +NOTIFY_ENABLED="$REPLY" + +if [[ "$NOTIFY_ENABLED" == "yes" ]]; then + echo + echo "Vorhandene Proxmox-Notification-Targets:" + TARGETS="$(pvesh get /cluster/notifications/targets --output-format json 2>/dev/null | + grep -oE '"name":"[^"]+"' | + sed -E 's/^"name":"([^"]+)"$/\1/' | + sort -u || true)" + + if [[ -z "$TARGETS" ]]; then + echo " Keine Targets gefunden." + echo " Benachrichtigungen werden deaktiviert." + NOTIFY_ENABLED="no" + NOTIFY_TARGET="" + else + while IFS= read -r target; do + [[ -n "$target" ]] && echo " - $target" + done <<< "$TARGETS" + + echo + while true; do + read -r -p "Notification-Target [${NOTIFY_TARGET:-keins}]: " NEW_TARGET