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
[[ -n "${snooze}" ]] && cleanup_snooze "${Updates[@]}"
return 0
}
### Set DISABLE_DOCKCHECK_NOTIFICATION=false in dockcheck.config
@ -187,14 +189,17 @@ dockcheck_notification() {
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.
notify_update_notification() {
if [[ ! "${DISABLE_NOTIFY_UPDATE_NOTIFICATION:-}" == "true" ]]; then
if [[ ! "${DISABLE_NOTIFY_NOTIFICATION:-}" == "true" ]]; then
NotifyUpdateNotify=false
NotifyError=false
NotifyUpdates=()
UpdateChannels=( "${enabled_notify_channels[@]}" "v2" )
@ -207,14 +212,14 @@ notify_update_notification() {
LatestNotifyRelease="$(echo "$LatestNotifySnippet" | sed -n "/${VersionVar}/s/${VersionVar}=//p" | tr -d '"')"
if [[ ! "${LatestNotifyRelease}" == "undefined" ]]; then
if [[ "${!VersionVar}" != "${LatestNotifyRelease}" ]] ; then
Updates+=("${NotifyScript}.sh ${!VersionVar} -> ${LatestNotifyRelease}")
NotifyUpdates+=("${NotifyScript}.sh ${!VersionVar} -> ${LatestNotifyRelease}")
fi
fi
fi
done
if [[ -n "${snooze}" ]] && [[ -f "${SnoozeFile}" ]]; then
for update in "${Updates[@]}"; do
for update in "${NotifyUpdates[@]}"; do
read -a NotifyScript <<< "${update}"
found=$(grep -w "${NotifyScript}" "${SnoozeFile}" || printf "")
if [[ -n "${found}" ]]; then
@ -232,8 +237,8 @@ notify_update_notification() {
fi
if [[ "${NotifyUpdateNotify}" == "true" ]]; then
if [[ "${#Updates[@]}" -gt 0 ]]; then
UpdToString=$( printf '%s\\n' "${Updates[@]}" )
if [[ "${#NotifyUpdates[@]}" -gt 0 ]]; then
UpdToString=$( printf '%s\\n' "${NotifyUpdates[@]}" )
UpdToString=${UpdToString%\\n}
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"
done
[[ -n "${snooze}" ]] && [[ "${NotifyError}" == "false" ]] && update_snooze "${Updates[@]}"
[[ -n "${snooze}" ]] && [[ "${NotifyError}" == "false" ]] && update_snooze "${NotifyUpdates[@]}"
fi
fi
UpdatesPlusDockcheck=("${Updates[@]}")
UpdatesPlusDockcheck=("${NotifyUpdates[@]}")
UpdatesPlusDockcheck+=("dockcheck.sh")
[[ -n "${snooze}" ]] && cleanup_snooze "${UpdatesPlusDockcheck[@]}"
fi
return 0
}