Auto backup: 2026-02-21 07:01

This commit is contained in:
Krilly
2026-02-21 07:01:51 +00:00
parent 8757148122
commit 17b5b82d99
2012 changed files with 352552 additions and 331 deletions

View File

@@ -13,11 +13,11 @@ FAIL_THRESHOLD="${FAIL_THRESHOLD:-3}" # consecutive failures before es
WATCHDOG_LOG="${WATCHDOG_LOG:-$HOME/.openclaw/watchdog.log}"
GOOD_CONFIG_PATH="${GOOD_CONFIG_PATH:-$HOME/.openclaw/config.yaml.good}"
# Notification settings (Telegram + Gotify)
# Notification settings (Telegram + ntfy)
TELEGRAM_BOT_TOKEN="${TELEGRAM_BOT_TOKEN:-}"
TELEGRAM_CHAT="${TELEGRAM_CHAT:-1793951355}"
GOTIFY_URL="${GOTIFY_URL:-http://runtipi.kangaroo-eel.ts.net:8129}"
GOTIFY_TOKEN="${GOTIFY_TOKEN:-AGKnHafW3FGzBlt}"
NTFY_URL="${NTFY_URL:-}"
NTFY_TOPIC="${NTFY_TOPIC:-}"
# Legacy Discord settings (optional, for backwards compat)
DISCORD_CHANNEL_ID="${DISCORD_CHANNEL_ID:-}"
@@ -62,18 +62,31 @@ telegram_send() {
>/dev/null 2>&1 || log "WARN: Failed to send Telegram message"
}
# ─── Gotify messaging ────────────────────────────────────────────────────────
gotify_send() {
# ─── ntfy messaging ────────────────────────────────────────────────────────
ntfy_send() {
local title="$1"
local msg="$2"
local priority="${3:-5}"
[[ -z "$GOTIFY_TOKEN" ]] && return 0
local priority="${3:-4}" # 1-5 or low|default|high|urgent
local sound="${4:-default}"
[[ -z "$NTFY_URL" ]] && return 0
[[ -z "$NTFY_TOPIC" ]] && return 0
# Enforce minimum priority (default 4)
local minp="${NTFY_MIN_PRIORITY:-4}"
if [[ "$priority" =~ ^[0-9]+$ ]] && [[ "$minp" =~ ^[0-9]+$ ]]; then
if (( priority < minp )); then
priority="$minp"
fi
fi
curl -sf -X POST \
"${GOTIFY_URL}/message?token=${GOTIFY_TOKEN}" \
-H "Content-Type: application/json" \
-d "{\"title\": \"$title\", \"message\": \"$msg\", \"priority\": $priority}" \
>/dev/null 2>&1 || log "WARN: Failed to send Gotify message"
"${NTFY_URL%/}/${NTFY_TOPIC}" \
-H "Title: $title" \
-H "Priority: $priority" \
-H "Sound: $sound" \
-d "$msg" \
>/dev/null 2>&1 || log "WARN: Failed to send ntfy message"
}
# ─── Send to all configured channels ─────────────────────────────────────────
@@ -84,7 +97,7 @@ send_notification() {
discord_send "$msg"
telegram_send "$msg"
gotify_send "$title" "$msg" "$priority"
ntfy_send "$title" "$msg" "4" "default"
}
# ─── Health check ─────────────────────────────────────────────────────────────
@@ -155,7 +168,7 @@ send_recovery() {
# ─── Main loop ────────────────────────────────────────────────────────────────
main() {
log "Watchdog started (interval=${CHECK_INTERVAL}s, threshold=${FAIL_THRESHOLD}, health=${HEALTH_URL})"
log "Notifications: Telegram=${TELEGRAM_CHAT:+enabled}, Gotify=${GOTIFY_TOKEN:+enabled}, Discord=${DISCORD_CHANNEL_ID:+enabled}"
log "Notifications: Telegram=${TELEGRAM_CHAT:+enabled}, ntfy=${NTFY_TOPIC:+enabled}, Discord=${DISCORD_CHANNEL_ID:+enabled}"
while true; do
if check_health; then