setup-email-pve.sh aktualisiert
This commit is contained in:
@@ -1,32 +1,49 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
echo "=== Proxmox VE 8 Benachrichtigungssystem konfigurieren ==="
|
set -e
|
||||||
|
|
||||||
read -p "SMTP Server: " SMTP_SERVER
|
echo "🔧 Konfiguration von Proxmox VE Benachrichtigungen (PVE 8.x)"
|
||||||
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
|
echo
|
||||||
|
|
||||||
read -p "Absender-Adresse: " MAIL_FROM
|
# Abfragen
|
||||||
read -p "Mail-Zieladresse: " MAIL_TO
|
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
|
SENDER_NAME="default"
|
||||||
pvesh create /config/notifications/senders/default --mailname "$(hostname -f)" \
|
TARGET_NAME="mail-admin"
|
||||||
--mailfrom "$MAIL_FROM" --smarthost "$SMTP_SERVER:$SMTP_PORT" \
|
POLICY_NAME="default"
|
||||||
--authuser "$SMTP_USER" --password "$SMTP_PASS" --type smtp
|
MAILNAME=$(hostname -f)
|
||||||
|
|
||||||
# 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
|
|
||||||
|
|
||||||
echo
|
echo
|
||||||
echo "==> Testmail wird versendet..."
|
echo "🚀 Konfiguriere SMTP-Sender '$SENDER_NAME'..."
|
||||||
proxmox-notify test --target mail-admin --subject "Test von $(hostname)" --body "Das ist eine Testmail vom neuen Benachrichtigungssystem (PVE 8)."
|
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."
|
||||||
|
|||||||
Reference in New Issue
Block a user