fix creating msmtprc
All checks were successful
Docker Build Smart Logic / Build amd64 & arm64 (push) Successful in 16s

This commit is contained in:
2026-02-07 00:05:32 +01:00
parent e208f30559
commit 72675a40d8

View File

@@ -12,7 +12,7 @@ if [ ! -f "$STATE_FILE" ] || ! jq -e . "$STATE_FILE" >/dev/null 2>&1; then
fi
while true; do
# 1. Config laden
if [ -f "$CONFIG_FILE" ]; then
source "$CONFIG_FILE"
else
@@ -20,6 +20,23 @@ while true; do
sleep 60; continue
fi
# 2. HIER NEU: msmtp Konfiguration IMMER neu schreiben
# Damit ist sie immer verfügbar für Tests und Updates
cat <<EOF > /etc/msmtprc
defaults
auth on
tls on
tls_trust_file /etc/ssl/certs/ca-certificates.crt
logfile /var/log/msmtp.log
account default
host $SMTP_HOST
port $SMTP_PORT
from $EMAIL_FROM
user $SMTP_USER
password $SMTP_PASS
EOF
chmod 600 /etc/msmtprc
INTERVAL=${CHECK_INTERVAL:-3600}
UPDATES_FOUND=""
echo "--- Starte Check: $(date) ---"
@@ -92,22 +109,12 @@ while true; do
# E-Mail Versand
if [ -n "$UPDATES_FOUND" ]; then
# Dynamische msmtp config (wie vorher)
cat <<EOF > /etc/msmtprc
defaults
auth on
tls on
tls_trust_file /etc/ssl/certs/ca-certificates.crt
account default
host $SMTP_HOST
port $SMTP_PORT
from $EMAIL_FROM
user $SMTP_USER
password $SMTP_PASS
EOF
chmod 600 /etc/msmtprc
echo -e "Subject: Watchdog Alert\n\n$UPDATES_FOUND" | msmtp "$EMAIL_TO"
echo " 📧 E-Mail gesendet."
echo " 📧 Versuche E-Mail zu senden an $EMAIL_TO..."
if echo -e "Subject: Watchdog Alert\n\n$UPDATES_FOUND" | timeout 20s msmtp --debug "$EMAIL_TO" 2>&1; then
echo " ✅ E-Mail erfolgreich versendet."
else
echo " ❌ FEHLER beim E-Mail Versand (siehe oben)."
fi
fi
echo "Nächster Scan in $INTERVAL s."