new notification structure

This commit is contained in:
mag37
2025-02-09 22:01:08 +01:00
parent 1548b03a9e
commit 71967277aa
6 changed files with 123 additions and 68 deletions

View File

@@ -3,14 +3,36 @@
# Copy/rename this file to notify.sh to enable the notification snippet.
# generic sample, the "Hello World" of notification addons
FromHost=$(hostname)
trigger_notification() {
printf "\n$MessageTitle\n"
printf "\n$MessageBody\n"
}
send_notification() {
[ -s "$ScriptWorkDir"/urls.list ] && releasenotes || Updates=("$@")
UpdToString=$( printf '%s\\n' "${Updates[@]}" )
FromHost=$(hostname)
# platform specific notification code would go here
printf "\n%bGeneric notification addon:%b" "$c_green" "$c_reset"
printf "\nThe following docker containers on %s need to be updated:\n" "$FromHost"
printf "$UpdToString"
MessageTitle="$FromHost - updates available."
printf -v MessageBody "🐋 Containers on $FromHost with updates available:\n$UpdToString"
trigger_notification
}
### Remove or comment out the following function
### to not send notifications when dockcheck itself has updates.
dockcheck_notification() {
printf "\nGeneric dockcheck notification\n"
MessageTitle="$FromHost - New version of dockcheck available."
# Setting the MessageBody variable here.
printf -v MessageBody "Installed version: $1 \nLatest version: $2 \n\nChangenotes: $3"
trigger_notification
}