setup-email-pbs.sh aktualisiert
This commit is contained in:
@@ -4,6 +4,9 @@ set -euo pipefail
|
||||
NOTIF_CFG="/etc/proxmox-backup/notifications.cfg"
|
||||
PRIV_NOTIF_CFG="/etc/proxmox-backup/notifications-priv.cfg"
|
||||
|
||||
# -----------------------------
|
||||
# Backup-Funktion
|
||||
# -----------------------------
|
||||
backup_file() {
|
||||
local file=$1
|
||||
if [ -f "$file" ]; then
|
||||
@@ -13,21 +16,69 @@ backup_file() {
|
||||
fi
|
||||
}
|
||||
|
||||
# -----------------------------
|
||||
# Pflichtfeld-Reader
|
||||
# $1 = Prompt
|
||||
# $2 = Variablenname
|
||||
# $3 = Optionaler Default
|
||||
# -----------------------------
|
||||
read_required() {
|
||||
local prompt="$1"
|
||||
local varname="$2"
|
||||
local default="${3:-}"
|
||||
local input
|
||||
|
||||
while true; do
|
||||
if [[ -n "$default" ]]; then
|
||||
read -rp "$prompt [$default]: " input
|
||||
input=${input:-$default}
|
||||
else
|
||||
read -rp "$prompt: " input
|
||||
fi
|
||||
|
||||
if [[ -n "$input" ]]; then
|
||||
printf -v "$varname" '%s' "$input"
|
||||
break
|
||||
fi
|
||||
|
||||
echo "❌ Eingabe darf nicht leer sein!"
|
||||
done
|
||||
}
|
||||
|
||||
# -----------------------------
|
||||
# Backups
|
||||
# -----------------------------
|
||||
backup_file "$NOTIF_CFG"
|
||||
backup_file "$PRIV_NOTIF_CFG"
|
||||
|
||||
echo
|
||||
echo "Bitte die SMTP Notification Konfiguration für PBS eingeben:"
|
||||
|
||||
read -rp "Author (z.B. MH-PBS01 | MAIERHOME): " AUTHOR
|
||||
read -rp "From-Address (z.B. MH-PBS01@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 "(Alle Felder sind Pflicht – Enter übernimmt ggf. den Default)"
|
||||
echo
|
||||
|
||||
# -----------------------------
|
||||
# Eingaben
|
||||
# -----------------------------
|
||||
read_required "Author" AUTHOR
|
||||
read_required "From-Address" FROMADDR
|
||||
|
||||
read_required "Empfänger-Mailadresse (mailto)" MAILTO "admin@vmd55888.de"
|
||||
read_required "SMTP Server" SERVER "mail.vmd55888.de"
|
||||
read_required "SMTP Port" PORT "587"
|
||||
read_required "Modus (starttls/ssl/none)" MODE "starttls"
|
||||
read_required "SMTP Benutzername" USERNAME "MH-PBS01@vmd55888.de"
|
||||
|
||||
# Passwort (Pflichtfeld, versteckt)
|
||||
while true; do
|
||||
read -rsp "SMTP Passwort: " SMTP_PASS
|
||||
echo
|
||||
[[ -n "$SMTP_PASS" ]] && break
|
||||
echo "❌ Passwort darf nicht leer sein!"
|
||||
done
|
||||
|
||||
# -----------------------------
|
||||
# notifications.cfg schreiben
|
||||
# -----------------------------
|
||||
cat > "$NOTIF_CFG" << EOF
|
||||
sendmail: mail-to-root
|
||||
comment Send mails to root@pam's email address
|
||||
@@ -50,9 +101,13 @@ smtp: mailout
|
||||
username $USERNAME
|
||||
EOF
|
||||
|
||||
# -----------------------------
|
||||
# priv/notifications-priv.cfg schreiben
|
||||
# -----------------------------
|
||||
cat > "$PRIV_NOTIF_CFG" << EOF
|
||||
smtp: mailout
|
||||
password $SMTP_PASS
|
||||
EOF
|
||||
|
||||
echo "PBS Notification Konfiguration neu geschrieben. Bitte WebUI prüfen."
|
||||
echo
|
||||
echo "✅ PBS Notification Konfiguration neu geschrieben. Bitte WebUI prüfen."
|
||||
|
||||
Reference in New Issue
Block a user