This commit is contained in:
sharky committed 2026-10-04 16:56:00 +02:00
1 parent 44d247d506
commit 300096f913
1 file changed
+33 -14
+33 -14
View File
@@ -216,23 +216,42 @@ if [[ "$NOTIFY_ENABLED" == "yes" ]]; then
[[ -n "$target" ]] && echo " - $target" [[ -n "$target" ]] && echo " - $target"
done <<< "$TARGETS" done <<< "$TARGETS"
echo # Eingebautes Proxmox-Fallback nicht als bevorzugtes Ziel behandeln.
while true; do # Wenn genau ein anderes Target existiert, automatisch verwenden.
read -r -p "Notification-Target [${NOTIFY_TARGET:-keins}]: " NEW_TARGET </dev/tty CUSTOM_TARGETS="$(printf '%s\n' "$TARGETS" | grep -Fxv 'mail-to-root' || true)"
NEW_TARGET="${NEW_TARGET:-$NOTIFY_TARGET}" CUSTOM_COUNT="$(printf '%s\n' "$CUSTOM_TARGETS" | sed '/^$/d' | wc -l)"
if [[ -z "$NEW_TARGET" ]]; then if [[ "$CUSTOM_COUNT" -eq 1 ]]; then
echo "Bitte ein vorhandenes Target eingeben." NOTIFY_TARGET="$(printf '%s\n' "$CUSTOM_TARGETS" | sed '/^$/d' | head -n1)"
continue echo
fi echo "Notification-Target automatisch gewählt: $NOTIFY_TARGET"
if printf '%s\n' "$TARGETS" | grep -Fxq "$NEW_TARGET"; then elif [[ "$CUSTOM_COUNT" -eq 0 ]]; then
NOTIFY_TARGET="$NEW_TARGET" # Nur mail-to-root vorhanden. Das ist ein gültiges Proxmox-Ziel.
break NOTIFY_TARGET="mail-to-root"
fi echo
echo "Notification-Target automatisch gewählt: $NOTIFY_TARGET"
echo "Target '$NEW_TARGET' wurde nicht gefunden." else
done echo
echo "Mehrere benutzerdefinierte Targets vorhanden."
while true; do
read -r -p "Notification-Target [${NOTIFY_TARGET:-keins}]: " NEW_TARGET </dev/tty
NEW_TARGET="${NEW_TARGET:-$NOTIFY_TARGET}"
if [[ -z "$NEW_TARGET" ]]; then
echo "Bitte ein vorhandenes Target eingeben."
continue
fi
if printf '%s\n' "$CUSTOM_TARGETS" | grep -Fxq "$NEW_TARGET"; then
NOTIFY_TARGET="$NEW_TARGET"
break
fi
echo "Target '$NEW_TARGET' wurde nicht gefunden."
done
fi
fi fi
else else
NOTIFY_TARGET="" NOTIFY_TARGET=""