diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6c60473 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +# ignore users custom notify.sh +/notify.sh diff --git a/README.md b/README.md index 0955f59..6e540e4 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,8 @@

With features like excluding specific containers, filter by name, auto-prune dangling images and more. -### :bell: Recent changes +### :bell: Changelog +- **v0.3.3**: Added Apprise template and the option `-i` inform - to send notifications. - **v0.3.2**: Added a notify function to wrap a notify-script, currently DSM/Ssmtp + template script. - **v0.3.1**: Addded option `-m` , monochrome mode - no printf color codes. - **v0.3.0**: Added option `-d N`, age (days) new images have to be before being pulled and updated. @@ -31,9 +32,10 @@ ___ ## Dependencies -Running docker (duh) and compose, either standalone or plugin. -[`regclient/regctl`](https://github.com/regclient/regclient) (Licensed under [Apache-2.0 License](http://www.apache.org/licenses/LICENSE-2.0)) -User will be prompted to download `regctl` if not in `PATH` or `PWD` +- Running docker (duh) and compose, either standalone or plugin. +- [`regclient/regctl`](https://github.com/regclient/regclient) (Licensed under [Apache-2.0 License](http://www.apache.org/licenses/LICENSE-2.0)) + - User will be prompted to download `regctl` if not in `PATH` or `PWD`. + - regctl requires `amd64/arm64` - see [workaround](#workaround-for-non-amd64--arm64) if other architecture is used. ___ @@ -42,18 +44,20 @@ ___ ## `dockcheck.sh` ``` $ ./dockcheck.sh -h - Syntax: dockcheck.sh [OPTION] [part of name to filter] + Syntax: dockcheck.sh [OPTION] [part of name to filter] Example: dockcheck.sh -y -d 10 -e nextcloud,heimdall Options: - -h Print this Help. -a|y Automatic updates, without interaction. - -n No updates, only checking availability. + -d N Only update to new images that are N+ days old. Lists too recent with +prefix and age. 2xSlower. -e X Exclude containers, separated by comma. - -d N Only update to new images that are N+ days old. Lists too recent with +prefix. 2xSlower. + -h Print this Help. + -i Inform - send a preconfigured notification. + -m Monochrome mode, no printf color codes. + -n No updates, only checking availability. -p Auto-Prune dangling images after update. -r Allow updating images for docker run, wont update the container. - -s Include stopped containers in the check. (Logic: docker ps -a). + -s Include stopped containers in the check. (Logic: docker ps -a) ``` Basic example: @@ -75,9 +79,20 @@ Enter number(s) separated by comma, [a] for all - [q] to quit: Then it proceedes to run `pull` and `up -d` on every container with updates. After the updates are complete, you'll get prompted if you'd like to prune dangling images. -### Notifications: +### :loudspeaker: Notifications +Trigger with the `-i` flag. +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! +Current templates: +- Synology [DSM](https://www.synology.com/en-global/dsm) +- Email with [sSMTP](https://wiki.debian.org/sSMTP) +- Apprise (with it's [multitude](https://github.com/caronc/apprise#supported-notifications) of notifications) + - both native [caronc/apprise](https://github.com/caronc/apprise) and the standalone [linuxserver/docker-apprise-api](https://github.com/linuxserver/docker-apprise-api) + +Further additions are welcome - suggestions or PR! +Initiated and first contributed by [yoyoma2](https://github.com/yoyoma2). -A simple email notification function is added, with a generic example and DSM/Ssmtp script by [yoyoma2](https://github.com/yoyoma2). Further addons are welcome, suggestions or PR! ### :warning: `-r flag` disclaimer and warning **Wont auto-update the containers, only their images. (compose is recommended)** @@ -89,6 +104,27 @@ Containers need to be manually stopped, removed and created again to run on the - Not respecting `--profile` options when re-creating the container. - Not working well with containers created by Portainer. +### Workaround for non **amd64** / **arm64** +`regctl` provides binaries for amd64/arm64, to use on other architecture you could try this workaround. +Run regctl in a contianer wrapped in a shell script. Copied from [regclient/docs/install.md](https://github.com/regclient/regclient/blob/main/docs/install.md): + +```sh +cat >regctl < date:$(date -R) To: <$SendMailTo> -Subject: [diskstation] Some docker containers need to be updated +Subject: [$SubjectTag] Updates available on $FromHost Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit -The following docker containers on $FromHost need to be updated: +The following containers on $FromHost have updates available: $UpdToString diff --git a/notify_apprise.sh b/notify_apprise.sh new file mode 100644 index 0000000..9945524 --- /dev/null +++ b/notify_apprise.sh @@ -0,0 +1,37 @@ +### 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. +# Modify to fit your setup - if API, set AppriseURL to your Apprise ip/domain. + +send_notification() { +Updates=("$@") +UpdToString=$( printf "%s\n" "${Updates[@]}" ) +FromHost=$(hostname) + +printf "\nSending Apprise notification\n" + +MessageTitle="$FromHost - updates available." +# Setting the MessageBody variable here. +read -d '\n' MessageBody << __EOF +Containers on $FromHost with updates available: + +$UpdToString + +__EOF + +# Modify to fit your setup: +apprise -vv -t "$MessageTitle" -b "$MessageBody" \ + mailto://myemail:mypass@gmail.com \ + mastodons://{token}@{host} \ + pbul://o.gn5kj6nfhv736I7jC3cj3QLRiyhgl98b \ + tgram://{bot_token}/{chat_id}/ + +### If you use the Apprise-API - Comment out the apprise command above. +### Uncomment the AppriseURL and the curl-line below: +# AppriseURL="http://apprise.mydomain.tld:1234/notify/apprise" +# curl -X POST -F "title=$MessageTitle" -F "body=$MessageBody" -F "tags=all" $AppriseURL + +} + + diff --git a/notify_generic.sh b/notify_generic.sh index 7c52c33..04b508c 100644 --- a/notify_generic.sh +++ b/notify_generic.sh @@ -1,5 +1,6 @@ ### DISCLAIMER: This is a third party addition to dockcheck - best effort testing. -# Copy/rename this file to notify.sh to enable email/text notifications +# +# Copy/rename this file to notify.sh to enable the notification snippet. # generic sample, the "Hello World" of notification addons send_notification() { diff --git a/notify_ssmtp.sh b/notify_ssmtp.sh new file mode 100644 index 0000000..2d80cb4 --- /dev/null +++ b/notify_ssmtp.sh @@ -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 snipppet. +# sSMTP has to be installed and configured manually. +# Modify to fit your setup - changing SendMailFrom, SendMailTo, SubjectTag + +send_notification() { +Updates=("$@") +UpdToString=$( printf "%s\n" "${Updates[@]}" ) +FromHost=$(hostname) + +# User variables: +SendMailFrom="me@mydomain.tld" +SendMailTo="me@mydomain.tld" +SubjectTag="dockcheck" + +printf "\nSending email notification.\n" + +ssmtp $SendMailTo << __EOF +From: "$FromHost" <$SendMailFrom> +date:$(date -R) +To: <$SendMailTo> +Subject: [$SubjectTag] Updates available on $FromHost +Content-Type: text/plain; charset=UTF-8; format=flowed +Content-Transfer-Encoding: 7bit + +The following containers on $FromHost have updates available: + +$UpdToString + +__EOF +}