mirror of
https://github.com/mag37/dockcheck.git
synced 2026-02-15 07:48:14 +01:00
Add file notification channel (#222)
* Add file notification channel * Bypass file channel notifications for dockcheck.sh script * Implement notification channel template reuse and advanced configuration variables. * Fix text insertion formatting for dockcheck script and container updates. * Fix dockcheck.sh notification csv and text output. * Fix ntfy variable references and replace tr for uppercase conversion. * Fix ALLOWEMPTY logic, undefined snippet case, and README formatting. * Refactor notification send/skip logic. Adjust missing variable return codes. * Adjust notifications README section for clarity and readability. --------- Co-authored-by: Matthew Oleksowicz <matt@everyoneneeds.it>
This commit is contained in:
parent
37f33d7a06
commit
31a45f1d84
18 changed files with 620 additions and 267 deletions
|
|
@ -1,5 +1,5 @@
|
|||
### DISCLAIMER: This is a third party addition to dockcheck - best effort testing.
|
||||
NOTIFY_HA_VERSION="v0.1"
|
||||
NOTIFY_HA_VERSION="v0.2"
|
||||
#
|
||||
# This is an integration that makes it possible to send notifications via Home Assistant (https://www.home-assistant.io/integrations/notify/)
|
||||
# You need to generate a long-lived access token in Home Sssistant to be used here (https://developers.home-assistant.io/docs/auth_api/#long-lived-access-token)
|
||||
|
|
@ -7,15 +7,28 @@ NOTIFY_HA_VERSION="v0.1"
|
|||
# If you instead wish make your own modifications, make a copy in the same directory as the main dockcheck.sh script.
|
||||
# Do not modify this file directly within the "notify_templates" subdirectory. Set HA_ENTITY, HA_URL and HA_TOKEN in your dockcheck.config file.
|
||||
|
||||
if [[ -z "${HA_ENTITY:-}" ]] || [[ -z "${HA_URL:-}" ]] || [[ -z "${HA_TOKEN:-}" ]]; then
|
||||
printf "Home Assistant notification channel enabled, but required configuration variables are missing. Home assistant notifications will not be sent.\n"
|
||||
|
||||
remove_channel HA
|
||||
fi
|
||||
|
||||
trigger_HA_notification() {
|
||||
AccessToken="${HA_TOKEN}"
|
||||
Url="${HA_URL}/api/services/notify/${HA_ENTITY}"
|
||||
if [[ -n "$1" ]]; then
|
||||
HA_channel="$1"
|
||||
else
|
||||
HA_channel="HA"
|
||||
fi
|
||||
|
||||
UpperChannel="${HA_channel^^}"
|
||||
|
||||
HAEntityVar="${UpperChannel}_ENTITY"
|
||||
HAUrlVar="${UpperChannel}_URL"
|
||||
HATokenVar="${UpperChannel}_TOKEN"
|
||||
|
||||
if [[ -z "${!HAEntityVar:-}" ]] || [[ -z "${!HAUrlVar:-}" ]] || [[ -z "${!HATokenVar:-}" ]]; then
|
||||
printf "The ${HA_channel} notification channel is enabled, but required configuration variables are missing. Home assistant notifications will not be sent.\n"
|
||||
|
||||
remove_channel HA
|
||||
return 0
|
||||
fi
|
||||
|
||||
AccessToken="${!HATokenVar}"
|
||||
Url="${!HAUrlVar}/api/services/notify/${!HAEntityVar}"
|
||||
JsonData=$( "$jqbin" -n \
|
||||
--arg body "$MessageBody" \
|
||||
'{"title": "dockcheck update", "message": $body}' )
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue