From b006931444c2171a1e044be2641935acf385e27f Mon Sep 17 00:00:00 2001 From: "manuel.maier" Date: Fri, 23 Jan 2026 16:23:36 +0100 Subject: [PATCH] =?UTF-8?q?setup-email-pve.sh=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- setup-email-pve.sh | 61 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 setup-email-pve.sh diff --git a/setup-email-pve.sh b/setup-email-pve.sh new file mode 100644 index 0000000..0a339f3 --- /dev/null +++ b/setup-email-pve.sh @@ -0,0 +1,61 @@ +#!/bin/bash +set -euo pipefail + +NOTIF_CFG="/etc/pve/notifications.cfg" +PRIV_NOTIF_CFG="/etc/pve/priv/notifications.cfg" + +# Backup-Funktion +backup_file() { + local file=$1 + if [ -f "$file" ]; then + local bak="${file}.bak.$(date +%Y%m%d%H%M%S)" + cp "$file" "$bak" + echo "Backup erstellt: $bak" + fi +} + +backup_file "$NOTIF_CFG" +backup_file "$PRIV_NOTIF_CFG" + +echo "Bitte die SMTP Notification Konfiguration eingeben:" + +read -rp "Author (z.B. MH-PVE02 | MAIERHOME H33): " AUTHOR +read -rp "From-Address (z.B. MH-PVE02@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 + +# notifications.cfg komplett neu schreiben +cat > "$NOTIF_CFG" << EOF +sendmail: mail-to-root + comment Send mails to root@pam's email address + disable true + mailto-user root@pam + +matcher: default-matcher + comment Route all notifications to mail-to-root + mode all + target mailout + +smtp: mailout + author $AUTHOR + from-address $FROMADDR + mailto $MAILTO + mailto-user root@pam + mode $MODE + port $PORT + server $SERVER + username $USERNAME +EOF + +# priv/notifications.cfg komplett neu schreiben +cat > "$PRIV_NOTIF_CFG" << EOF +smtp: mailout + password $SMTP_PASS +EOF + +echo "Konfiguration neu geschrieben. Bitte WebUI prüfen." \ No newline at end of file