Compare commits

...

21 Commits

Author SHA1 Message Date
mag37
319b43bc1b Added releasenotes-logic to all templates, fix to DSM+smtp 2024-10-05 08:03:33 +02:00
mag37
8b40dce2cd Merge pull request #97 from mag37/releasenotes
Releasenotes addon
2024-10-04 23:24:15 +02:00
mag37
62b52796f2 removed empty lines 2024-10-04 23:19:41 +02:00
mag37
85ee721cd1 typo 2024-10-04 23:09:45 +02:00
mag37
6de00a2b90 removed releasenotes test script 2024-10-04 23:07:58 +02:00
mag37
a550994659 tweaks + version info 2024-10-04 23:07:01 +02:00
mag37
0e3210b561 added urls.list
Added urls.list to be ignored.
2024-10-04 14:55:43 +02:00
mag37
db4431d40a Update dockcheck.sh
changed missing url-message.
2024-10-04 14:48:05 +02:00
mag37
9f8c62ed96 first tweaks for a release-notes addition 2024-10-04 14:39:51 +02:00
mag37
827bb7e14a Update releasenotes.sh
added $ScriptWorkDir prefix to urls.list
2024-10-04 08:05:42 +02:00
mag37
91ff4aaaa7 Added notification release notes url function 2024-10-02 20:44:32 +02:00
mag37
999694985a Added sponsorlist - section. 2024-09-28 14:24:34 +02:00
mag37
640046668c added project url to --help 2024-09-28 14:22:09 +02:00
mag37
a79de24bcc Cleanups + info to readme 2024-09-18 16:44:32 +02:00
mag37
f31a886424 Merge pull request #94 from sudo-kraken/patch-1
Create notify_pushover.sh
2024-09-10 06:32:26 +02:00
Joe Harrison
5b31e68f73 Create notify_pushover.sh 2024-09-09 22:57:11 +01:00
mag37
923736c413 version bump+info 2024-08-17 23:00:41 +02:00
mag37
7d825f36c9 Rewrote prune prompt logic, wont prompt if none-interactive flags are used 2024-08-17 22:56:04 +02:00
mag37
29dffbb9b3 Merge pull request #92 from bocan/pre-commit-fixes
style: Add pre-commit checks and code cleanup
2024-08-17 20:39:07 +02:00
Chris Funderburg
588c22afc9 style: Add pre-commit checks and code cleanup
This change adds an optional pre-commit configuration that can be used
to keep the code style clean.  I've also run it across all files and
fixed numerous whitespaces issues.

To use it, if wanted, just clone / pull the repo as normal, go into the
folder and run:

```
pre-commit install
```

From that point on, when running `git commit`, it will run the checks
on any changed files.

Feel free to ignore this PR if you're not interested.
2024-08-17 08:50:39 -04:00
mag37
39c69b7648 Update README.md 2024-07-26 07:54:46 +02:00
18 changed files with 171 additions and 99 deletions

1
.gitignore vendored
View File

@@ -1,4 +1,5 @@
# ignore users custom notify.sh # ignore users custom notify.sh
/notify.sh /notify.sh
/urls.list
# ignore the auto-installed regctl # ignore the auto-installed regctl
regctl regctl

11
.pre-commit-config.yaml Normal file
View File

@@ -0,0 +1,11 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: check-yaml
- id: check-added-large-files
- id: trailing-whitespace
args: [--markdown-linebreak-ext=md]
- id: end-of-file-fixer
- id: mixed-line-ending
args: ['--fix=lf']

View File

@@ -16,20 +16,13 @@
___ ___
## :bell: Changelog ## :bell: Changelog
* Create notify_gotify.sh by @cerealconyogurt in https://github.com/mag37/dockcheck/pull/87
* zero configuration DSM notification emails by @yoyoma2 in https://github.com/mag37/dockcheck/pull/88
* smtp-changes, deprecate ssmtp, suggest msmtp by @mag37 in https://github.com/mag37/dockcheck/pull/90
- **v0.4.9**: Added a function to enrich the notify-message with release note URLs. See [Release notes addon](https://github.com/mag37/dockcheck#date-release-notes-addon-to-notifications)
- **v0.4.8**: Rewrote prune logic to not prompt with options `-a|-y` or `-n`. Auto prune with `-p`.
- **v0.4.7**: Notification Template changes to gotify(new!), DSM(improved), SMTP(deprecation alternative). - **v0.4.7**: Notification Template changes to gotify(new!), DSM(improved), SMTP(deprecation alternative).
- **v0.4.6**: Compatibility changes to timeout, due to busybox. - **v0.4.6**: Compatibility changes to timeout, due to busybox.
- **v0.4.5**: Bugfixes, compatibility changes to timeout and arrays. - **v0.4.5**: Bugfixes, compatibility changes to timeout and arrays.
- **v0.4.3**: Added timeout option to skip container if registry check takes too long (10s default). - **v0.4.3**: Added timeout option to skip container if registry check takes too long (10s default).
- **v0.4.1**: Syntax and logic cleanups, bugfixes on multi compose and env-files.
- **v0.4.0**: Reworked selfupdate (auto git/curl/wget), general syntax cleanup, added -v for version.
- **v0.3.8**: Fixed `--env-file` logic to work with multiple env-files.
- **v0.3.7**: Added support for [labels](#bookmark-labels), added the `-f` option (force restart stack).
- **v0.3.6**: Added pushbullet template.
- **v0.3.5**: Added a simple progress bar for the registry checkup.
___ ___
@@ -105,7 +98,7 @@ Add preferred `notify.sh`-template to the same directory - this will not be touc
Trigger with the `-i` flag. Trigger with the `-i` flag.
Run it scheduled with `-ni` to only get notified when there's updates available! Run it scheduled with `-ni` to only get notified when there's updates available!
Use a `notify_X.sh` template file, copy it to `notify.sh`, modify it to your needs! (notify.sh is added to .gitignore) Use a `notify_X.sh` template file from the **notify_templates** directory, copy it to `notify.sh` alongside the script, modify it to your needs! (notify.sh is added to .gitignore)
**Current templates:** **Current templates:**
- Synology [DSM](https://www.synology.com/en-global/dsm) - Synology [DSM](https://www.synology.com/en-global/dsm)
- Email with [mSMTP](https://wiki.debian.org/msmtp) (or deprecated alternative [sSMTP](https://wiki.debian.org/sSMTP)) - Email with [mSMTP](https://wiki.debian.org/msmtp) (or deprecated alternative [sSMTP](https://wiki.debian.org/sSMTP))
@@ -117,10 +110,24 @@ Use a `notify_X.sh` template file, copy it to `notify.sh`, modify it to your nee
- [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.
- [Pushover](https://pushover.net/) - Simple Notifications (to your phone, wearables, desktops)
Further additions are welcome - suggestions or PR! Further additions are welcome - suggestions or PR!
<sub><sup>Initiated and first contributed by [yoyoma2](https://github.com/yoyoma2).</sup></sub> <sub><sup>Initiated and first contributed by [yoyoma2](https://github.com/yoyoma2).</sup></sub>
### :date: Release notes addon to Notifications
There's a function to use a lookup-file to add release note URL's to the notification message.
Copy the notify_templates/`urls.list` file to the script directory and modify it as necessary, it will be used automatically if it's there.
The output of the notification will look something like this:
```
Containers on hostname with updates available:
apprise-api -> https://github.com/linuxserver/docker-apprise-api/releases
homer -> https://github.com/bastienwirtz/homer/releases
nginx -> https://github.com/docker-library/official-images/blob/master/library/nginx
...
```
The `urls.list` file is just an example and I'd gladly see that people contribute back when they add their preferred URLs to their lists.
## :bookmark: Labels ## :bookmark: Labels
Optionally add labels to compose-files. Currently these are the usable labels: Optionally add labels to compose-files. Currently these are the usable labels:
``` ```
@@ -163,21 +170,26 @@ function dchk {
## :hammer: Known issues ## :hammer: Known issues
- No detailed error feedback (just skip + list what's skipped). - No detailed error feedback (just skip + list what's skipped).
- Not respecting `--profile` options when re-creating the container. - Not respecting `--profile` options when re-creating the container.
- Not working well with containers created by Portainer. - Not working well with containers created by **Portainer**.
- **Watchtower** might cause issues due to retagging images when checking for updates (and thereby pulling new images).
## :warning: `-r flag` disclaimer and warning ## :warning: `-r flag` disclaimer and warning
**Wont auto-update the containers, only their images. (compose is recommended)** **Wont auto-update the containers, only their images. (compose is recommended)**
`docker run` dont support using new images just by restarting a container. `docker run` dont support using new images just by restarting a container.
Containers need to be manually stopped, removed and created again to run on the new image. Containers need to be manually stopped, removed and created again to run on the new image.
## :wrench: Debugging
If you hit issues, you could check the output of the `extras/errorCheck.sh` script for clues.
Another option is to run the main script with debugging in a subshell `bash -x dockcheck.sh` - if there's a particular container/image that's causing issues you can filter for just that through `bash -x dockcheck.sh nginx`.
## :scroll: License ## :scroll: License
dockcheck is created and released under the [GNU GPL v3.0](https://www.gnu.org/licenses/gpl-3.0-standalone.html) license. dockcheck is created and released under the [GNU GPL v3.0](https://www.gnu.org/licenses/gpl-3.0-standalone.html) license.
### :floppy_disk: The [story](https://mag37.org/posts/project_dockcheck/) behind it. 1 year in retrospect. ## :heartpulse: Sponsorlist
- [avegy](https://github.com/avegy)
___ ___
### :floppy_disk: The [story](https://mag37.org/posts/project_dockcheck/) behind it. 1 year in retrospect.
## Special Thanks
- :bison: [t0rnis](https://github.com/t0rnis)
- :leopard: [Palleri](https://github.com/Palleri)

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
VERSION="v0.4.7" VERSION="v0.4.9"
### ChangeNotes: Notification template changes for: gotify(new), DSM(improved), SMTP(deprecation alternative). ### ChangeNotes: Added a function to enrich the notify-message with release note URLs. See README.
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"
@@ -13,7 +13,6 @@ ScriptWorkDir="$(dirname "$ScriptPath")"
LatestRelease="$(curl -s -r 0-50 $RawUrl | sed -n "/VERSION/s/VERSION=//p" | tr -d '"')" LatestRelease="$(curl -s -r 0-50 $RawUrl | sed -n "/VERSION/s/VERSION=//p" | tr -d '"')"
LatestChanges="$(curl -s -r 0-200 $RawUrl | sed -n "/ChangeNotes/s/### ChangeNotes: //p")" LatestChanges="$(curl -s -r 0-200 $RawUrl | sed -n "/ChangeNotes/s/### ChangeNotes: //p")"
### Help Function: ### Help Function:
Help() { Help() {
echo "Syntax: dockcheck.sh [OPTION] [part of name to filter]" echo "Syntax: dockcheck.sh [OPTION] [part of name to filter]"
@@ -34,6 +33,8 @@ Help() {
echo "-s Include stopped containers in the check. (Logic: docker ps -a)." echo "-s Include stopped containers in the check. (Logic: docker ps -a)."
echo "-t Set a timeout (in seconds) per container for registry checkups, 10 is default." echo "-t Set a timeout (in seconds) per container for registry checkups, 10 is default."
echo "-v Prints current version." echo "-v Prints current version."
echo
echo "Project source: $Github"
} }
### Colors: ### Colors:
@@ -146,6 +147,17 @@ progress_bar() {
[[ "$QueTotal" == "$QueCurrent" ]] && printf "\r[%b%s%b] %s/%s \n" "$c_teal" "$BarComplete" "$c_reset" "$QueCurrent" "$QueTotal" [[ "$QueTotal" == "$QueCurrent" ]] && printf "\r[%b%s%b] %s/%s \n" "$c_teal" "$BarComplete" "$c_reset" "$QueCurrent" "$QueTotal"
} }
### Function to add user-provided urls to releasenotes
releasenotes() {
for update in ${Updates[@]}; do
found=false
while read -r container url; do
[[ $update == $container ]] && printf "%s -> %s\n" "$update" "$url" && found=true
done < "$ScriptWorkDir"/urls.list
[[ $found == false ]] && printf "%s -> url missing\n" "$update" || continue
done
}
### Version check & initiate self update ### Version check & initiate self update
if [[ "$VERSION" != "$LatestRelease" ]] ; then if [[ "$VERSION" != "$LatestRelease" ]] ; then
printf "New version available! %b%s%b ⇒ %b%s%b \n Change Notes: %s \n" "$c_yellow" "$VERSION" "$c_reset" "$c_green" "$LatestRelease" "$c_reset" "$LatestChanges" printf "New version available! %b%s%b ⇒ %b%s%b \n Change Notes: %s \n" "$c_yellow" "$VERSION" "$c_reset" "$c_green" "$LatestRelease" "$c_reset" "$LatestChanges"
@@ -259,7 +271,6 @@ NoUpdates=($(sort <<<"${NoUpdates[*]}"))
GotUpdates=($(sort <<<"${GotUpdates[*]}")) GotUpdates=($(sort <<<"${GotUpdates[*]}"))
unset IFS unset IFS
### Define how many updates are available ### Define how many updates are available
UpdCount="${#GotUpdates[@]}" UpdCount="${#GotUpdates[@]}"
@@ -333,7 +344,7 @@ if [ -n "$GotUpdates" ] ; then
fi fi
done done
printf "\n%bAll done!%b\n" "$c_green" "$c_reset" printf "\n%bAll done!%b\n" "$c_green" "$c_reset"
[[ -z "$AutoPrune" ]] && read -r -p "Would you like to prune dangling images? y/[n]: " AutoPrune if [[ -z "$AutoPrune" ]] && [[ -z "$AutoUp" ]]; then read -r -p "Would you like to prune dangling images? y/[n]: " AutoPrune ; fi
[[ "$AutoPrune" =~ [yY] ]] && docker image prune -f [[ "$AutoPrune" =~ [yY] ]] && docker image prune -f
else else
printf "\nNo updates installed, exiting.\n" printf "\nNo updates installed, exiting.\n"
@@ -343,4 +354,3 @@ else
fi fi
exit 0 exit 0

View File

@@ -9,17 +9,17 @@
MSMTP=$(which msmtp) MSMTP=$(which msmtp)
SSMTP=$(which ssmtp) SSMTP=$(which ssmtp)
if [ -n $MSMPT ] ; then if [ -n "$MSMPT" ] ; then
MAIL=$MSMTP MailPkg=$MSMTP
elif [ -n $SSMTP ] && [ -z $MAIL ] ; then elif [ -n "$SSMTP" ] ; then
MAIL=$SSMTP MailPkg=$SSMTP
else else
echo "No msmtp or ssmtp binary found in PATH: $PATH" ; exit 1 echo "No msmtp or ssmtp binary found in PATH: $PATH" ; exit 1
fi fi
send_notification() { send_notification() {
Updates=("$@") Updates=("$@")
UpdToString=$( printf "%s\n" "${Updates[@]}" ) [ -s "$ScriptWorkDir"/urls.list ] && UpdToString=$( releasenotes ) || UpdToString=$( printf "%s\n" "${Updates[@]}" )
FromHost=$(hostname) FromHost=$(hostname)
CfgFile="/usr/syno/etc/synosmtp.conf" CfgFile="/usr/syno/etc/synosmtp.conf"
@@ -36,7 +36,7 @@ SenderMail=${SenderMail:-$(grep 'eventmail1' $CfgFile | sed -n 's/.*"\([^"]*\)".
printf "\nSending email notification.\n" printf "\nSending email notification.\n"
$MAIL $SendMailTo << __EOF $MailPkg $SendMailTo << __EOF
From: "$SenderName" <$SenderMail> From: "$SenderName" <$SenderMail>
date:$(date -R) date:$(date -R)
To: <$SendMailTo> To: <$SendMailTo>

View File

@@ -6,7 +6,7 @@
send_notification() { send_notification() {
Updates=("$@") Updates=("$@")
UpdToString=$( printf "%s\n" "${Updates[@]}" ) [ -s "$ScriptWorkDir"/urls.list ] && UpdToString=$( releasenotes ) || UpdToString=$( printf "%s\n" "${Updates[@]}" )
FromHost=$(hostname) FromHost=$(hostname)
printf "\nSending Apprise notification\n" printf "\nSending Apprise notification\n"
@@ -33,5 +33,3 @@ apprise -vv -t "$MessageTitle" -b "$MessageBody" \
# curl -X POST -F "title=$MessageTitle" -F "body=$MessageBody" -F "tags=all" $AppriseURL # curl -X POST -F "title=$MessageTitle" -F "body=$MessageBody" -F "tags=all" $AppriseURL
} }

View File

@@ -5,7 +5,7 @@
send_notification() { send_notification() {
Updates=("$@") Updates=("$@")
UpdToString=$( printf "%s\n" "${Updates[@]}" ) [ -s "$ScriptWorkDir"/urls.list ] && UpdToString=$( releasenotes ) || UpdToString=$( printf "%s\n" "${Updates[@]}" )
FromHost=$(hostname) FromHost=$(hostname)
# platform specific notification code would go here # platform specific notification code would go here

View File

@@ -6,7 +6,7 @@
send_notification() { send_notification() {
Updates=("$@") Updates=("$@")
UpdToString=$( printf "%s\n" "${Updates[@]}" ) [ -s "$ScriptWorkDir"/urls.list ] && UpdToString=$( releasenotes ) || UpdToString=$( printf "%s\n" "${Updates[@]}" )
FromHost=$(hostname) FromHost=$(hostname)
# platform specific notification code would go here # platform specific notification code would go here

View File

@@ -6,7 +6,7 @@
send_notification() { send_notification() {
Updates=("$@") Updates=("$@")
UpdToString=$( printf "%s\n" "${Updates[@]}" ) [ -s "$ScriptWorkDir"/urls.list ] && UpdToString=$( releasenotes ) || UpdToString=$( printf "%s\n" "${Updates[@]}" )
FromHost=$(hostname) FromHost=$(hostname)
# platform specific notification code would go here # platform specific notification code would go here

View File

@@ -6,7 +6,7 @@
send_notification() { send_notification() {
Updates=("$@") Updates=("$@")
UpdToString=$( printf "%s\n" "${Updates[@]}" ) [ -s "$ScriptWorkDir"/urls.list ] && UpdToString=$( releasenotes ) || UpdToString=$( printf "%s\n" "${Updates[@]}" )
FromHost=$(hostname) FromHost=$(hostname)
printf "\nSending ntfy.sh notification\n" printf "\nSending ntfy.sh notification\n"

View File

@@ -7,7 +7,7 @@
send_notification() { send_notification() {
Updates=("$@") Updates=("$@")
UpdToString=$( printf "%s\n" "${Updates[@]}" ) [ -s "$ScriptWorkDir"/urls.list ] && UpdToString=$( releasenotes ) || UpdToString=$( printf "%s\n" "${Updates[@]}" )
FromHost=$(hostname) FromHost=$(hostname)
# platform specific notification code would go here # platform specific notification code would go here

View File

@@ -0,0 +1,32 @@
### DISCLAIMER: This is a third party addition to dockcheck - best effort testing.
#
# Copy/rename this file to notify.sh to enable the notification snippet.
# Required receiving services must already be set up.
# Requires jq installed and in PATH.
# Modify to fit your setup - set Url and Token.
send_notification() {
Updates=("$@")
[ -s "$ScriptWorkDir"/urls.list ] && UpdToString=$( releasenotes ) || UpdToString=$( printf "%s\n" "${Updates[@]}" )
FromHost=$(hostname)
# platform specific notification code would go here
printf "\nSending pushover notification\n"
MessageTitle="$FromHost - updates available."
# Setting the MessageBody variable here.
MessageBody="Containers on $FromHost with updates available: $UpdToString"
# Modify to fit your setup:
PushoverUrl="https://api.pushover.net/1/messages.json"
PushoverUserKey="Your Pushover User Key Here"
PushoverToken="Your Pushover API Token Here"
# Sending the notification via Pushover
curl -sS -o /dev/null --show-error --fail -X POST \
-F "token=$PushoverToken" \
-F "user=$PushoverUserKey" \
-F "title=$MessageTitle" \
-F "message=$MessageBody" \
$PushoverUrl
}

View File

@@ -8,17 +8,17 @@
MSMTP=$(which msmtp) MSMTP=$(which msmtp)
SSMTP=$(which ssmtp) SSMTP=$(which ssmtp)
if [ -n $MSMPT ] ; then if [ -n "$MSMPT" ] ; then
MAIL=$MSMTP MailPkg=$MSMTP
elif [ -n $SSMTP ] && [ -z $MAIL ] ; then elif [ -n "$SSMTP" ] ; then
MAIL=$SSMTP MailPkg=$SSMTP
else else
echo "No msmtp or ssmtp binary found in PATH: $PATH" ; exit 1 echo "No msmtp or ssmtp binary found in PATH: $PATH" ; exit 1
fi fi
send_notification() { send_notification() {
Updates=("$@") Updates=("$@")
UpdToString=$( printf "%s\n" "${Updates[@]}" ) [ -s "$ScriptWorkDir"/urls.list ] && UpdToString=$( releasenotes ) || UpdToString=$( printf "%s\n" "${Updates[@]}" )
FromHost=$(hostname) FromHost=$(hostname)
# User variables: # User variables:
@@ -28,7 +28,7 @@ SubjectTag="dockcheck"
printf "\nSending email notification.\n" printf "\nSending email notification.\n"
$MAIL $SendMailTo << __EOF $MailPkg $SendMailTo << __EOF
From: "$FromHost" <$SendMailFrom> From: "$FromHost" <$SendMailFrom>
date:$(date -R) date:$(date -R)
To: <$SendMailTo> To: <$SendMailTo>

View File

@@ -6,7 +6,7 @@
send_notification() { send_notification() {
Updates=("$@") Updates=("$@")
UpdToString=$( printf "%s\n" "${Updates[@]}" ) [ -s "$ScriptWorkDir"/urls.list ] && UpdToString=$( releasenotes ) || UpdToString=$( printf "%s\n" "${Updates[@]}" )
FromHost=$(hostname) FromHost=$(hostname)
# platform specific notification code would go here # platform specific notification code would go here

View File

@@ -0,0 +1,8 @@
# This is a list of container names and releasenote urls, separated by space.
# Modify, add and (if necessary) remove to fit your needs.
# Additions are welcome! Append your list to the git-repo, use generic names and sensible urls.
apprise-api https://github.com/linuxserver/docker-apprise-api/releases
homer https://github.com/bastienwirtz/homer/releases
nginx https://github.com/docker-library/official-images/blob/master/library/nginx
vaultwarden-server https://github.com/dani-garcia/vaultwarden/releases