setup-email-pve.sh aktualisiert
This commit is contained in:
@@ -1,19 +1,32 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -e
|
set -euo pipefail
|
||||||
|
|
||||||
CFG="/etc/pve/notifications.cfg"
|
NOTIF_CFG="/etc/pve/notifications.cfg"
|
||||||
|
PRIV_NOTIF_CFG="/etc/pve/priv/notifications.cfg"
|
||||||
|
|
||||||
if [ ! -f "$CFG" ]; then
|
if [ ! -f "$NOTIF_CFG" ]; then
|
||||||
echo "Fehler: $CFG nicht gefunden!"
|
echo "Fehler: $NOTIF_CFG nicht gefunden!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -f "$PRIV_NOTIF_CFG" ]; then
|
||||||
|
echo "Fehler: $PRIV_NOTIF_CFG nicht gefunden!"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Backup anlegen
|
# Backup anlegen
|
||||||
BACKUP="${CFG}.bak.$(date +%Y%m%d%H%M%S)"
|
backup_file() {
|
||||||
cp "$CFG" "$BACKUP"
|
local file=$1
|
||||||
echo "Backup erstellt: $BACKUP"
|
local bak="${file}.bak.$(date +%Y%m%d%H%M%S)"
|
||||||
|
cp "$file" "$bak"
|
||||||
|
echo "Backup erstellt: $bak"
|
||||||
|
}
|
||||||
|
|
||||||
|
backup_file "$NOTIF_CFG"
|
||||||
|
backup_file "$PRIV_NOTIF_CFG"
|
||||||
|
|
||||||
|
echo "Bitte die SMTP Notification Konfiguration eingeben:"
|
||||||
|
|
||||||
# Eingaben abfragen
|
|
||||||
read -rp "Author (z.B. MH-PVE02 | MAIERHOME H33): " AUTHOR
|
read -rp "Author (z.B. MH-PVE02 | MAIERHOME H33): " AUTHOR
|
||||||
read -rp "From-Address (z.B. MH-PVE02@vmd55888.de): " FROMADDR
|
read -rp "From-Address (z.B. MH-PVE02@vmd55888.de): " FROMADDR
|
||||||
read -rp "Empfänger-Mailadresse (mailto): " MAILTO
|
read -rp "Empfänger-Mailadresse (mailto): " MAILTO
|
||||||
@@ -21,16 +34,24 @@ read -rp "SMTP Server (z.B. mail.vmd55888.de): " SERVER
|
|||||||
read -rp "SMTP Port (z.B. 587): " PORT
|
read -rp "SMTP Port (z.B. 587): " PORT
|
||||||
read -rp "Modus (starttls/ssl/none): " MODE
|
read -rp "Modus (starttls/ssl/none): " MODE
|
||||||
read -rp "SMTP Benutzername: " USERNAME
|
read -rp "SMTP Benutzername: " USERNAME
|
||||||
|
read -rsp "SMTP Passwort: " SMTP_PASS
|
||||||
|
echo
|
||||||
|
|
||||||
# sed ersetzt gezielt die Zeilen in der Sektion smtp: mailout
|
# notifications.cfg anpassen
|
||||||
sed -i "/^smtp: mailout/,/^$/ {
|
sed -i "/^smtp:/,/^$/ {
|
||||||
s/^ author .*/ author $AUTHOR/
|
s/^[[:space:]]*author .*/ author $AUTHOR/
|
||||||
s/^ from-address .*/ from-address $FROMADDR/
|
s/^[[:space:]]*from-address .*/ from-address $FROMADDR/
|
||||||
s/^ mailto .*/ mailto $MAILTO/
|
s/^[[:space:]]*mailto .*/ mailto $MAILTO/
|
||||||
s/^ server .*/ server $SERVER/
|
s/^[[:space:]]*server .*/ server $SERVER/
|
||||||
s/^ port .*/ port $PORT/
|
s/^[[:space:]]*port .*/ port $PORT/
|
||||||
s/^ mode .*/ mode $MODE/
|
s/^[[:space:]]*mode .*/ mode $MODE/
|
||||||
s/^ username .*/ username $USERNAME/
|
s/^[[:space:]]*username .*/ username $USERNAME/
|
||||||
}" "$CFG"
|
}" "$NOTIF_CFG"
|
||||||
|
|
||||||
echo "Konfiguration aktualisiert. Bitte Passwort im WebUI setzen!"
|
# priv/notifications.cfg anpassen
|
||||||
|
sed -i "/^smtp:/,/^$/ {
|
||||||
|
s/^[[:space:]]*password .*/ password $SMTP_PASS/
|
||||||
|
}" "$PRIV_NOTIF_CFG"
|
||||||
|
|
||||||
|
echo "Konfiguration wurde aktualisiert."
|
||||||
|
echo "Bitte überprüfe in der WebUI, ob alles korrekt übernommen wurde."
|
||||||
|
|||||||
Reference in New Issue
Block a user