diff --git a/setup-email-pve.sh b/setup-email-pve.sh index 178445d..28b827f 100644 --- a/setup-email-pve.sh +++ b/setup-email-pve.sh @@ -2,35 +2,35 @@ set -e CFG="/etc/pve/notifications.cfg" -BACKUP="/etc/pve/notifications.cfg.bak.$(date +%Y%m%d%H%M%S)" +if [ ! -f "$CFG" ]; then + echo "Fehler: $CFG nicht gefunden!" + exit 1 +fi + +# Backup anlegen +BACKUP="${CFG}.bak.$(date +%Y%m%d%H%M%S)" cp "$CFG" "$BACKUP" echo "Backup erstellt: $BACKUP" -cat > "$CFG" << 'EOF' -sendmail: mail-to-root - comment Send mails to root@pam's email address - disable false - mailto-user root@pam +# Eingaben abfragen +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 -smtp: mailout - author MH-PVE02 | MAIERHOME H33 - from-address MH-PVE02@vmd55888.de - mailto pbs-dashboard@mail.vmd55888.de - mailto-user root@pam - mode starttls - port 587 - server mail.vmd55888.de - username mailout +# sed ersetzt gezielt die Zeilen in der Sektion smtp: mailout +sed -i "/^smtp: mailout/,/^$/ { + s/^ author .*/ author $AUTHOR/ + s/^ from-address .*/ from-address $FROMADDR/ + s/^ mailto .*/ mailto $MAILTO/ + s/^ server .*/ server $SERVER/ + s/^ port .*/ port $PORT/ + s/^ mode .*/ mode $MODE/ + s/^ username .*/ username $USERNAME/ +}" "$CFG" -matcher: default-matcher - comment Route all notifications to mail-to-root - mode all - target mail-to-root - -policy: default - sender mailout - targets mail-to-root -EOF - -echo "Config geschrieben. Passwort bitte manuell in WebUI setzen." +echo "Konfiguration aktualisiert. Bitte Passwort im WebUI setzen!"