mirror of
https://github.com/mag37/dockcheck.git
synced 2026-04-18 10:27:54 +00:00
Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
37f33d7a06 | ||
|
|
732a5e69cd | ||
|
|
9156cc44e1 | ||
|
|
fbc9a252f5 | ||
|
|
1f374b5003 | ||
|
|
563dbb8b42 | ||
|
|
31bb2008b9 | ||
|
|
cfa74adc3d | ||
|
|
e2dbd69c5e | ||
|
|
98e996caa3 | ||
|
|
a1e7446753 | ||
|
|
69c06de1bd | ||
|
|
d37e1a1024 | ||
|
|
77f024bb81 |
35
README.md
35
README.md
@@ -1,13 +1,15 @@
|
|||||||
<p align="center">
|
<p align="center">
|
||||||
<img src="extras/dockcheck_logo_by_booYah187.png" width="160" title="dockcheck">
|
<img src="extras/dockcheck_colour.png" width="300" title="dockcheck">
|
||||||
</p>
|
</p>
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<img src="https://img.shields.io/badge/bash-4.3-green?style=flat-square&logo=gnubash" alt="bash">
|
<img src="https://img.shields.io/badge/bash-4.3-green?style=flat-square&logo=gnubash" alt="bash">
|
||||||
<a href="https://www.gnu.org/licenses/gpl-3.0.html"><img src="https://img.shields.io/badge/license-GPLv3-red?style=flat-square" alt="GPLv3"></a>
|
<a href="https://www.gnu.org/licenses/gpl-3.0.html"><img src="https://img.shields.io/badge/license-GPLv3-red?style=flat-square" alt="GPLv3"></a>
|
||||||
<img src="https://img.shields.io/github/v/tag/mag37/dockcheck?style=flat-square&label=release" alt="release">
|
<img src="https://img.shields.io/github/v/tag/mag37/dockcheck?style=flat-square&label=release" alt="release">
|
||||||
|
<br>
|
||||||
<a href="https://ko-fi.com/mag37"><img src="https://img.shields.io/badge/-Ko--fi-grey?style=flat-square&logo=Ko-fi" alt="Buy me a Coffee"></a>
|
<a href="https://ko-fi.com/mag37"><img src="https://img.shields.io/badge/-Ko--fi-grey?style=flat-square&logo=Ko-fi" alt="Buy me a Coffee"></a>
|
||||||
<a href="https://liberapay.com/user-bin-rob/donate"><img src="https://img.shields.io/badge/-LiberaPay-grey?style=flat-square&logo=liberapay" alt="LiberaPay"></a>
|
<a href="https://liberapay.com/user-bin-rob/donate"><img src="https://img.shields.io/badge/-LiberaPay-grey?style=flat-square&logo=liberapay" alt="LiberaPay"></a>
|
||||||
<a href="https://github.com/sponsors/mag37"><img src="https://img.shields.io/badge/-Sponsor-grey?style=flat-square&logo=github" alt="Github Sponsor"></a>
|
<a href="https://github.com/sponsors/mag37"><img src="https://img.shields.io/badge/-Sponsor-grey?style=flat-square&logo=github" alt="Github Sponsor"></a>
|
||||||
|
<a href="https://www.paypal.com/donate/?business=P2V5MCWRGCNBG&no_recurring=0¤cy_code=SEK"><img src="https://img.shields.io/badge/-PayPal-grey?style=flat-square&logo=paypal" alt="PayPal donation"></a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<h2 align="center">CLI tool to automate docker image updates or notifying when updates are available.</h2>
|
<h2 align="center">CLI tool to automate docker image updates or notifying when updates are available.</h2>
|
||||||
@@ -20,25 +22,22 @@
|
|||||||
___
|
___
|
||||||
## :bell: Changelog
|
## :bell: Changelog
|
||||||
|
|
||||||
|
- **v0.7.0**:
|
||||||
|
- Bugfix: snooze dockcheck.sh-self-notification and some config clarification.
|
||||||
|
- Added authentication support to Ntfy.sh.
|
||||||
|
- Added suport for sendmail in the SMTP-template.
|
||||||
|
- **v0.6.9**:
|
||||||
|
- Bugfix: label logic didn't skip recreation (skipped pulling).
|
||||||
|
- Added comma separated search filtering so you can selectively search exactly which containers to check/update.
|
||||||
|
- eg: `dockcheck.sh -yp homer,dozzle`
|
||||||
|
- **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
|
||||||
- Consolidated and standardized notify template update notifications
|
- Consolidated and standardized notify template update notifications
|
||||||
- Added curl error handling
|
- Added curl error handling
|
||||||
- **v0.6.6**: Notify_v2 bugfixes
|
|
||||||
- Clearer readme and error messages
|
|
||||||
- Sourcing templates from either project root or subdirectory
|
|
||||||
- Consistent newline handling
|
|
||||||
- Added (when using `-d`) days old message to notification title
|
|
||||||
- Added ntfy self hosted domain option to config
|
|
||||||
- jq fixes to templates (and properly using $jqbin)
|
|
||||||
- **v0.6.5**: Refactored notification logic. See notify_templates/notify_v2.sh for upgrade steps.
|
|
||||||
- Added helper functions to simplify sourcing files and executing functions if they exist.
|
|
||||||
- Created notify_v2.sh wrapper script.
|
|
||||||
- Simplified and consolidated notification logic within notify_v2.sh.
|
|
||||||
- Added support for notification management via environment variables.
|
|
||||||
- Moved notification secrets to **dockcheck.config**.
|
|
||||||
- Added retries to wget/curl to not get empty responses when github is slow.
|
|
||||||
___
|
___
|
||||||
|
|
||||||
|
|
||||||
@@ -47,7 +46,7 @@ ___
|
|||||||
## :mag_right: `dockcheck.sh`
|
## :mag_right: `dockcheck.sh`
|
||||||
```
|
```
|
||||||
$ ./dockcheck.sh -h
|
$ ./dockcheck.sh -h
|
||||||
Syntax: dockcheck.sh [OPTION] [part of name to filter]
|
Syntax: dockcheck.sh [OPTION] [comma separated names to include]
|
||||||
Example: dockcheck.sh -y -x 10 -d 10 -e nextcloud,heimdall
|
Example: dockcheck.sh -y -x 10 -d 10 -e nextcloud,heimdall
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
@@ -142,6 +141,7 @@ Make certain your project directory is laid out as below. You only need the noti
|
|||||||
│ ├── notify_discord.sh
|
│ ├── notify_discord.sh
|
||||||
│ ├── notify_generic.sh
|
│ ├── notify_generic.sh
|
||||||
│ ├── notify_gotify.sh
|
│ ├── notify_gotify.sh
|
||||||
|
│ ├── notify_HA.sh
|
||||||
│ ├── notify_matrix.sh
|
│ ├── notify_matrix.sh
|
||||||
│ ├── notify_ntfy.sh
|
│ ├── notify_ntfy.sh
|
||||||
│ ├── notify_pushbullet.sh
|
│ ├── notify_pushbullet.sh
|
||||||
@@ -168,7 +168,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.
|
||||||
@@ -185,6 +185,7 @@ If an update becomes available for an item that is not snoozed, notifications wi
|
|||||||
- Read the [QuickStart](extras/apprise_quickstart.md)
|
- Read the [QuickStart](extras/apprise_quickstart.md)
|
||||||
- [ntfy](https://ntfy.sh/) - HTTP-based pub-sub notifications.
|
- [ntfy](https://ntfy.sh/) - HTTP-based pub-sub notifications.
|
||||||
- [Gotify](https://gotify.net/) - a simple server for sending and receiving messages.
|
- [Gotify](https://gotify.net/) - a simple server for sending and receiving messages.
|
||||||
|
- [Home Assistant](https://www.home-assistant.io/integrations/notify/) - Connection to the notify [integrations](https://www.home-assistant.io/integrations/#notifications).
|
||||||
- [Pushbullet](https://www.pushbullet.com/) - connecting different devices with cross-platform features.
|
- [Pushbullet](https://www.pushbullet.com/) - connecting different devices with cross-platform features.
|
||||||
- [Telegram](https://telegram.org/) - Telegram chat API.
|
- [Telegram](https://telegram.org/) - Telegram chat API.
|
||||||
- [Matrix-Synapse](https://github.com/element-hq/synapse) - [Matrix](https://matrix.org/), open, secure, decentralised communication.
|
- [Matrix-Synapse](https://github.com/element-hq/synapse) - [Matrix](https://matrix.org/), open, secure, decentralised communication.
|
||||||
|
|||||||
@@ -26,19 +26,20 @@
|
|||||||
#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.
|
||||||
##
|
##
|
||||||
## Uncomment the line below and specify the notification channels you wish to enable in a space separated string
|
## Uncomment the line below and specify the notification channels you wish to enable in a space separated string
|
||||||
# NOTIFY_CHANNELS="apprise discord DSM generic gotify matrix ntfy pushbullet pushover slack smtp telegram"
|
# NOTIFY_CHANNELS="apprise discord DSM generic HA gotify matrix ntfy pushbullet pushover slack smtp telegram"
|
||||||
#
|
#
|
||||||
## Uncomment the line below and specify the number of seconds to delay notifications to enable snooze
|
## Uncomment the line below and specify the number of seconds to delay notifications to enable snooze
|
||||||
# SNOOZE_SECONDS=86400
|
# SNOOZE_SECONDS=86400
|
||||||
#
|
#
|
||||||
## Uncomment to not send notifications when dockcheck itself has updates.
|
## Uncomment and set to true to disable notifications when dockcheck itself has updates.
|
||||||
# DISABLE_DOCKCHECK_NOTIFICATION=false
|
# DISABLE_DOCKCHECK_NOTIFICATION=false
|
||||||
## Uncomment to not send notifications when notify scripts themselves have updates.
|
## Uncomment and set to true to disable notifications when notify scripts themselves have updates.
|
||||||
# DISABLE_NOTIFY_NOTIFICATION=false
|
# DISABLE_NOTIFY_NOTIFICATION=false
|
||||||
#
|
#
|
||||||
## Apprise configuration variables. Set APPRISE_PAYLOAD to make a CLI call or set APPRISE_URL to make an API request instead.
|
## Apprise configuration variables. Set APPRISE_PAYLOAD to make a CLI call or set APPRISE_URL to make an API request instead.
|
||||||
@@ -56,13 +57,18 @@
|
|||||||
# GOTIFY_DOMAIN="https://gotify.domain.tld"
|
# GOTIFY_DOMAIN="https://gotify.domain.tld"
|
||||||
# GOTIFY_TOKEN="token-value"
|
# GOTIFY_TOKEN="token-value"
|
||||||
#
|
#
|
||||||
|
# HA_ENTITY="entity"
|
||||||
|
# HA_TOKEN="token"
|
||||||
|
# HA_URL="https://your.homeassistant.url"
|
||||||
|
#
|
||||||
# MATRIX_ACCESS_TOKEN="token-value"
|
# MATRIX_ACCESS_TOKEN="token-value"
|
||||||
# MATRIX_ROOM_ID="myroom"
|
# MATRIX_ROOM_ID="myroom"
|
||||||
# MATRIX_SERVER_URL="https://matrix.yourdomain.tld"
|
# MATRIX_SERVER_URL="https://matrix.yourdomain.tld"
|
||||||
#
|
#
|
||||||
## ntfy.sh or your custom domain with no trailing /
|
## https://ntfy.sh or your custom domain with https:// and no trailing /
|
||||||
# NTFY_DOMAIN="ntfy.sh"
|
# NTFY_DOMAIN="https://ntfy.sh"
|
||||||
# NTFY_TOPIC_NAME="YourUniqueTopicName"
|
# NTFY_TOPIC_NAME="YourUniqueTopicName"
|
||||||
|
# NTFY_AUTH="" # set to either format -> "user:password" OR ":tk_12345678". If using tokens, don't forget the ":"
|
||||||
#
|
#
|
||||||
# PUSHBULLET_URL="https://api.pushbullet.com/v2/pushes"
|
# PUSHBULLET_URL="https://api.pushbullet.com/v2/pushes"
|
||||||
# PUSHBULLET_TOKEN="token-value"
|
# PUSHBULLET_TOKEN="token-value"
|
||||||
@@ -81,3 +87,4 @@
|
|||||||
# TELEGRAM_CHAT_ID="mychatid"
|
# TELEGRAM_CHAT_ID="mychatid"
|
||||||
# TELEGRAM_TOKEN="token-value"
|
# TELEGRAM_TOKEN="token-value"
|
||||||
# TELEGRAM_TOPIC_ID="0"
|
# TELEGRAM_TOPIC_ID="0"
|
||||||
|
|
||||||
|
|||||||
33
dockcheck.sh
33
dockcheck.sh
@@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
VERSION="v0.6.7"
|
VERSION="v0.7.0"
|
||||||
# ChangeNotes: snooze feature (see readme), curl arguments, cleanup.
|
# ChangeNotes: Snooze bugfix, added auth support to ntfy.sh and sendmail support to SMTP
|
||||||
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,20 +14,22 @@ 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() {
|
||||||
echo "Syntax: dockcheck.sh [OPTION] [part of name to filter]"
|
echo "Syntax: dockcheck.sh [OPTION] [comma separated names to include]"
|
||||||
echo "Example: dockcheck.sh -y -x 10 -d 10 -e nextcloud,heimdall"
|
echo "Example: dockcheck.sh -y -x 10 -d 10 -e nextcloud,heimdall"
|
||||||
echo
|
echo
|
||||||
echo "Options:"
|
echo "Options:"
|
||||||
@@ -119,8 +121,11 @@ while getopts "ayfFhiIlmMnprsuvc:e:d:t:x:" options; do
|
|||||||
done
|
done
|
||||||
shift "$((OPTIND-1))"
|
shift "$((OPTIND-1))"
|
||||||
|
|
||||||
# Set $1 to a variable for name filtering later
|
# Set $1 to a variable for name filtering later, rewriting if multiple
|
||||||
SearchName="${1:-}"
|
SearchName="${1:-}"
|
||||||
|
if [[ ! -z "$SearchName" ]]; then
|
||||||
|
SearchName="^(${SearchName//,/|})$"
|
||||||
|
fi
|
||||||
|
|
||||||
# Check if there's a new release of the script
|
# Check if there's a new release of the script
|
||||||
LatestSnippet="$(curl ${CurlArgs} -r 0-200 "$RawUrl" || printf "undefined")"
|
LatestSnippet="$(curl ${CurlArgs} -r 0-200 "$RawUrl" || printf "undefined")"
|
||||||
@@ -568,8 +573,11 @@ if [[ -n "${GotUpdates:-}" ]]; then
|
|||||||
ContOnlySpecific=$($jqbin -r '."mag37.dockcheck.only-specific-container"' <<< "$ContLabels")
|
ContOnlySpecific=$($jqbin -r '."mag37.dockcheck.only-specific-container"' <<< "$ContLabels")
|
||||||
[[ "$ContOnlySpecific" == "null" ]] && ContRestartStack=""
|
[[ "$ContOnlySpecific" == "null" ]] && ContRestartStack=""
|
||||||
|
|
||||||
|
printf "\n%bNow recreating (%s/%s): %b%s%b\n" "$c_teal" "$CurrentQue" "$NumberofUpdates" "$c_blue" "$i" "$c_reset"
|
||||||
# Checking if compose-values are empty - hence started with docker run
|
# Checking if compose-values are empty - hence started with docker run
|
||||||
[[ -z "$ContPath" ]] && continue
|
[[ -z "$ContPath" ]] && { echo "Not a compose container, skipping."; continue; }
|
||||||
|
# Checking if Label Only -option is set, and if container got the label
|
||||||
|
[[ "$OnlyLabel" == true ]] && { [[ "$ContUpdateLabel" != true ]] && { echo "No update label, skipping."; continue; } }
|
||||||
|
|
||||||
# cd to the compose-file directory to account for people who use relative volumes
|
# cd to the compose-file directory to account for people who use relative volumes
|
||||||
cd "$ContPath" || { printf "\n%bPath error - skipping%b %s" "$c_red" "$c_reset" "$i"; continue; }
|
cd "$ContPath" || { printf "\n%bPath error - skipping%b %s" "$c_red" "$c_reset" "$i"; continue; }
|
||||||
@@ -585,7 +593,6 @@ if [[ -n "${GotUpdates:-}" ]]; then
|
|||||||
# Set variable when compose up should only target the specific container, not the stack
|
# Set variable when compose up should only target the specific container, not the stack
|
||||||
if [[ $OnlySpecific == true ]] || [[ $ContOnlySpecific == true ]]; then SpecificContainer="$ContName"; fi
|
if [[ $OnlySpecific == true ]] || [[ $ContOnlySpecific == true ]]; then SpecificContainer="$ContName"; fi
|
||||||
|
|
||||||
printf "\n%bNow recreating (%s/%s): %b%s%b\n" "$c_teal" "$CurrentQue" "$NumberofUpdates" "$c_blue" "$i" "$c_reset"
|
|
||||||
# Check if the whole stack should be restarted
|
# Check if the whole stack should be restarted
|
||||||
if [[ "$ContRestartStack" == true ]] || [[ "$ForceRestartStacks" == true ]]; then
|
if [[ "$ContRestartStack" == true ]] || [[ "$ForceRestartStacks" == true ]]; then
|
||||||
${DockerBin} ${CompleteConfs} stop; ${DockerBin} ${CompleteConfs} ${ContEnvs} up -d || { printf "\n%bDocker error, exiting!%b\n" "$c_red" "$c_reset" ; exit 1; }
|
${DockerBin} ${CompleteConfs} stop; ${DockerBin} ${CompleteConfs} ${ContEnvs} up -d || { printf "\n%bDocker error, exiting!%b\n" "$c_red" "$c_reset" ; exit 1; }
|
||||||
@@ -594,7 +601,7 @@ if [[ -n "${GotUpdates:-}" ]]; then
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
if [[ "$AutoPrune" == false ]] && [[ "$AutoMode" == false ]]; then printf "\n"; read -rep "Would you like to prune dangling images? y/[n]: " AutoPrune; fi
|
if [[ "$AutoPrune" == false ]] && [[ "$AutoMode" == false ]]; then printf "\n"; read -rep "Would you like to prune dangling images? y/[n]: " AutoPrune; fi
|
||||||
if [[ "$AutoPrune" == true ]] || [[ "$AutoPrune" =~ [yY] ]]; then printf "\n Auto pruning.."; docker image prune -f; fi
|
if [[ "$AutoPrune" == true ]] || [[ "$AutoPrune" =~ [yY] ]]; then printf "\nAuto pruning.."; docker image prune -f; fi
|
||||||
printf "\n%bAll done!%b\n" "$c_green" "$c_reset"
|
printf "\n%bAll done!%b\n" "$c_green" "$c_reset"
|
||||||
else
|
else
|
||||||
printf "\nNo updates installed, exiting.\n"
|
printf "\nNo updates installed, exiting.\n"
|
||||||
|
|||||||
BIN
extras/dockcheck_colour.png
Normal file
BIN
extras/dockcheck_colour.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 144 KiB |
@@ -1,5 +1,5 @@
|
|||||||
### DISCLAIMER: This is a third party addition to dockcheck - best effort testing.
|
### DISCLAIMER: This is a third party addition to dockcheck - best effort testing.
|
||||||
NOTIFY_DSM_VERSION="v0.3"
|
NOTIFY_DSM_VERSION="v0.4"
|
||||||
# INFO: ssmtp is deprecated - consider to use msmtp instead.
|
# INFO: ssmtp is deprecated - consider to use msmtp instead.
|
||||||
#
|
#
|
||||||
# mSMTP/sSMTP has to be installed and configured manually.
|
# mSMTP/sSMTP has to be installed and configured manually.
|
||||||
@@ -10,13 +10,16 @@ NOTIFY_DSM_VERSION="v0.3"
|
|||||||
|
|
||||||
MSMTP=$(which msmtp)
|
MSMTP=$(which msmtp)
|
||||||
SSMTP=$(which ssmtp)
|
SSMTP=$(which ssmtp)
|
||||||
|
SENDMAIL=$(which sendmail)
|
||||||
|
|
||||||
if [ -n "$MSMTP" ] ; then
|
if [ -n "$MSMTP" ] ; then
|
||||||
MailPkg=$MSMTP
|
MailPkg=$MSMTP
|
||||||
elif [ -n "$SSMTP" ] ; then
|
elif [ -n "$SSMTP" ] ; then
|
||||||
MailPkg=$SSMTP
|
MailPkg=$SSMTP
|
||||||
|
elif [ -n "$SENDMAIL" ] ; then
|
||||||
|
MailPkg=$SENDMAIL
|
||||||
else
|
else
|
||||||
echo "No msmtp or ssmtp binary found in PATH: $PATH" ; exit 1
|
echo "No msmtp, ssmtp or sendmail binary found in PATH: $PATH" ; exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
trigger_DSM_notification() {
|
trigger_DSM_notification() {
|
||||||
|
|||||||
31
notify_templates/notify_HA.sh
Executable file
31
notify_templates/notify_HA.sh
Executable file
@@ -0,0 +1,31 @@
|
|||||||
|
### DISCLAIMER: This is a third party addition to dockcheck - best effort testing.
|
||||||
|
NOTIFY_HA_VERSION="v0.1"
|
||||||
|
#
|
||||||
|
# This is an integration that makes it possible to send notifications via Home Assistant (https://www.home-assistant.io/integrations/notify/)
|
||||||
|
# You need to generate a long-lived access token in Home Sssistant to be used here (https://developers.home-assistant.io/docs/auth_api/#long-lived-access-token)
|
||||||
|
# Leave (or place) this file in the "notify_templates" subdirectory within the same directory as the main dockcheck.sh script.
|
||||||
|
# If you instead wish make your own modifications, make a copy in the same directory as the main dockcheck.sh script.
|
||||||
|
# Do not modify this file directly within the "notify_templates" subdirectory. Set HA_ENTITY, HA_URL and HA_TOKEN in your dockcheck.config file.
|
||||||
|
|
||||||
|
if [[ -z "${HA_ENTITY:-}" ]] || [[ -z "${HA_URL:-}" ]] || [[ -z "${HA_TOKEN:-}" ]]; then
|
||||||
|
printf "Home Assistant notification channel enabled, but required configuration variables are missing. Home assistant notifications will not be sent.\n"
|
||||||
|
|
||||||
|
remove_channel HA
|
||||||
|
fi
|
||||||
|
|
||||||
|
trigger_HA_notification() {
|
||||||
|
AccessToken="${HA_TOKEN}"
|
||||||
|
Url="${HA_URL}/api/services/notify/${HA_ENTITY}"
|
||||||
|
JsonData=$( "$jqbin" -n \
|
||||||
|
--arg body "$MessageBody" \
|
||||||
|
'{"title": "dockcheck update", "message": $body}' )
|
||||||
|
|
||||||
|
curl -S -o /dev/null ${CurlArgs} \
|
||||||
|
-H "Authorization: Bearer $AccessToken" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d "$JsonData" -X POST $Url
|
||||||
|
|
||||||
|
if [[ $? -gt 0 ]]; then
|
||||||
|
NotifyError=true
|
||||||
|
fi
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
### DISCLAIMER: This is a third party addition to dockcheck - best effort testing.
|
### DISCLAIMER: This is a third party addition to dockcheck - best effort testing.
|
||||||
NOTIFY_NTFYSH_VERSION="v0.5"
|
NOTIFY_NTFYSH_VERSION="v0.6"
|
||||||
#
|
#
|
||||||
# Setup app and subscription at https://ntfy.sh
|
# Setup app and subscription at https://ntfy.sh
|
||||||
# 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.
|
||||||
@@ -24,11 +24,18 @@ trigger_ntfy_notification() {
|
|||||||
ContentType="Markdown: no" #text/plain
|
ContentType="Markdown: no" #text/plain
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ -n "${NTFY_AUTH:-}" ]]; then
|
||||||
|
NtfyAuth="-u $NTFY_AUTH"
|
||||||
|
else
|
||||||
|
NtfyAuth=""
|
||||||
|
fi
|
||||||
|
|
||||||
curl -S -o /dev/null ${CurlArgs} \
|
curl -S -o /dev/null ${CurlArgs} \
|
||||||
-H "Title: $MessageTitle" \
|
-H "Title: $MessageTitle" \
|
||||||
-H "$ContentType" \
|
-H "$ContentType" \
|
||||||
-d "$MessageBody" \
|
-d "$MessageBody" \
|
||||||
"$NtfyUrl"
|
$NtfyAuth \
|
||||||
|
-L "$NtfyUrl"
|
||||||
|
|
||||||
if [[ $? -gt 0 ]]; then
|
if [[ $? -gt 0 ]]; then
|
||||||
NotifyError=true
|
NotifyError=true
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
### DISCLAIMER: This is a third party addition to dockcheck - best effort testing.
|
### DISCLAIMER: This is a third party addition to dockcheck - best effort testing.
|
||||||
NOTIFY_SMTP_VERSION="v0.3"
|
NOTIFY_SMTP_VERSION="v0.4"
|
||||||
# INFO: ssmtp is depcerated - consider to use msmtp instead.
|
# INFO: ssmtp is depcerated - consider to use msmtp instead.
|
||||||
#
|
#
|
||||||
# mSMTP/sSMTP has to be installed and configured manually.
|
# mSMTP/sSMTP has to be installed and configured manually.
|
||||||
@@ -15,13 +15,16 @@ fi
|
|||||||
|
|
||||||
MSMTP=$(which msmtp)
|
MSMTP=$(which msmtp)
|
||||||
SSMTP=$(which ssmtp)
|
SSMTP=$(which ssmtp)
|
||||||
|
SENDMAIL=$(which sendmail)
|
||||||
|
|
||||||
if [ -n "$MSMTP" ] ; then
|
if [ -n "$MSMTP" ] ; then
|
||||||
MailPkg=$MSMTP
|
MailPkg=$MSMTP
|
||||||
elif [ -n "$SSMTP" ] ; then
|
elif [ -n "$SSMTP" ] ; then
|
||||||
MailPkg=$SSMTP
|
MailPkg=$SSMTP
|
||||||
|
elif [ -n "$SENDMAIL" ] ; then
|
||||||
|
MailPkg=$SENDMAIL
|
||||||
else
|
else
|
||||||
echo "No msmtp or ssmtp binary found in PATH: $PATH" ; exit 1
|
echo "No msmtp, ssmtp or sendmail binary found in PATH: $PATH" ; exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
trigger_smtp_notification() {
|
trigger_smtp_notification() {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
NOTIFY_V2_VERSION="v0.3"
|
NOTIFY_V2_VERSION="v0.5"
|
||||||
#
|
#
|
||||||
# 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
|
||||||
@@ -175,26 +177,20 @@ dockcheck_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
|
||||||
|
|
||||||
if [[ -n "${snooze}" ]] && [[ -f "${SnoozeFile}" ]]; then
|
[[ -n "${snooze}" ]] && [[ "${NotifyError}" == "false" ]] && update_snooze "dockcheck.sh"
|
||||||
if [[ "${NotifyError}" == "false" ]]; then
|
|
||||||
if [[ -n "${found}" ]]; then
|
|
||||||
sed -e "s/dockcheck\.sh.*/dockcheck\.sh ${CurrentEpochTime}/" "${SnoozeFile}" > "${SnoozeFile}.new"
|
|
||||||
mv "${SnoozeFile}.new" "${SnoozeFile}"
|
|
||||||
else
|
|
||||||
printf "dockcheck.sh ${CurrentEpochTime}\n" >> "${SnoozeFile}"
|
|
||||||
fi
|
|
||||||
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 +203,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 +228,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 +243,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
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user