setup-email-pbs.sh aktualisiert
This commit is contained in:
@@ -1,41 +1,40 @@
|
||||
#!/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
|
||||
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
|
||||
echo
|
||||
|
||||
read -p "Absender-Name (z.B. PBS Server): " SENDER_NAME
|
||||
read -p "Absender-Adresse (z.B. pbs@example.com): " MAIL_FROM
|
||||
read -p "Empfänger-Adresse (z.B. admin@example.com): " MAIL_TO
|
||||
read -p "Absender-Adresse: " MAIL_FROM
|
||||
read -p "Empfänger-Adresse: " 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 "==> 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"
|
||||
{
|
||||
"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."
|
||||
echo "==> Konfiguration abgeschlossen. Sichtbar in der PBS Web-GUI unter: Verwaltung → Benachrichtigungen"
|
||||
|
||||
Reference in New Issue
Block a user