mirror of
https://github.com/mag37/dockcheck.git
synced 2026-03-04 08:00:35 +01:00
Add file notification channel
This commit is contained in:
parent
37f33d7a06
commit
6af9ff3eb8
5 changed files with 41 additions and 6 deletions
12
notify_templates/notify_file.sh
Normal file
12
notify_templates/notify_file.sh
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
### DISCLAIMER: This is a third party addition to dockcheck - best effort testing.
|
||||
NOTIFY_FILE_VERSION="v0.1"
|
||||
#
|
||||
# Leave (or place) this file in the "notify_templates" subdirectory within the same directory as the main dockcheck.sh script.
|
||||
# If you instead wish make your own modifications, make a copy in the same directory as the main dockcheck.sh script.
|
||||
|
||||
trigger_file_notification() {
|
||||
NotifyFile="${ScriptWorkDir}/updates_available.txt"
|
||||
|
||||
echo "${MessageBody}" > ${NotifyFile}
|
||||
|
||||
}
|
||||
|
|
@ -114,6 +114,23 @@ send_notification() {
|
|||
UpdNotifyCount="${#Updates[@]}"
|
||||
fi
|
||||
|
||||
if [[ "${enabled_notify_channels[@]}" == *"file"* ]]; then
|
||||
UpdToString=$( printf '%s, ' "${Updates[@]}" )
|
||||
UpdToString="${UpdToString%, }"
|
||||
|
||||
if [[ -z "${UpdToString}" ]]; then
|
||||
UpdToString="None"
|
||||
fi
|
||||
|
||||
printf "\nSending file notification\n"
|
||||
printf -v MessageBody "${UpdToString}"
|
||||
|
||||
exec_if_exists_or_fail trigger_file_notification || \
|
||||
printf "Attempted to send notification to channel file, but the function was not found. Make sure notify_file.sh is available in the ${ScriptWorkDir} directory or notify_templates subdirectory.\n"
|
||||
|
||||
remove_channel file
|
||||
fi
|
||||
|
||||
NotifyError=false
|
||||
|
||||
if [[ "${UpdNotifyCount}" -gt 0 ]]; then
|
||||
|
|
@ -238,9 +255,11 @@ notify_update_notification() {
|
|||
printf -v MessageBody "Notify templates on $FromHost with updates available:\n${UpdToString}\n"
|
||||
|
||||
for channel in "${enabled_notify_channels[@]}"; do
|
||||
printf "Sending notify template update notification - ${channel}\n"
|
||||
exec_if_exists_or_fail trigger_${channel}_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"
|
||||
if [[ ! "${channel}" == "file" ]]; then
|
||||
printf "Sending notify template update notification - ${channel}\n"
|
||||
exec_if_exists_or_fail trigger_${channel}_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"
|
||||
fi
|
||||
done
|
||||
|
||||
[[ -n "${snooze}" ]] && [[ "${NotifyError}" == "false" ]] && update_snooze "${NotifyUpdates[@]}"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue