Fix unbound variable, potential collision, and config variable. (#209)

* Fix unbound variable, potential collision, and config variable.

* Return 0 when notification functions finish successfully

---------

Co-authored-by: Matthew Oleksowicz <matt@everyoneneeds.it>
This commit is contained in:
vorezal 2025-06-27 03:10:31 -04:00 committed by GitHub
parent a0e11de383
commit 77f024bb81
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -139,6 +139,8 @@ send_notification() {
fi fi
[[ -n "${snooze}" ]] && cleanup_snooze "${Updates[@]}" [[ -n "${snooze}" ]] && cleanup_snooze "${Updates[@]}"
return 0
} }
### Set DISABLE_DOCKCHECK_NOTIFICATION=false in dockcheck.config ### Set DISABLE_DOCKCHECK_NOTIFICATION=false in dockcheck.config
@ -187,14 +189,17 @@ dockcheck_notification() {
fi fi
fi fi
fi fi
return 0
} }
### Set DISABLE_NOTIFY_UPDATE_NOTIFICATION=false in dockcheck.config ### Set DISABLE_NOTIFY_NOTIFICATION=false in dockcheck.config
### to not send notifications when notify scripts themselves have updates. ### to not send notifications when notify scripts themselves have updates.
notify_update_notification() { notify_update_notification() {
if [[ ! "${DISABLE_NOTIFY_UPDATE_NOTIFICATION:-}" == "true" ]]; then if [[ ! "${DISABLE_NOTIFY_NOTIFICATION:-}" == "true" ]]; then
NotifyUpdateNotify=false NotifyUpdateNotify=false
NotifyError=false NotifyError=false
NotifyUpdates=()
UpdateChannels=( "${enabled_notify_channels[@]}" "v2" ) UpdateChannels=( "${enabled_notify_channels[@]}" "v2" )
@ -207,14 +212,14 @@ notify_update_notification() {
LatestNotifyRelease="$(echo "$LatestNotifySnippet" | sed -n "/${VersionVar}/s/${VersionVar}=//p" | tr -d '"')" LatestNotifyRelease="$(echo "$LatestNotifySnippet" | sed -n "/${VersionVar}/s/${VersionVar}=//p" | tr -d '"')"
if [[ ! "${LatestNotifyRelease}" == "undefined" ]]; then if [[ ! "${LatestNotifyRelease}" == "undefined" ]]; then
if [[ "${!VersionVar}" != "${LatestNotifyRelease}" ]] ; then if [[ "${!VersionVar}" != "${LatestNotifyRelease}" ]] ; then
Updates+=("${NotifyScript}.sh ${!VersionVar} -> ${LatestNotifyRelease}") NotifyUpdates+=("${NotifyScript}.sh ${!VersionVar} -> ${LatestNotifyRelease}")
fi fi
fi fi
fi fi
done done
if [[ -n "${snooze}" ]] && [[ -f "${SnoozeFile}" ]]; then if [[ -n "${snooze}" ]] && [[ -f "${SnoozeFile}" ]]; then
for update in "${Updates[@]}"; do for update in "${NotifyUpdates[@]}"; do
read -a NotifyScript <<< "${update}" read -a NotifyScript <<< "${update}"
found=$(grep -w "${NotifyScript}" "${SnoozeFile}" || printf "") found=$(grep -w "${NotifyScript}" "${SnoozeFile}" || printf "")
if [[ -n "${found}" ]]; then if [[ -n "${found}" ]]; then
@ -232,8 +237,8 @@ notify_update_notification() {
fi fi
if [[ "${NotifyUpdateNotify}" == "true" ]]; then if [[ "${NotifyUpdateNotify}" == "true" ]]; then
if [[ "${#Updates[@]}" -gt 0 ]]; then if [[ "${#NotifyUpdates[@]}" -gt 0 ]]; then
UpdToString=$( printf '%s\\n' "${Updates[@]}" ) UpdToString=$( printf '%s\\n' "${NotifyUpdates[@]}" )
UpdToString=${UpdToString%\\n} UpdToString=${UpdToString%\\n}
NotifyError=false NotifyError=false
@ -247,12 +252,14 @@ notify_update_notification() {
printf "Attempted to send notification to channel ${channel}, but the function was not found. Make sure notify_${channel}.sh is available in the ${ScriptWorkDir} directory or notify_templates subdirectory.\n" printf "Attempted to send notification to channel ${channel}, but the function was not found. Make sure notify_${channel}.sh is available in the ${ScriptWorkDir} directory or notify_templates subdirectory.\n"
done done
[[ -n "${snooze}" ]] && [[ "${NotifyError}" == "false" ]] && update_snooze "${Updates[@]}" [[ -n "${snooze}" ]] && [[ "${NotifyError}" == "false" ]] && update_snooze "${NotifyUpdates[@]}"
fi fi
fi fi
UpdatesPlusDockcheck=("${Updates[@]}") UpdatesPlusDockcheck=("${NotifyUpdates[@]}")
UpdatesPlusDockcheck+=("dockcheck.sh") UpdatesPlusDockcheck+=("dockcheck.sh")
[[ -n "${snooze}" ]] && cleanup_snooze "${UpdatesPlusDockcheck[@]}" [[ -n "${snooze}" ]] && cleanup_snooze "${UpdatesPlusDockcheck[@]}"
fi fi
return 0
} }