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