mirror of
https://github.com/ergosteur/ergo-proxmox-scripts.git
synced 2026-10-28 13:00:37 -04:00
Move watchdog alert address into conf/
Both watchdogs hardcoded the notification address. Read it from conf/watchdog.conf instead, matching the pattern used for the other credentials, so the repo carries no real contact details. If the config is absent the watchdogs still run and log; sendAlert notes the missing address and skips the mail rather than invoking mail(1) with an empty recipient. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
0580a9530a
commit
23196eafed
+15
-1
@@ -13,7 +13,17 @@ declare -A Containers=(
|
||||
)
|
||||
|
||||
logFile="/var/log/proxmox_lxc_watchdog.log"
|
||||
email="your_email@example.com"
|
||||
|
||||
# Alert address comes from conf/watchdog.conf (see conf/watchdog.conf.example),
|
||||
# resolved relative to this script so it works from a checkout or /opt/ergosteur.
|
||||
SCRIPT_DIR=$(CDPATH= cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)
|
||||
CONFIG=${WATCHDOG_CONFIG:-$SCRIPT_DIR/conf/watchdog.conf}
|
||||
email=""
|
||||
if [[ -r "$CONFIG" ]]; then
|
||||
# shellcheck source=/dev/null
|
||||
. "$CONFIG"
|
||||
email="${WATCHDOG_EMAIL:-}"
|
||||
fi
|
||||
|
||||
# Log function
|
||||
log () {
|
||||
@@ -26,6 +36,10 @@ log () {
|
||||
sendAlert () {
|
||||
subject="[Proxmox LXC WatchDog] $1"
|
||||
body="$2"
|
||||
if [[ -z "$email" ]]; then
|
||||
log "No WATCHDOG_EMAIL configured in $CONFIG; skipping alert: $subject"
|
||||
return
|
||||
fi
|
||||
echo -e "$body" | mail -s "$subject" "$email"
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user