setup-email-pve.sh aktualisiert
This commit is contained in:
@@ -1,47 +1,44 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
read -rp "SMTP author (z.B. MH-PVE02 | MAIERHOME H33): " AUTHOR
|
||||
read -rp "SMTP from-address (z.B. MH-PVE02@vmd55888.de): " FROMADDR
|
||||
read -rp "SMTP server (z.B. mail.vmd55888.de): " SERVER
|
||||
read -rp "SMTP port (z.B. 587): " PORT
|
||||
read -rp "SMTP mode (starttls/ssl/none): " MODE
|
||||
read -rp "SMTP username: " USERNAME
|
||||
read -rsp "SMTP password: " PASSWORD
|
||||
echo
|
||||
read -rp "Mailto Adresse (Empfänger): " MAILTO
|
||||
CFG="/etc/pve/notifications.cfg"
|
||||
BACKUP="/etc/pve/notifications.cfg.bak.$(date +%Y%m%d%H%M%S)"
|
||||
|
||||
SENDER="mailout"
|
||||
TARGET="mail-to-root"
|
||||
MATCHER="default-matcher"
|
||||
POLICY="default"
|
||||
cp "$CFG" "$BACKUP"
|
||||
echo "Backup angelegt: $BACKUP"
|
||||
|
||||
echo "Setze SMTP Sender..."
|
||||
pvesh set /config/notifications/senders/$SENDER \
|
||||
--type smtp \
|
||||
--author "$AUTHOR" \
|
||||
--from-address "$FROMADDR" \
|
||||
--server "$SERVER" \
|
||||
--port "$PORT" \
|
||||
--mode "$MODE" \
|
||||
--username "$USERNAME" \
|
||||
--password "$PASSWORD"
|
||||
read -rp "Author (z.B. MH-PVE02 | MAIERHOME H33): " AUTHOR
|
||||
read -rp "From-Address (z.B. MH-PVE02@vmd55888.de): " FROMADDR
|
||||
read -rp "SMTP Server (z.B. mail.vmd55888.de): " SERVER
|
||||
read -rp "SMTP Port (z.B. 587): " PORT
|
||||
read -rp "Mode (starttls/ssl/none): " MODE
|
||||
read -rp "Username: " USERNAME
|
||||
read -rp "Mailto Adresse: " MAILTO
|
||||
|
||||
echo "Setze Ziel..."
|
||||
pvesh set /config/notifications/targets/$TARGET \
|
||||
--type sendmail \
|
||||
--mailto "$MAILTO" \
|
||||
--mailto-user root@pam
|
||||
cat > "$CFG" <<EOF
|
||||
sendmail: mail-to-root
|
||||
comment Send mails to root@pam's email address
|
||||
disable false
|
||||
mailto-user root@pam
|
||||
|
||||
echo "Setze Matcher..."
|
||||
pvesh set /config/notifications/matchers/$MATCHER \
|
||||
--comment "Route all notifications to $TARGET" \
|
||||
--mode all \
|
||||
--target "$TARGET"
|
||||
smtp: mailout
|
||||
author $AUTHOR
|
||||
from-address $FROMADDR
|
||||
mailto $MAILTO
|
||||
mailto-user root@pam
|
||||
mode $MODE
|
||||
port $PORT
|
||||
server $SERVER
|
||||
username $USERNAME
|
||||
|
||||
echo "Setze Policy..."
|
||||
pvesh set /config/notifications/policies/$POLICY \
|
||||
--sender "$SENDER" \
|
||||
--targets "$TARGET"
|
||||
matcher: default-matcher
|
||||
comment Route all notifications to mail-to-root
|
||||
mode all
|
||||
target mail-to-root
|
||||
|
||||
echo "Fertig! Prüfe die Einstellungen in der WebUI."
|
||||
policy: default
|
||||
sender mailout
|
||||
targets mail-to-root
|
||||
EOF
|
||||
|
||||
echo "Config geschrieben. Bitte Passwort manuell in der WebUI setzen."
|
||||
|
||||
Reference in New Issue
Block a user