setup-email-pve.sh hinzugefügt
This commit is contained in:
61
setup-email-pve.sh
Normal file
61
setup-email-pve.sh
Normal file
@@ -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."
|
||||
Reference in New Issue
Block a user