setup-email-pbs.sh aktualisiert

This commit is contained in:
2025-05-20 22:22:08 +02:00
parent e41a80499e
commit 753c9460e6

View File

@@ -1,41 +1,40 @@
#!/bin/bash #!/bin/bash
echo "=== [PBS] E-Mail-Benachrichtigungen einrichten ===" echo "=== Proxmox Backup Server Benachrichtigungssystem konfigurieren ==="
read -p "SMTP Server (z.B. smtp.example.com): " SMTP_SERVER read -p "SMTP Server: " SMTP_SERVER
read -p "SMTP Port [587]: " SMTP_PORT read -p "SMTP Port [587]: " SMTP_PORT
SMTP_PORT=${SMTP_PORT:-587} SMTP_PORT=${SMTP_PORT:-587}
read -p "SMTP Benutzer (z.B. user@example.com): " SMTP_USER read -p "SMTP Benutzer: " SMTP_USER
read -s -p "SMTP Passwort: " SMTP_PASS read -s -p "SMTP Passwort: " SMTP_PASS
echo echo
read -p "Absender-Name (z.B. PBS Server): " SENDER_NAME read -p "Absender-Adresse: " MAIL_FROM
read -p "Absender-Adresse (z.B. pbs@example.com): " MAIL_FROM read -p "Empfänger-Adresse: " MAIL_TO
read -p "Empfänger-Adresse (z.B. admin@example.com): " MAIL_TO
CONFIG_FILE="/etc/proxmox-backup/email-notification.cfg" # Sender anlegen
proxmox-notify sender update smtp-default \
--type smtp \
--mailfrom "$MAIL_FROM" \
--smarthost "$SMTP_SERVER:$SMTP_PORT" \
--authuser "$SMTP_USER" \
--password "$SMTP_PASS" \
--mailname "$(hostname -f)"
# Ziel anlegen
proxmox-notify target update mail-admin \
--type sendmail \
--mailto "$MAIL_TO"
# Policy zuweisen (optional)
proxmox-notify policy update default \
--targets mail-admin \
--sender smtp-default
# Test
echo echo
echo "==> Konfiguration wird geschrieben..." echo "==> Sende Testmail..."
proxmox-notify test --target mail-admin --subject "Testmail von PBS $(hostname)" --body "Dies ist eine Testbenachrichtigung vom neuen PBS-System."
cat <<EOF > "$CONFIG_FILE" echo "==> Konfiguration abgeschlossen. Sichtbar in der PBS Web-GUI unter: Verwaltung → Benachrichtigungen"
{
"mail-to": "$MAIL_TO",
"mail-from": "$MAIL_FROM",
"smtp-server": "$SMTP_SERVER",
"smtp-port": $SMTP_PORT,
"smtp-user": "$SMTP_USER",
"smtp-pass": "$SMTP_PASS",
"smtp-starttls": true
}
EOF
chmod 600 "$CONFIG_FILE"
chown root:root "$CONFIG_FILE"
echo
echo "==> Testmail wird gesendet..."
proxmox-backup-manager notify send --to "$MAIL_TO" --subject "Testmail von $SENDER_NAME" --body "Das ist eine Testbenachrichtigung von $SENDER_NAME <$MAIL_FROM>"
echo "==> Fertig mit PBS-Konfiguration."