++ Add Readme + Multiple S3 Configs
This commit is contained in:
38
sync.sh
38
sync.sh
@@ -227,15 +227,37 @@ gotify_send() {
|
||||
return 0
|
||||
fi
|
||||
|
||||
# Invia la notifica in background per non bloccare la sync
|
||||
# Usa il formato Markdown per il messaggio
|
||||
wget -q --timeout=10 --tries=2 -O /dev/null \
|
||||
--post-data="$(printf '{"title":"%s","message":"%s","priority":%s,"extras":{"client::display":{"contentType":"text/markdown"}}}' \
|
||||
"${title}" "${message}" "${priority}")" \
|
||||
--header="Content-Type: application/json" \
|
||||
"${GOTIFY_URL}/message?token=${GOTIFY_TOKEN}" 2>/dev/null &
|
||||
# Crea il payload JSON con corretta escape
|
||||
# Usa jq se disponibile, altrimenti fallback a printf con escape
|
||||
local payload
|
||||
if command -v jq &>/dev/null; then
|
||||
payload=$(jq -c -n \
|
||||
--arg title "$title" \
|
||||
--arg message "$message" \
|
||||
--argjson priority "$priority" \
|
||||
'{title: $title, message: $message, priority: $priority, extras: {"client::display": {contentType: "text/markdown"}}}')
|
||||
else
|
||||
# Fallback: escape manuale per i caratteri JSON
|
||||
title=$(printf '%s' "$title" | sed 's/\\/\\\\/g; s/"/\\"/g')
|
||||
message=$(printf '%s' "$message" | sed 's/\\/\\\\/g; s/"/\\"/g; s/$/, /g' | sed 's/, $//')
|
||||
payload="{\"title\":\"${title}\",\"message\":\"${message}\",\"priority\":${priority},\"extras\":{\"client::display\":{\"contentType\":\"text/markdown\"}}}"
|
||||
fi
|
||||
|
||||
log_info "Notifica Gotify inviata: ${title}"
|
||||
# Invia la notifica in background per non bloccare la sync
|
||||
# Cattura il risultato per il debug
|
||||
wget -q --timeout=10 --tries=2 -O /dev/null \
|
||||
--post-data="${payload}" \
|
||||
--header="Content-Type: application/json" \
|
||||
"${GOTIFY_URL}/message?token=${GOTIFY_TOKEN}" 2>/tmp/gotify_error.log &
|
||||
|
||||
local pid=$!
|
||||
wait $pid 2>/dev/null
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
log_info "Notifica Gotify inviata: ${title}"
|
||||
else
|
||||
log_warn "Errore invio Gotify: $(cat /tmp/gotify_error.log 2>/dev/null || echo 'sconosciuto')"
|
||||
fi
|
||||
}
|
||||
|
||||
gotify_notify_sync_result() {
|
||||
|
||||
Reference in New Issue
Block a user