mirror of
https://github.com/mag37/dockcheck.git
synced 2026-02-14 23:38:15 +01:00
* Refactor notifications and add helper functions * Add helper functions to simplify sourcing files and executing functions if they exist * Create notify_v2.sh wrapper script * Simplify and consolidate notification logic within notify_v2.sh * Support notification management via environment variables * Move secrets to dockcheck.config * Fix NOTIFY_CHANNELS default value when not set * Feedback changes * Remove leading spaces from MessageBody * Check for valid notify v2 variables * Warn on missing configuration and bypass notifications * Update readme * Additional feedback fixes * More comments in default.config with different # depth for comments and settings * Rename NOTIFY_TOPIC_NAME variable to NTFY_TOPIC_NAME for consistency * Add TELEGRAM_TOPIC_ID * Fix AppriseURL variable * Add an ending newline to all MessageBody statements for consistency * Remove troubleshooting echo statement * Prevent attempting to trigger notifications for notification templates if versions are the same --------- Co-authored-by: Matthew Oleksowicz <matt@everyoneneeds.it>
22 lines
952 B
Bash
22 lines
952 B
Bash
### DISCLAIMER: This is a third party addition to dockcheck - best effort testing.
|
|
NOTIFY_SLACK_VERSION="v0.2"
|
|
#
|
|
# Setup app and token at https://api.slack.com/tutorials/tracks/posting-messages-with-curl
|
|
# Do not modify this file directly. Set SLACK_ACCESS_TOKEN, and SLACK_CHANNEL_ID in your dockcheck.config file.
|
|
|
|
if [[ -z "${SLACK_ACCESS_TOKEN:-}" ]] || [[ -z "${SLACK_CHANNEL_ID:-}" ]]; then
|
|
printf "Slack notification channel enabled, but required configuration variables are missing. Slack notifications will not be sent.\n"
|
|
|
|
remove_channel slack
|
|
fi
|
|
|
|
trigger_slack_notification() {
|
|
AccessToken="${SLACK_ACCESS_TOKEN}" # e.g. SLACK_ACCESS_TOKEN=some-token
|
|
ChannelID="${SLACK_CHANNEL_ID}" # e.g. CHANNEL_ID=mychannel
|
|
SlackUrl="https://slack.com/api/chat.postMessage"
|
|
|
|
curl -sS -o /dev/null --show-error --fail \
|
|
-d "text=$MessageBody" -d "channel=$ChannelID" \
|
|
-H "Authorization: Bearer $AccessToken" \
|
|
-X POST $SlackUrl
|
|
}
|