mirror of
https://github.com/mag37/dockcheck.git
synced 2026-02-15 07:48:14 +01:00
Fix ALLOWEMPTY logic, undefined snippet case, and README formatting.
This commit is contained in:
parent
8bbc73482e
commit
51c9987d45
2 changed files with 21 additions and 20 deletions
24
README.md
24
README.md
|
|
@ -26,12 +26,12 @@ ___
|
|||
- Added support for multiple notifications using the same template
|
||||
- Added support for notification output format
|
||||
- Added support for file output
|
||||
- Added optional configuration variables per channel to (replace <channel> with any channel name):
|
||||
- <channel>\_TEMPLATE : Specify a template
|
||||
- <channel>\_SKIPSNOOZE : Skip snooze
|
||||
- <channel>\_CONTAINERSONLY : Only notify for docker container related updates
|
||||
- <channel>\_ALLOWEMPTY : Always send notifications, even when empty
|
||||
- <channel>\_OUTPUT : Define output format
|
||||
- Added optional configuration variables per channel to (replace <channel> with any channel name):
|
||||
- <channel>\_TEMPLATE : Specify a template
|
||||
- <channel>\_SKIPSNOOZE : Skip snooze
|
||||
- <channel>\_CONTAINERSONLY : Only notify for docker container related updates
|
||||
- <channel>\_ALLOWEMPTY : Always send notifications, even when empty
|
||||
- <channel>\_OUTPUT : Define output format
|
||||
- **v0.7.0**:
|
||||
- Bugfix: snooze dockcheck.sh-self-notification and some config clarification.
|
||||
- Added authentication support to Ntfy.sh.
|
||||
|
|
@ -209,15 +209,15 @@ Further additions are welcome - suggestions or PRs!
|
|||
#### Notification channel configuration:
|
||||
All required environment variables for each channel type are provided in the default.config file as comments and must be uncommented and modified for your requirements.
|
||||
For advanced users, additional functionality is available via custom configurations and environment variables.
|
||||
Use cases (in all cases, replace <channel> with the name of the channel specified in the NOTIFY_CHANNELS environment variable):
|
||||
- To bypass the snooze feature, even when enabled, add the variable `<channel>\_SKIPSNOOZE` to `dockcheck.config` and set it equal to `true`.
|
||||
- To configure the channel to only send Docker container update notifications, add the variable `<channel>\_CONTAINERSONLY` to `dockcheck.config` and set it equal to `true`.
|
||||
- To send notifications even when there are no updates available, add the variable `<channel>\_ALLOWEMPTY` to `dockcheck.config` and set it equal to `true`.
|
||||
- To use another notification output format, add the variable `<channel>\_OUTPUT` to `dockcheck.config` and set it equal to `csv`, `json`, or `text`. If unset or set to an invalid value, defaults to `text`.
|
||||
Use cases (in all cases, replace <channel> with the name of the channel specified in the NOTIFY_CHANNELS environment variable):
|
||||
- To bypass the snooze feature, even when enabled, add the variable `<channel>_SKIPSNOOZE` to `dockcheck.config` and set it equal to `true`.
|
||||
- To configure the channel to only send Docker container update notifications, add the variable `<channel>_CONTAINERSONLY` to `dockcheck.config` and set it equal to `true`.
|
||||
- To send notifications even when there are no updates available, add the variable `<channel>_ALLOWEMPTY` to `dockcheck.config` and set it equal to `true`.
|
||||
- To use another notification output format, add the variable `<channel>_OUTPUT` to `dockcheck.config` and set it equal to `csv`, `json`, or `text`. If unset or set to an invalid value, defaults to `text`.
|
||||
- To send multiple notifications using the same notification template:
|
||||
- Strings in the `NOTIFY_CHANNELS` list are now treated as unique names and do not necessarily refer to the notification template that will be called, though they do by default.
|
||||
- Add another notification channel to `NOTIFY_CHANNELS` in `dockcheck.config`. It can have any name as long as it is unique and contains no spaces or special characters.
|
||||
- Add the variable `<channel>\_TEMPLATE` to `dockcheck.config` where `<channel>` is the name of the channel added above and set the value to an available notification template script (`slack`, `apprise`, `gotify`, etc.)
|
||||
- Add the variable `<channel>_TEMPLATE` to `dockcheck.config` where `<channel>` is the name of the channel added above and set the value to an available notification template script (`slack`, `apprise`, `gotify`, etc.)
|
||||
- Add all other environment variables required for the chosen template to function with `<channel>` in upper case as the prefix rather than the template name.
|
||||
- For example, if `<channel>` is `mynotification` and the template configured is `slack`, you would need to set `MYNOTIFICATION_CHANNEL_ID` and `MYNOTIFICATION_ACCESS_TOKEN`.
|
||||
|
||||
|
|
|
|||
|
|
@ -108,10 +108,10 @@ is_snoozed() {
|
|||
if [[ -n "${found}" ]]; then
|
||||
read -a arr <<< "${found}"
|
||||
CheckEpochSeconds=$(( $(date -d "${arr[1]}" +%s 2>/dev/null) + ${snooze} - 60 )) || CheckEpochSeconds=$(( $(date -f "%Y-%m-%d" -j "${arr[1]}" +%s) + ${snooze} - 60 ))
|
||||
if [[ "${CurrentEpochSeconds}" -gt "${CheckEpochSeconds}" ]]; then
|
||||
printf "false"
|
||||
else
|
||||
if [[ "${CurrentEpochSeconds}" -le "${CheckEpochSeconds}" ]]; then
|
||||
printf "true"
|
||||
else
|
||||
printf "false"
|
||||
fi
|
||||
else
|
||||
printf "false"
|
||||
|
|
@ -254,7 +254,7 @@ send_notification() {
|
|||
# Setting the MessageBody variable here.
|
||||
printf -v MessageBody "${FormattedOutput}"
|
||||
|
||||
if { [[ $(skip_snooze "${channel}") == "true" ]] || [[ ${UnsnoozedContainers} -gt 0 ]] } && { { [[ "${MessageBody}" != "None" ]] && [[ "${MessageBody}" != '{"updates": []}' ]] } || [[ $(allow_empty "${channel}") == "true" ]] }; then
|
||||
if { { [[ "${MessageBody}" == "None" ]] || [[ "${MessageBody}" == '{"updates": []}' ]]; } && [[ $(allow_empty "${channel}") == "true" ]]; } || { [[ $(skip_snooze "${channel}") == "true" ]] || [[ ${UnsnoozedContainers} -gt 0 ]]; }; then
|
||||
printf "\nSending ${channel} notification"
|
||||
exec_if_exists_or_fail trigger_${template}_notification "${channel}" || \
|
||||
printf "\nAttempted to send notification to channel ${channel}, but the function was not found. Make sure notify_${template}.sh is available in the ${ScriptWorkDir} directory or notify_templates subdirectory."
|
||||
|
|
@ -290,7 +290,7 @@ dockcheck_notification() {
|
|||
# Setting the MessageBody variable here.
|
||||
printf -v MessageBody "${FormattedOutput}"
|
||||
|
||||
if { [[ $(skip_snooze "${channel}") == "true" ]] || [[ $(is_snoozed "dockcheck\.sh") == "false" ]] } && [[ $(containers_only "${channel}") == "false" ]] && { { [[ "${MessageBody}" != "None" ]] && [[ "${MessageBody}" != '{"updates": []}' ]] } || [[ $(allow_empty "${channel}") == "true" ]] }; then
|
||||
if { { [[ "${MessageBody}" == "None" ]] || [[ "${MessageBody}" == '{"updates": []}' ]]; } && [[ $(allow_empty "${channel}") == "true" ]]; } && { [[ $(skip_snooze "${channel}") == "true" ]] || [[ $(is_snoozed "dockcheck\.sh") == "false" ]]; } && [[ $(containers_only "${channel}") == "false" ]]; then
|
||||
printf "\nSending dockcheck update notification - ${channel}"
|
||||
exec_if_exists_or_fail trigger_${template}_notification "${channel}" || \
|
||||
printf "\nAttempted to send notification to channel ${channel}, but the function was not found. Make sure notify_${template}.sh is available in the ${ScriptWorkDir} directory or notify_templates subdirectory."
|
||||
|
|
@ -323,8 +323,9 @@ notify_update_notification() {
|
|||
if [[ -n "${!VersionVar:-}" ]]; then
|
||||
RawNotifyUrl="https://raw.githubusercontent.com/mag37/dockcheck/main/notify_templates/notify_${NotifyScript}.sh"
|
||||
LatestNotifySnippet="$(curl ${CurlArgs} -r 0-150 "$RawNotifyUrl" || printf "undefined")"
|
||||
LatestNotifyRelease="$(echo "$LatestNotifySnippet" | sed -n "/${VersionVar}/s/${VersionVar}=//p" | tr -d '"')"
|
||||
if [[ ! "${LatestNotifyRelease}" == "undefined" ]]; then
|
||||
if [[ ! "${LatestNotifySnippet}" == "undefined" ]]; then
|
||||
LatestNotifyRelease="$(echo "$LatestNotifySnippet" | sed -n "/${VersionVar}/s/${VersionVar}=//p" | tr -d '"')"
|
||||
|
||||
if [[ "${!VersionVar}" != "${LatestNotifyRelease}" ]] ; then
|
||||
NotifyUpdates+=("${NotifyScript}.sh ${!VersionVar} -> ${LatestNotifyRelease}")
|
||||
fi
|
||||
|
|
@ -349,7 +350,7 @@ notify_update_notification() {
|
|||
# Setting the MessageBody variable here.
|
||||
printf -v MessageBody "${FormattedOutput}"
|
||||
|
||||
if { [[ $(skip_snooze "${channel}") == "true" ]] || [[ ${UnsnoozedTemplates} -gt 0 ]] } && { { [[ "${MessageBody}" != "None" ]] && [[ "${MessageBody}" != '{"updates": []}' ]] } || [[ $(allow_empty "${channel}") == "true" ]] } && [[ $(containers_only "${channel}") == "false" ]]; then
|
||||
if { { [[ "${MessageBody}" == "None" ]] || [[ "${MessageBody}" == '{"updates": []}' ]]; } && [[ $(allow_empty "${channel}") == "true" ]]; } && { [[ $(skip_snooze "${channel}") == "true" ]] || [[ ${UnsnoozedTemplates} -gt 0 ]]; } && [[ $(containers_only "${channel}") == "false" ]]; then
|
||||
printf "\nSending notify template update notification - ${channel}"
|
||||
exec_if_exists_or_fail trigger_${template}_notification "${channel}" || \
|
||||
printf "\nAttempted to send notification to channel ${channel}, but the function was not found. Make sure notify_${template}.sh is available in the ${ScriptWorkDir} directory or notify_templates subdirectory."
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue