setup-email-pve.sh aktualisiert

This commit is contained in:
2025-05-20 22:31:39 +02:00
parent 753c9460e6
commit 5b482407b0

View File

@@ -1,32 +1,49 @@
#!/bin/bash
echo "=== Proxmox VE 8 Benachrichtigungssystem konfigurieren ==="
set -e
read -p "SMTP Server: " SMTP_SERVER
read -p "SMTP Port [587]: " SMTP_PORT
SMTP_PORT=${SMTP_PORT:-587}
read -p "SMTP Benutzer: " SMTP_USER
read -s -p "SMTP Passwort: " SMTP_PASS
echo "🔧 Konfiguration von Proxmox VE Benachrichtigungen (PVE 8.x)"
echo
read -p "Absender-Adresse: " MAIL_FROM
read -p "Mail-Zieladresse: " MAIL_TO
# Abfragen
read -rp "▶️ SMTP-Absenderadresse (z.B. pve@example.com): " MAILFROM
read -rp "▶️ SMTP-Hostname (z.B. smtp.example.com:587): " SMTPHOST
read -rp "▶️ SMTP-Benutzername: " SMTPUSER
read -rsp "▶️ SMTP-Passwort: " SMTPPASS
echo
read -rp "▶️ Empfängeradresse für Benachrichtigungen: " RCPT
# Sender erstellen
pvesh create /config/notifications/senders/default --mailname "$(hostname -f)" \
--mailfrom "$MAIL_FROM" --smarthost "$SMTP_SERVER:$SMTP_PORT" \
--authuser "$SMTP_USER" --password "$SMTP_PASS" --type smtp
# Ziel konfigurieren
pvesh create /config/notifications/targets/mail-admin --type sendmail \
--mailto "$MAIL_TO"
# Policy setzen (optional)
pvesh set /config/notifications/policy/default --targets mail-admin --sender default
SENDER_NAME="default"
TARGET_NAME="mail-admin"
POLICY_NAME="default"
MAILNAME=$(hostname -f)
echo
echo "==> Testmail wird versendet..."
proxmox-notify test --target mail-admin --subject "Test von $(hostname)" --body "Das ist eine Testmail vom neuen Benachrichtigungssystem (PVE 8)."
echo "🚀 Konfiguriere SMTP-Sender '$SENDER_NAME'..."
pvesh set /config/notifications/senders/$SENDER_NAME \
--type smtp \
--mailfrom "$MAILFROM" \
--mailname "$MAILNAME" \
--smarthost "$SMTPHOST" \
--authuser "$SMTPUSER" \
--password "$SMTPPASS"
echo "==> Konfiguration abgeschlossen. Überprüfbar in der Web-GUI unter Rechenzentrum → Benachrichtigungen."
echo "✅ Sender eingerichtet."
echo "🚀 Konfiguriere Ziel '$TARGET_NAME'..."
pvesh set /config/notifications/targets/$TARGET_NAME \
--type sendmail \
--mailto "$RCPT"
echo "✅ Ziel eingerichtet."
echo "🚀 Setze Standard-Policy '$POLICY_NAME'..."
pvesh set /config/notifications/policy/$POLICY_NAME \
--targets "$TARGET_NAME" \
--sender "$SENDER_NAME"
echo "✅ Policy eingerichtet."
echo
echo "🎉 Benachrichtigungs-Konfiguration abgeschlossen!"
echo " Du kannst sie unter 'Rechenzentrum → Benachrichtigungen' in der WebUI ansehen und testen."