setup-email-pbs.sh aktualisiert

This commit is contained in:
2025-05-20 23:14:04 +02:00
parent 5b06e39047
commit 76ca50f97c

View File

@@ -1,40 +1,58 @@
#!/bin/bash #!/bin/bash
set -euo pipefail
echo "=== Proxmox Backup Server Benachrichtigungssystem konfigurieren ===" NOTIF_CFG="/etc/proxmox-backup/notifications.cfg"
PRIV_NOTIF_CFG="/etc/proxmox-backup/notifications-priv.cfg"
read -p "SMTP Server: " SMTP_SERVER backup_file() {
read -p "SMTP Port [587]: " SMTP_PORT local file=$1
SMTP_PORT=${SMTP_PORT:-587} if [ -f "$file" ]; then
local bak="${file}.bak.$(date +%Y%m%d%H%M%S)"
cp "$file" "$bak"
echo "Backup erstellt: $bak"
fi
}
read -p "SMTP Benutzer: " SMTP_USER backup_file "$NOTIF_CFG"
read -s -p "SMTP Passwort: " SMTP_PASS backup_file "$PRIV_NOTIF_CFG"
echo "Bitte die SMTP Notification Konfiguration für PBS eingeben:"
read -rp "Author (z.B. MH-PBS01 | MAIERHOME): " AUTHOR
read -rp "From-Address (z.B. MH-PBS01@vmd55888.de): " FROMADDR
read -rp "Empfänger-Mailadresse (mailto): " MAILTO
read -rp "SMTP Server (z.B. mail.vmd55888.de): " SERVER
read -rp "SMTP Port (z.B. 587): " PORT
read -rp "Modus (starttls/ssl/none): " MODE
read -rp "SMTP Benutzername: " USERNAME
read -rsp "SMTP Passwort: " SMTP_PASS
echo echo
read -p "Absender-Adresse: " MAIL_FROM cat > "$NOTIF_CFG" << EOF
read -p "Empfänger-Adresse: " MAIL_TO sendmail: mail-to-root
comment Send mails to root@pam's email address
disable true
mailto-user root@pam
# Sender anlegen matcher: default-matcher
proxmox-notify sender update smtp-default \ comment Route all notifications to mail-to-root
--type smtp \ mode all
--mailfrom "$MAIL_FROM" \ target mailout
--smarthost "$SMTP_SERVER:$SMTP_PORT" \
--authuser "$SMTP_USER" \
--password "$SMTP_PASS" \
--mailname "$(hostname -f)"
# Ziel anlegen smtp: mailout
proxmox-notify target update mail-admin \ author $AUTHOR
--type sendmail \ from-address $FROMADDR
--mailto "$MAIL_TO" mailto $MAILTO
mailto-user root@pam
mode $MODE
port $PORT
server $SERVER
username $USERNAME
EOF
# Policy zuweisen (optional) cat > "$PRIV_NOTIF_CFG" << EOF
proxmox-notify policy update default \ smtp: mailout
--targets mail-admin \ password $SMTP_PASS
--sender smtp-default EOF
# Test echo "PBS Notification Konfiguration neu geschrieben. Bitte WebUI prüfen."
echo
echo "==> Sende Testmail..."
proxmox-notify test --target mail-admin --subject "Testmail von PBS $(hostname)" --body "Dies ist eine Testbenachrichtigung vom neuen PBS-System."
echo "==> Konfiguration abgeschlossen. Sichtbar in der PBS Web-GUI unter: Verwaltung → Benachrichtigungen"