mirror of
https://github.com/mag37/dockcheck.git
synced 2026-04-18 10:27:54 +00:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a1e7446753 | ||
|
|
69c06de1bd | ||
|
|
d37e1a1024 | ||
|
|
77f024bb81 |
@@ -20,6 +20,9 @@
|
||||
___
|
||||
## :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
|
||||
- Added snooze feature to delay notifications
|
||||
- Added configurable default curl arguments
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#CurlRetryDelay=1 # Time between curl retries
|
||||
#CurlRetryCount=3 # Max number of curl retries
|
||||
#CurlConnectTimeout=5 # Time to wait for curl to establish a connection before failing
|
||||
#DisplaySourcedFiles=false # Display what files are being sourced/used
|
||||
|
||||
### Notify settings
|
||||
## All commented values are examples only. Modify as needed.
|
||||
|
||||
18
dockcheck.sh
18
dockcheck.sh
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
VERSION="v0.6.7"
|
||||
# ChangeNotes: snooze feature (see readme), curl arguments, cleanup.
|
||||
VERSION="v0.6.8"
|
||||
# ChangeNotes: bugfix unbound variable in notify_v2, new option "DisplaySourcedFiles" added to config
|
||||
Github="https://github.com/mag37/dockcheck"
|
||||
RawUrl="https://raw.githubusercontent.com/mag37/dockcheck/main/dockcheck.sh"
|
||||
|
||||
@@ -14,16 +14,18 @@ ScriptPath="$(readlink -f "$0")"
|
||||
ScriptWorkDir="$(dirname "$ScriptPath")"
|
||||
|
||||
# Source helper functions
|
||||
source_if_exists() {
|
||||
if [[ -s "$1" ]]; then source "$1"; fi
|
||||
}
|
||||
|
||||
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
|
||||
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() {
|
||||
|
||||
@@ -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.
|
||||
# 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
|
||||
|
||||
[[ -n "${snooze}" ]] && cleanup_snooze "${Updates[@]}"
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
### Set DISABLE_DOCKCHECK_NOTIFICATION=false in dockcheck.config
|
||||
@@ -187,14 +189,17 @@ dockcheck_notification() {
|
||||
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.
|
||||
notify_update_notification() {
|
||||
if [[ ! "${DISABLE_NOTIFY_UPDATE_NOTIFICATION:-}" == "true" ]]; then
|
||||
if [[ ! "${DISABLE_NOTIFY_NOTIFICATION:-}" == "true" ]]; then
|
||||
NotifyUpdateNotify=false
|
||||
NotifyError=false
|
||||
NotifyUpdates=()
|
||||
|
||||
UpdateChannels=( "${enabled_notify_channels[@]}" "v2" )
|
||||
|
||||
@@ -207,14 +212,14 @@ notify_update_notification() {
|
||||
LatestNotifyRelease="$(echo "$LatestNotifySnippet" | sed -n "/${VersionVar}/s/${VersionVar}=//p" | tr -d '"')"
|
||||
if [[ ! "${LatestNotifyRelease}" == "undefined" ]]; then
|
||||
if [[ "${!VersionVar}" != "${LatestNotifyRelease}" ]] ; then
|
||||
Updates+=("${NotifyScript}.sh ${!VersionVar} -> ${LatestNotifyRelease}")
|
||||
NotifyUpdates+=("${NotifyScript}.sh ${!VersionVar} -> ${LatestNotifyRelease}")
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ -n "${snooze}" ]] && [[ -f "${SnoozeFile}" ]]; then
|
||||
for update in "${Updates[@]}"; do
|
||||
for update in "${NotifyUpdates[@]}"; do
|
||||
read -a NotifyScript <<< "${update}"
|
||||
found=$(grep -w "${NotifyScript}" "${SnoozeFile}" || printf "")
|
||||
if [[ -n "${found}" ]]; then
|
||||
@@ -232,8 +237,8 @@ notify_update_notification() {
|
||||
fi
|
||||
|
||||
if [[ "${NotifyUpdateNotify}" == "true" ]]; then
|
||||
if [[ "${#Updates[@]}" -gt 0 ]]; then
|
||||
UpdToString=$( printf '%s\\n' "${Updates[@]}" )
|
||||
if [[ "${#NotifyUpdates[@]}" -gt 0 ]]; then
|
||||
UpdToString=$( printf '%s\\n' "${NotifyUpdates[@]}" )
|
||||
UpdToString=${UpdToString%\\n}
|
||||
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"
|
||||
done
|
||||
|
||||
[[ -n "${snooze}" ]] && [[ "${NotifyError}" == "false" ]] && update_snooze "${Updates[@]}"
|
||||
[[ -n "${snooze}" ]] && [[ "${NotifyError}" == "false" ]] && update_snooze "${NotifyUpdates[@]}"
|
||||
fi
|
||||
fi
|
||||
|
||||
UpdatesPlusDockcheck=("${Updates[@]}")
|
||||
UpdatesPlusDockcheck=("${NotifyUpdates[@]}")
|
||||
UpdatesPlusDockcheck+=("dockcheck.sh")
|
||||
[[ -n "${snooze}" ]] && cleanup_snooze "${UpdatesPlusDockcheck[@]}"
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user