dockcheck/notify_templates/notify_gotify.sh

30 lines
1 KiB
Bash
Raw Normal View History

### DISCLAIMER: This is a third party addition to dockcheck - best effort testing.
#
# Copy/rename this file to notify.sh to enable the notification snippet.
# Required receiving services must already be set up.
# Modify to fit your setup - set GotifyUrl and GotifyToken.
send_notification() {
2024-10-07 21:28:31 +02:00
[ -s "$ScriptWorkDir"/urls.list ] && releasenotes || Updates=("$@")
UpdToString=$( printf '%s\\n' "${Updates[@]}" )
FromHost=$(hostname)
# platform specific notification code would go here
printf "\nSending Gotify notification\n"
# Setting the MessageTitle and MessageBody variable here.
MessageTitle="${FromHost} - updates available."
Upstream patches and additional patching (#2) * Ensures DSM GUI refreshes its updates * Removed whale icon and changed verbosity * Added addon for Prometheus+node_exporter * Changed local image check to check on image ID rather than name * Update podcheck.sh changed docker->podman, typo * - **v0.6.0**: - **Grafana & Prometheus Integration:** - Added a detailed Prometheus metrics exporter that now reports not only the number of containers with updates, no-updates, and errors, but also the total number of containers checked, the duration of the update check, and the epoch timestamp of the last check. - Enhanced documentation with instructions on integrating these metrics with Grafana for visual monitoring. - **Improved Error Handling & Code Refactoring:** - Introduced `set -euo pipefail` and local variable scoping within functions to improve reliability and prevent unexpected behaviour. - Standardised container name handling and refined the Quadlet detection logic. - **Self-Update Enhancements:** - Updated the self-update mechanism to support both Git-based and HTTP-based updates, with an automatic restart that preserves the original arguments. - **Miscellaneous Improvements:** - Enhanced dependency installer to support both package manager and static binary installations for `jq` and `regctl`. - General code refactoring across the project for better readability and maintainability. * Update podcheck.sh * increment version * Update Quadlet detection logic Update Quadlet detection logic to support flexible service naming - Modified the quadlet update block to first try an exact match for "$i.service". - If no exact match is found, build a regex pattern from the container name (allowing underscores and hyphens interchangeably) and search user service units. - When multiple candidate units are found, the script attempts to choose the one that exactly matches (ignoring case) or defaults to the first candidate. - This update allows containers like "containera" to match service units named "container_a.service" and supports scenarios with multiple counterparts (e.g., matrix-a, matrix-b, matrix_db). * search name fix * fixes to arg parsing * Logic overhaul, verbose output and better syntax * Added support for prometheus --------- Co-authored-by: mag37 <robin.ivehult@gmail.com>
2025-02-25 14:12:01 +00:00
printf -v MessageBody "Containers on $FromHost with updates available:\n$UpdToString"
# Modify to fit your setup:
GotifyToken="Your Gotify token here"
GotifyUrl="https://api.gotify/message?token=${GotifyToken}"
curl \
-F "title=${MessageTitle}" \
-F "message=${MessageBody}" \
-F "priority=5" \
Upstream patches and additional patching (#2) * Ensures DSM GUI refreshes its updates * Removed whale icon and changed verbosity * Added addon for Prometheus+node_exporter * Changed local image check to check on image ID rather than name * Update podcheck.sh changed docker->podman, typo * - **v0.6.0**: - **Grafana & Prometheus Integration:** - Added a detailed Prometheus metrics exporter that now reports not only the number of containers with updates, no-updates, and errors, but also the total number of containers checked, the duration of the update check, and the epoch timestamp of the last check. - Enhanced documentation with instructions on integrating these metrics with Grafana for visual monitoring. - **Improved Error Handling & Code Refactoring:** - Introduced `set -euo pipefail` and local variable scoping within functions to improve reliability and prevent unexpected behaviour. - Standardised container name handling and refined the Quadlet detection logic. - **Self-Update Enhancements:** - Updated the self-update mechanism to support both Git-based and HTTP-based updates, with an automatic restart that preserves the original arguments. - **Miscellaneous Improvements:** - Enhanced dependency installer to support both package manager and static binary installations for `jq` and `regctl`. - General code refactoring across the project for better readability and maintainability. * Update podcheck.sh * increment version * Update Quadlet detection logic Update Quadlet detection logic to support flexible service naming - Modified the quadlet update block to first try an exact match for "$i.service". - If no exact match is found, build a regex pattern from the container name (allowing underscores and hyphens interchangeably) and search user service units. - When multiple candidate units are found, the script attempts to choose the one that exactly matches (ignoring case) or defaults to the first candidate. - This update allows containers like "containera" to match service units named "container_a.service" and supports scenarios with multiple counterparts (e.g., matrix-a, matrix-b, matrix_db). * search name fix * fixes to arg parsing * Logic overhaul, verbose output and better syntax * Added support for prometheus --------- Co-authored-by: mag37 <robin.ivehult@gmail.com>
2025-02-25 14:12:01 +00:00
-X POST "${GotifyUrl}" 1> /dev/null
}