Compare commits

...

4 Commits

Author SHA1 Message Date
mag37
a1e7446753 version bump + readme 2025-07-01 22:27:54 +02:00
op4lat
69c06de1bd Add DisplaySourcedFiles variable (#207)
* Add DisplaySourcedFiles variable to be used in source_if_exists and source_if_exists_or_fail functions
* Added return 0 as to not throw wrong exit code.
* Delete source_if_exists. source_if_exists_or_fail returns success or failure. Failure doesn't stop the script

---------

Co-authored-by: Elephant Quater <eq@cont.MSHOME>
Co-authored-by: mag37 <robin.ivehult@gmail.com>
2025-07-01 22:19:15 +02:00
mag37
d37e1a1024 Bugfixes for unbound variable, potential collision and config variable mismatch
Version bump to alert users of the latest bugfixes for unbound variable, potential collision and config variable mismatch.
2025-06-27 09:22:10 +02:00
vorezal
77f024bb81 Fix unbound variable, potential collision, and config variable. (#209)
* Fix unbound variable, potential collision, and config variable.

* Return 0 when notification functions finish successfully

---------

Co-authored-by: Matthew Oleksowicz <matt@everyoneneeds.it>
2025-06-27 09:10:31 +02:00
4 changed files with 31 additions and 18 deletions

View File

@@ -20,6 +20,9 @@
___ ___
## :bell: Changelog ## :bell: Changelog
- **v0.6.8**:
- Bugfix: Unbound variable in notify_v2.sh
- New option: "DisplaySourcedFiles" *config* added to list what files get sourced
- **v0.6.7**: Snooze feature, curl, and consolidation - **v0.6.7**: Snooze feature, curl, and consolidation
- Added snooze feature to delay notifications - Added snooze feature to delay notifications
- Added configurable default curl arguments - Added configurable default curl arguments
@@ -168,7 +171,7 @@ copy it to `notify.sh` alongside the script, modify it to your needs! (notify.sh
#### Snooze feature: #### Snooze feature:
**Use case:** You wish to be notified of available updates in a timely manner, but do not require reminders after the initial notification with the same frequency. **Use case:** You wish to be notified of available updates in a timely manner, but do not require reminders after the initial notification with the same frequency.
e.g. *Dockcheck is scheduled to run every hour. You will receive an update notification within an hour of availability.* e.g. *Dockcheck is scheduled to run every hour. You will receive an update notification within an hour of availability.*
**Snooze enabled:** you will not receive another notification about updates for this container for a configurable period of time. **Snooze enabled:** you will not receive another notification about updates for this container for a configurable period of time.
**Snooze disabled:** you will receive additional notifications every hour. **Snooze disabled:** you will receive additional notifications every hour.
To enable snooze, uncomment the `SNOOZE_SECONDS` variable in your `dockcheck.config` file and set it to the number of seconds you wish to prevent duplicate alerts. To enable snooze, uncomment the `SNOOZE_SECONDS` variable in your `dockcheck.config` file and set it to the number of seconds you wish to prevent duplicate alerts.

View File

@@ -26,6 +26,7 @@
#CurlRetryDelay=1 # Time between curl retries #CurlRetryDelay=1 # Time between curl retries
#CurlRetryCount=3 # Max number of curl retries #CurlRetryCount=3 # Max number of curl retries
#CurlConnectTimeout=5 # Time to wait for curl to establish a connection before failing #CurlConnectTimeout=5 # Time to wait for curl to establish a connection before failing
#DisplaySourcedFiles=false # Display what files are being sourced/used
### Notify settings ### Notify settings
## All commented values are examples only. Modify as needed. ## All commented values are examples only. Modify as needed.

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
VERSION="v0.6.7" VERSION="v0.6.8"
# ChangeNotes: snooze feature (see readme), curl arguments, cleanup. # ChangeNotes: bugfix unbound variable in notify_v2, new option "DisplaySourcedFiles" added to config
Github="https://github.com/mag37/dockcheck" Github="https://github.com/mag37/dockcheck"
RawUrl="https://raw.githubusercontent.com/mag37/dockcheck/main/dockcheck.sh" RawUrl="https://raw.githubusercontent.com/mag37/dockcheck/main/dockcheck.sh"
@@ -14,16 +14,18 @@ ScriptPath="$(readlink -f "$0")"
ScriptWorkDir="$(dirname "$ScriptPath")" ScriptWorkDir="$(dirname "$ScriptPath")"
# Source helper functions # Source helper functions
source_if_exists() {
if [[ -s "$1" ]]; then source "$1"; fi
}
source_if_exists_or_fail() { source_if_exists_or_fail() {
[[ -s "$1" ]] && source "$1" if [[ -s "$1" ]]; then
source "$1"
[[ "${DisplaySourcedFiles:-false}" == true ]] && echo " * sourced config: ${1}"
return 0
else
return 1
fi
} }
# User customizable defaults # User customizable defaults
source_if_exists_or_fail "${HOME}/.config/dockcheck.config" || source_if_exists "${ScriptWorkDir}/dockcheck.config" source_if_exists_or_fail "${HOME}/.config/dockcheck.config" || source_if_exists_or_fail "${ScriptWorkDir}/dockcheck.config"
# Help Function # Help Function
Help() { Help() {

View File

@@ -1,4 +1,4 @@
NOTIFY_V2_VERSION="v0.3" NOTIFY_V2_VERSION="v0.4"
# #
# If migrating from an older notify template, remove your existing notify.sh file. # If migrating from an older notify template, remove your existing notify.sh file.
# Leave (or place) this file in the "notify_templates" subdirectory within the same directory as the main dockcheck.sh script. # Leave (or place) this file in the "notify_templates" subdirectory within the same directory as the main dockcheck.sh script.
@@ -139,6 +139,8 @@ send_notification() {
fi fi
[[ -n "${snooze}" ]] && cleanup_snooze "${Updates[@]}" [[ -n "${snooze}" ]] && cleanup_snooze "${Updates[@]}"
return 0
} }
### Set DISABLE_DOCKCHECK_NOTIFICATION=false in dockcheck.config ### Set DISABLE_DOCKCHECK_NOTIFICATION=false in dockcheck.config
@@ -187,14 +189,17 @@ dockcheck_notification() {
fi fi
fi fi
fi fi
return 0
} }
### Set DISABLE_NOTIFY_UPDATE_NOTIFICATION=false in dockcheck.config ### Set DISABLE_NOTIFY_NOTIFICATION=false in dockcheck.config
### to not send notifications when notify scripts themselves have updates. ### to not send notifications when notify scripts themselves have updates.
notify_update_notification() { notify_update_notification() {
if [[ ! "${DISABLE_NOTIFY_UPDATE_NOTIFICATION:-}" == "true" ]]; then if [[ ! "${DISABLE_NOTIFY_NOTIFICATION:-}" == "true" ]]; then
NotifyUpdateNotify=false NotifyUpdateNotify=false
NotifyError=false NotifyError=false
NotifyUpdates=()
UpdateChannels=( "${enabled_notify_channels[@]}" "v2" ) UpdateChannels=( "${enabled_notify_channels[@]}" "v2" )
@@ -207,14 +212,14 @@ notify_update_notification() {
LatestNotifyRelease="$(echo "$LatestNotifySnippet" | sed -n "/${VersionVar}/s/${VersionVar}=//p" | tr -d '"')" LatestNotifyRelease="$(echo "$LatestNotifySnippet" | sed -n "/${VersionVar}/s/${VersionVar}=//p" | tr -d '"')"
if [[ ! "${LatestNotifyRelease}" == "undefined" ]]; then if [[ ! "${LatestNotifyRelease}" == "undefined" ]]; then
if [[ "${!VersionVar}" != "${LatestNotifyRelease}" ]] ; then if [[ "${!VersionVar}" != "${LatestNotifyRelease}" ]] ; then
Updates+=("${NotifyScript}.sh ${!VersionVar} -> ${LatestNotifyRelease}") NotifyUpdates+=("${NotifyScript}.sh ${!VersionVar} -> ${LatestNotifyRelease}")
fi fi
fi fi
fi fi
done done
if [[ -n "${snooze}" ]] && [[ -f "${SnoozeFile}" ]]; then if [[ -n "${snooze}" ]] && [[ -f "${SnoozeFile}" ]]; then
for update in "${Updates[@]}"; do for update in "${NotifyUpdates[@]}"; do
read -a NotifyScript <<< "${update}" read -a NotifyScript <<< "${update}"
found=$(grep -w "${NotifyScript}" "${SnoozeFile}" || printf "") found=$(grep -w "${NotifyScript}" "${SnoozeFile}" || printf "")
if [[ -n "${found}" ]]; then if [[ -n "${found}" ]]; then
@@ -232,8 +237,8 @@ notify_update_notification() {
fi fi
if [[ "${NotifyUpdateNotify}" == "true" ]]; then if [[ "${NotifyUpdateNotify}" == "true" ]]; then
if [[ "${#Updates[@]}" -gt 0 ]]; then if [[ "${#NotifyUpdates[@]}" -gt 0 ]]; then
UpdToString=$( printf '%s\\n' "${Updates[@]}" ) UpdToString=$( printf '%s\\n' "${NotifyUpdates[@]}" )
UpdToString=${UpdToString%\\n} UpdToString=${UpdToString%\\n}
NotifyError=false NotifyError=false
@@ -247,12 +252,14 @@ notify_update_notification() {
printf "Attempted to send notification to channel ${channel}, but the function was not found. Make sure notify_${channel}.sh is available in the ${ScriptWorkDir} directory or notify_templates subdirectory.\n" printf "Attempted to send notification to channel ${channel}, but the function was not found. Make sure notify_${channel}.sh is available in the ${ScriptWorkDir} directory or notify_templates subdirectory.\n"
done done
[[ -n "${snooze}" ]] && [[ "${NotifyError}" == "false" ]] && update_snooze "${Updates[@]}" [[ -n "${snooze}" ]] && [[ "${NotifyError}" == "false" ]] && update_snooze "${NotifyUpdates[@]}"
fi fi
fi fi
UpdatesPlusDockcheck=("${Updates[@]}") UpdatesPlusDockcheck=("${NotifyUpdates[@]}")
UpdatesPlusDockcheck+=("dockcheck.sh") UpdatesPlusDockcheck+=("dockcheck.sh")
[[ -n "${snooze}" ]] && cleanup_snooze "${UpdatesPlusDockcheck[@]}" [[ -n "${snooze}" ]] && cleanup_snooze "${UpdatesPlusDockcheck[@]}"
fi fi
return 0
} }