mirror of
https://github.com/mag37/dockcheck.git
synced 2026-04-18 02:17:46 +00:00
Compare commits
92 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
09c9faa008 | ||
|
|
17ed46d157 | ||
|
|
d744d51473 | ||
|
|
3821c22660 | ||
|
|
5dd42b7336 | ||
|
|
8da2cbe611 | ||
|
|
9937d6bc3f | ||
|
|
5517abb090 | ||
|
|
cb8c23e62d | ||
|
|
0009adc2cf | ||
|
|
8d39e1b66b | ||
|
|
ec068dd19a | ||
|
|
119932aa19 | ||
|
|
a9f2433fab | ||
|
|
18e467274e | ||
|
|
6db92be627 | ||
|
|
fc47b1313b | ||
|
|
76d2921719 | ||
|
|
2844e54fbd | ||
|
|
e0d66cc773 | ||
|
|
071fa4b245 | ||
|
|
cb73025a61 | ||
|
|
87f1886d28 | ||
|
|
ac10a96cc8 | ||
|
|
e5a7a715c6 | ||
|
|
8a6a1fbec2 | ||
|
|
04b0c46366 | ||
|
|
319b43bc1b | ||
|
|
8b40dce2cd | ||
|
|
62b52796f2 | ||
|
|
85ee721cd1 | ||
|
|
6de00a2b90 | ||
|
|
a550994659 | ||
|
|
0e3210b561 | ||
|
|
db4431d40a | ||
|
|
9f8c62ed96 | ||
|
|
827bb7e14a | ||
|
|
91ff4aaaa7 | ||
|
|
999694985a | ||
|
|
640046668c | ||
|
|
a79de24bcc | ||
|
|
f31a886424 | ||
|
|
5b31e68f73 | ||
|
|
923736c413 | ||
|
|
7d825f36c9 | ||
|
|
29dffbb9b3 | ||
|
|
588c22afc9 | ||
|
|
39c69b7648 | ||
|
|
35e33b3997 | ||
|
|
a615d759ad | ||
|
|
df310c8f50 | ||
|
|
b1448fbb95 | ||
|
|
de67cab998 | ||
|
|
608c218281 | ||
|
|
3d122f2b86 | ||
|
|
8e280145b9 | ||
|
|
da389a04e7 | ||
|
|
25563d16b6 | ||
|
|
4917c97076 | ||
|
|
33fc647cb1 | ||
|
|
abec27c38a | ||
|
|
082b0f4c7c | ||
|
|
8521280070 | ||
|
|
0aac94f27c | ||
|
|
730dba5c3d | ||
|
|
f8455d3787 | ||
|
|
bbe9164554 | ||
|
|
5d86c79710 | ||
|
|
b0f8431dbf | ||
|
|
331d2cc5a7 | ||
|
|
35f460ed61 | ||
|
|
aab63901d0 | ||
|
|
5e53fabbf6 | ||
|
|
8b3926fd5d | ||
|
|
049413cf5a | ||
|
|
b1b7f048a3 | ||
|
|
361e98c378 | ||
|
|
d1ad0c68f6 | ||
|
|
76697bc281 | ||
|
|
86649fb0fe | ||
|
|
80f7dd9b82 | ||
|
|
959f636152 | ||
|
|
d1bf9256fa | ||
|
|
5513e13109 | ||
|
|
f0b2f7eab7 | ||
|
|
44a90d5e62 | ||
|
|
c63643dde8 | ||
|
|
b2767864ab | ||
|
|
c09e813aad | ||
|
|
0b52dd50b6 | ||
|
|
b86df76fb6 | ||
|
|
b8450aa774 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -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
11
.pre-commit-config.yaml
Normal 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']
|
||||||
102
README.md
102
README.md
@@ -2,7 +2,6 @@
|
|||||||
<img src="extras/dockcheck_logo_by_booYah187.png" width="160" title="dockcheck">
|
<img src="extras/dockcheck_logo_by_booYah187.png" width="160" title="dockcheck">
|
||||||
</p>
|
</p>
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<img src="https://img.shields.io/badge/coded%20by%20Human-100%25-yellow?style=flat-square" alt="No AI!">
|
|
||||||
<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">
|
||||||
@@ -11,29 +10,25 @@
|
|||||||
<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>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<h3 align="center">A script checking updates for docker images <b>without pulling</b><br>Then selectively auto-update containers.</h3>
|
<h3 align="center">CLI tool to automate docker image updates. <br>No <b>pre-pull</b>, selective, optional notifications and prune when done.</h3>
|
||||||
<h2 align="center">Now with a simple Apprise integration!</h2>
|
<h2 align="center">Now with simple notification integrations!</h2>
|
||||||
<h4 align="center">With features like excluding specific containers, filter by name, auto-prune dangling images and more.</h4>
|
<h4 align="center">With features like excluding specific containers, custom container labels, auto-prune when done and more.</h4>
|
||||||
|
<h4 align="center">Also see the fresh Podman fork <a href="https://github.com/sudo-kraken/podcheck">sudo-kraken/podcheck</a>!</h4>
|
||||||
|
|
||||||
___
|
___
|
||||||
## :bell: Changelog
|
## :bell: Changelog
|
||||||
|
|
||||||
- **v0.4.0**: Reworked selfupdate (auto git/curl/wget), general syntax cleanup, added -v for version.
|
- **v0.5.1**: DEPENDENCY WARNING: now requires **jq**. + Upstreaming changes from [sudo-kraken/podcheck](https://github.com/sudo-kraken/podcheck)
|
||||||
- **v0.3.8**: Fixed `--env-file` logic to work with multiple env-files.
|
- **v0.5.0**: Rewritten notify logic - all templates are adjusted and should be migrated!
|
||||||
- **v0.3.7**: Added support for [labels](#bookmark-labels), added the `-f` option (force restart stack).
|
- Copy the custom settings from your current template to the new version of the same template.
|
||||||
- **v0.3.6**: Added pushbullet template.
|
- Look into, copy and customize the `urls.list` file if that's of interest.
|
||||||
- **v0.3.5**: Added a simple progress bar for the registry checkup.
|
- Other changes:
|
||||||
- **v0.3.4**: Added ntfy.sh template and error message on registry fail.
|
- Added Discord notify template.
|
||||||
- **v0.3.3**: Added Apprise template and the option `-i` inform - to send notifications.
|
- Verbosity changed of `regctl`.
|
||||||
- **v0.3.2**: Added a notify function to wrap a notify-script, currently DSM/Ssmtp + template script.
|
- **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.6**: Compatibility changes to timeout, due to busybox.
|
||||||
## :nut_and_bolt: 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`.
|
|
||||||
- regctl requires `amd64/arm64` - see [workaround](#roller_coaster-workaround-for-non-amd64--arm64) if other architecture is used.
|
|
||||||
___
|
___
|
||||||
|
|
||||||
|
|
||||||
@@ -58,6 +53,7 @@ Options:"
|
|||||||
-p Auto-Prune dangling images after update.
|
-p Auto-Prune dangling images after update.
|
||||||
-r Allow updating images for docker run, wont update the container.
|
-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).
|
||||||
|
-t Set a timeout (in seconds) per container for registry checkups, 10 is default.
|
||||||
-v Prints current version.
|
-v Prints current version.
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -78,26 +74,67 @@ Containers with updates available:
|
|||||||
Choose what containers to update:
|
Choose what containers to update:
|
||||||
Enter number(s) separated by comma, [a] for all - [q] to quit:
|
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.
|
Then it proceeds 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.
|
After the updates are complete, you'll get prompted if you'd like to prune dangling images.
|
||||||
|
|
||||||
|
___
|
||||||
|
|
||||||
|
## :nut_and_bolt: Dependencies
|
||||||
|
- Running docker (duh) and compose, either standalone or plugin. (see [Podman fork](https://github.com/sudo-kraken/podcheck)
|
||||||
|
- Bash shell or compatible shell of at least v4.3
|
||||||
|
- [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](#roller_coaster-workaround-for-non-amd64--arm64) if other architecture is used.
|
||||||
|
|
||||||
|
## :tent: Install Instructions
|
||||||
|
Download the script to a directory in **PATH**, I'd suggest using `~/.local/bin` as that's usually in **PATH**.
|
||||||
|
```sh
|
||||||
|
# basic example with curl:
|
||||||
|
curl -L https://raw.githubusercontent.com/mag37/dockcheck/main/dockcheck.sh -o ~/.local/bin/dockcheck.sh
|
||||||
|
chmod +x ~/.local/bin/dockcheck.sh
|
||||||
|
|
||||||
|
# or oneliner with wget:
|
||||||
|
wget -O ~/.local/bin/dockcheck.sh "https://raw.githubusercontent.com/mag37/dockcheck/main/dockcheck.sh" && chmod +x ~/.local/bin/dockcheck.sh
|
||||||
|
```
|
||||||
|
Then call the script anywhere with just `dockcheck.sh`.
|
||||||
|
Add preferred `notify.sh`-template to the same directory - this will not be touched by the scripts self-update function.
|
||||||
|
|
||||||
|
|
||||||
## :loudspeaker: Notifications
|
## :loudspeaker: Notifications
|
||||||
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!
|
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 [sSMTP](https://wiki.debian.org/sSMTP)
|
- Email with [mSMTP](https://wiki.debian.org/msmtp) (or deprecated alternative [sSMTP](https://wiki.debian.org/sSMTP))
|
||||||
- Apprise (with it's [multitude](https://github.com/caronc/apprise#supported-notifications) of notifications)
|
- 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)
|
- both native [caronc/apprise](https://github.com/caronc/apprise) and the standalone [linuxserver/docker-apprise-api](https://github.com/linuxserver/docker-apprise-api)
|
||||||
- Read the [QuickStart](extras/apprise_quickstart.md)
|
- Read the [QuickStart](extras/apprise_quickstart.md)
|
||||||
- [ntfy.sh](https://ntfy.sh/) - HTTP-based pub-sub notifications.
|
- [ntfy.sh](https://ntfy.sh/) - HTTP-based pub-sub notifications.
|
||||||
|
- [Gotify](https://gotify.net/) - a simple server for sending and receiving messages.
|
||||||
- [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.
|
||||||
|
- [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)
|
||||||
|
- [Discord](https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks) - Discord webhooks.
|
||||||
|
|
||||||
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, it will be used automatically if it's there. Modify it as necessary, the names of interest in the left column needs to match your container names.
|
||||||
|
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:
|
||||||
```
|
```
|
||||||
@@ -128,7 +165,7 @@ chmod 755 regctl
|
|||||||
```
|
```
|
||||||
Test it with `./regctl --help` and then either add the file to the same path as *dockcheck.sh* or in your path (eg. `~/.local/bin/regctl`).
|
Test it with `./regctl --help` and then either add the file to the same path as *dockcheck.sh* or in your path (eg. `~/.local/bin/regctl`).
|
||||||
|
|
||||||
## :open_hands: Function to auth with docker hub before running
|
## :guardsman: Function to auth with docker hub before running
|
||||||
**Example** - Change names, paths, and remove cat+password flag if you rather get prompted:
|
**Example** - Change names, paths, and remove cat+password flag if you rather get prompted:
|
||||||
```sh
|
```sh
|
||||||
function dchk {
|
function dchk {
|
||||||
@@ -140,21 +177,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)
|
|
||||||
|
|||||||
196
dockcheck.sh
196
dockcheck.sh
@@ -1,21 +1,19 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
VERSION="v0.4.0"
|
VERSION="v0.5.1"
|
||||||
### ChangeNotes: Reworked selfupdate (auto git/curl/wget), cleanups, -v for version.
|
# ChangeNotes: DEPENDENCY WARNING: now requires jq. And upstreaming changes from sudo-kraken/podcheck
|
||||||
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"
|
||||||
|
|
||||||
### Variables for self updating
|
# Variables for self updating
|
||||||
ScriptArgs=( "$@" )
|
ScriptArgs=( "$@" )
|
||||||
ScriptPath="$(readlink -f "$0")"
|
ScriptPath="$(readlink -f "$0")"
|
||||||
ScriptName="$(basename "$ScriptPath")"
|
|
||||||
ScriptWorkDir="$(dirname "$ScriptPath")"
|
ScriptWorkDir="$(dirname "$ScriptPath")"
|
||||||
|
|
||||||
### Check if there's a new release of the script:
|
# Check if there's a new release of the script
|
||||||
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]"
|
||||||
echo "Example: dockcheck.sh -y -d 10 -e nextcloud,heimdall"
|
echo "Example: dockcheck.sh -y -d 10 -e nextcloud,heimdall"
|
||||||
@@ -29,14 +27,17 @@ Help() {
|
|||||||
echo "-i Inform - send a preconfigured notification."
|
echo "-i Inform - send a preconfigured notification."
|
||||||
echo "-l Only update if label is set. See readme."
|
echo "-l Only update if label is set. See readme."
|
||||||
echo "-m Monochrome mode, no printf color codes."
|
echo "-m Monochrome mode, no printf color codes."
|
||||||
echo "-n No updates, only checking availability."
|
echo "-n No updates; only checking availability."
|
||||||
echo "-p Auto-Prune dangling images after update."
|
echo "-p Auto-prune dangling images after update."
|
||||||
echo "-r Allow updating images for docker run, wont update the container."
|
echo "-r Allow updating images for docker run; won't update the container."
|
||||||
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 "-v Prints current version."
|
echo "-v Prints current version."
|
||||||
|
echo
|
||||||
|
echo "Project source: $Github"
|
||||||
}
|
}
|
||||||
|
|
||||||
### Colors:
|
# Colors
|
||||||
c_red="\033[0;31m"
|
c_red="\033[0;31m"
|
||||||
c_green="\033[0;32m"
|
c_green="\033[0;32m"
|
||||||
c_yellow="\033[0;33m"
|
c_yellow="\033[0;33m"
|
||||||
@@ -44,8 +45,9 @@ c_blue="\033[0;34m"
|
|||||||
c_teal="\033[0;36m"
|
c_teal="\033[0;36m"
|
||||||
c_reset="\033[0m"
|
c_reset="\033[0m"
|
||||||
|
|
||||||
|
Timeout=10
|
||||||
Stopped=""
|
Stopped=""
|
||||||
while getopts "aynpfrhlisvme:d:" options; do
|
while getopts "aynpfrhlisvme:d:t:" options; do
|
||||||
case "${options}" in
|
case "${options}" in
|
||||||
a|y) AutoUp="yes" ;;
|
a|y) AutoUp="yes" ;;
|
||||||
n) AutoUp="no" ;;
|
n) AutoUp="no" ;;
|
||||||
@@ -57,6 +59,7 @@ while getopts "aynpfrhlisvme:d:" options; do
|
|||||||
e) Exclude=${OPTARG} ;;
|
e) Exclude=${OPTARG} ;;
|
||||||
m) declare c_{red,green,yellow,blue,teal,reset}="" ;;
|
m) declare c_{red,green,yellow,blue,teal,reset}="" ;;
|
||||||
s) Stopped="-a" ;;
|
s) Stopped="-a" ;;
|
||||||
|
t) Timeout="${OPTARG}" ;;
|
||||||
v) printf "%s\n" "$VERSION" ; exit 0 ;;
|
v) printf "%s\n" "$VERSION" ; exit 0 ;;
|
||||||
d) DaysOld=${OPTARG}
|
d) DaysOld=${OPTARG}
|
||||||
if ! [[ $DaysOld =~ ^[0-9]+$ ]] ; then { printf "Days -d argument given (%s) is not a number.\n" "${DaysOld}" ; exit 2 ; } ; fi ;;
|
if ! [[ $DaysOld =~ ^[0-9]+$ ]] ; then { printf "Days -d argument given (%s) is not a number.\n" "${DaysOld}" ; exit 2 ; } ; fi ;;
|
||||||
@@ -65,26 +68,27 @@ while getopts "aynpfrhlisvme:d:" options; do
|
|||||||
done
|
done
|
||||||
shift "$((OPTIND-1))"
|
shift "$((OPTIND-1))"
|
||||||
|
|
||||||
|
# Self-update function
|
||||||
self_update_curl() {
|
self_update_curl() {
|
||||||
cp "$ScriptPath" "$ScriptPath".bak
|
cp "$ScriptPath" "$ScriptPath".bak
|
||||||
if [[ $(builtin type -P curl) ]]; then
|
if [[ $(command -v curl) ]]; then
|
||||||
curl -L $RawUrl > "$ScriptPath" ; chmod +x "$ScriptPath"
|
curl -L $RawUrl > "$ScriptPath" ; chmod +x "$ScriptPath"
|
||||||
printf "\n%s\n" "--- starting over with the updated version ---"
|
printf "\n%s\n" "--- starting over with the updated version ---"
|
||||||
exec "$ScriptPath" "${ScriptArgs[@]}" # run the new script with old arguments
|
exec "$ScriptPath" "${ScriptArgs[@]}" # run the new script with old arguments
|
||||||
exit 1 # exit the old instance
|
exit 1 # Exit the old instance
|
||||||
elif [[ $(builtin type -P wget) ]]; then
|
elif [[ $(command -v wget) ]]; then
|
||||||
wget $RawUrl -O "$ScriptPath" ; chmod +x "$ScriptPath"
|
wget $RawUrl -O "$ScriptPath" ; chmod +x "$ScriptPath"
|
||||||
printf "\n%s\n" "--- starting over with the updated version ---"
|
printf "\n%s\n" "--- starting over with the updated version ---"
|
||||||
exec "$ScriptPath" "${ScriptArgs[@]}" # run the new script with old arguments
|
exec "$ScriptPath" "${ScriptArgs[@]}" # run the new script with old arguments
|
||||||
exit 1 # exit the old instance
|
exit 1 # Exit the old instance
|
||||||
else
|
else
|
||||||
printf "curl/wget not available - download the update manually: %s \n" "$RawUrl"
|
printf "curl/wget not available - download the update manually: %s \n" "$Github"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
self_update() {
|
self_update() {
|
||||||
cd "$ScriptWorkDir" || { printf "Path error, skipping update.\n" ; return ; }
|
cd "$ScriptWorkDir" || { printf "Path error, skipping update.\n" ; return ; }
|
||||||
if [[ $(builtin type -P git) ]] && [[ "$(git ls-remote --get-url)" =~ .*"mag37/dockcheck".* ]] ; then
|
if [[ $(command -v git) ]] && [[ "$(git ls-remote --get-url 2>/dev/null)" =~ .*"mag37/dockcheck".* ]] ; then
|
||||||
printf "\n%s\n" "Pulling the latest version."
|
printf "\n%s\n" "Pulling the latest version."
|
||||||
git pull --force || { printf "Git error, manually pull/clone.\n" ; return ; }
|
git pull --force || { printf "Git error, manually pull/clone.\n" ; return ; }
|
||||||
printf "\n%s\n" "--- starting over with the updated version ---"
|
printf "\n%s\n" "--- starting over with the updated version ---"
|
||||||
@@ -97,7 +101,7 @@ self_update() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
### Choose from list -function:
|
# Choose from list function
|
||||||
choosecontainers() {
|
choosecontainers() {
|
||||||
while [[ -z "$ChoiceClean" ]]; do
|
while [[ -z "$ChoiceClean" ]]; do
|
||||||
read -r -p "Enter number(s) separated by comma, [a] for all - [q] to quit: " Choice
|
read -r -p "Enter number(s) separated by comma, [a] for all - [q] to quit: " Choice
|
||||||
@@ -109,7 +113,7 @@ choosecontainers() {
|
|||||||
else
|
else
|
||||||
ChoiceClean=${Choice//[,.:;]/ }
|
ChoiceClean=${Choice//[,.:;]/ }
|
||||||
for CC in $ChoiceClean ; do
|
for CC in $ChoiceClean ; do
|
||||||
if [[ "$CC" -lt 1 || "$CC" -gt $UpdCount ]] ; then # reset choice if out of bounds
|
if [[ "$CC" -lt 1 || "$CC" -gt $UpdCount ]] ; then # Reset choice if out of bounds
|
||||||
echo "Number not in list: $CC" ; unset ChoiceClean ; break 1
|
echo "Number not in list: $CC" ; unset ChoiceClean ; break 1
|
||||||
else
|
else
|
||||||
SelectedUpdates+=( "${GotUpdates[$CC-1]}" )
|
SelectedUpdates+=( "${GotUpdates[$CC-1]}" )
|
||||||
@@ -123,7 +127,7 @@ choosecontainers() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
datecheck() {
|
datecheck() {
|
||||||
ImageDate=$($regbin image inspect "$RepoUrl" --format='{{.Created}}' | cut -d" " -f1 )
|
ImageDate=$($regbin -v error image inspect "$RepoUrl" --format='{{.Created}}' | cut -d" " -f1 )
|
||||||
ImageAge=$(( ( $(date +%s) - $(date -d "$ImageDate" +%s) )/86400 ))
|
ImageAge=$(( ( $(date +%s) - $(date -d "$ImageDate" +%s) )/86400 ))
|
||||||
if [ "$ImageAge" -gt "$DaysOld" ] ; then
|
if [ "$ImageAge" -gt "$DaysOld" ] ; then
|
||||||
return 0
|
return 0
|
||||||
@@ -136,15 +140,26 @@ progress_bar() {
|
|||||||
QueCurrent="$1"
|
QueCurrent="$1"
|
||||||
QueTotal="$2"
|
QueTotal="$2"
|
||||||
((Percent=100*QueCurrent/QueTotal))
|
((Percent=100*QueCurrent/QueTotal))
|
||||||
((Complete=50*Percent/100)) # change first number for width (50)
|
((Complete=50*Percent/100)) # Change first number for width (50)
|
||||||
((Left=50-Complete)) # change first number for width (50)
|
((Left=50-Complete)) # Change first number for width (50)
|
||||||
BarComplete=$(printf "%${Complete}s" | tr " " "#")
|
BarComplete=$(printf "%${Complete}s" | tr " " "#")
|
||||||
BarLeft=$(printf "%${Left}s" | tr " " "-")
|
BarLeft=$(printf "%${Left}s" | tr " " "-")
|
||||||
[[ "$QueTotal" == "$QueCurrent" ]] || printf "\r[%s%s] %s/%s " "$BarComplete" "$BarLeft" "$QueCurrent" "$QueTotal"
|
[[ "$QueTotal" == "$QueCurrent" ]] || printf "\r[%s%s] %s/%s " "$BarComplete" "$BarLeft" "$QueCurrent" "$QueTotal"
|
||||||
[[ "$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"
|
||||||
}
|
}
|
||||||
|
|
||||||
### Version check & initiate self update
|
# Function to add user-provided urls to releasenotes
|
||||||
|
releasenotes() {
|
||||||
|
for update in ${GotUpdates[@]}; do
|
||||||
|
found=false
|
||||||
|
while read -r container url; do
|
||||||
|
[[ $update == $container ]] && Updates+=("$update -> $url") && found=true
|
||||||
|
done < "$ScriptWorkDir"/urls.list
|
||||||
|
[[ $found == false ]] && Updates+=("$update -> url missing") || continue
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# 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"
|
||||||
if [[ -z "$AutoUp" ]] ; then
|
if [[ -z "$AutoUp" ]] ; then
|
||||||
@@ -153,26 +168,26 @@ if [[ "$VERSION" != "$LatestRelease" ]] ; then
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
### Set $1 to a variable for name filtering later.
|
# Set $1 to a variable for name filtering later
|
||||||
SearchName="$1"
|
SearchName="$1"
|
||||||
### Create array of excludes
|
# Create array of excludes
|
||||||
IFS=',' read -r -a Excludes <<< "$Exclude" ; unset IFS
|
IFS=',' read -r -a Excludes <<< "$Exclude" ; unset IFS
|
||||||
|
|
||||||
### Check if required binary exists in PATH or directory:
|
# Check if required binary exists in PATH or directory
|
||||||
if [[ $(builtin type -P "regctl") ]]; then regbin="regctl" ;
|
if [[ $(command -v regctl) ]]; then regbin="regctl" ;
|
||||||
elif [[ -f "$ScriptWorkDir/regctl" ]]; then regbin="$ScriptWorkDir/regctl" ;
|
elif [[ -f "$ScriptWorkDir/regctl" ]]; then regbin="$ScriptWorkDir/regctl" ;
|
||||||
else
|
else
|
||||||
read -r -p "Required dependency 'regctl' missing, do you want it downloaded? y/[n] " GetDep
|
read -r -p "Required dependency 'regctl' missing, do you want it downloaded? y/[n] " GetDep
|
||||||
if [[ "$GetDep" =~ [yY] ]] ; then
|
if [[ "$GetDep" =~ [yY] ]] ; then
|
||||||
### Check arch:
|
# Check architecture
|
||||||
case "$(uname --machine)" in
|
case "$(uname --machine)" in
|
||||||
x86_64|amd64) architecture="amd64" ;;
|
x86_64|amd64) architecture="amd64" ;;
|
||||||
arm64|aarch64) architecture="arm64";;
|
arm64|aarch64) architecture="arm64";;
|
||||||
*) echo "Architecture not supported, exiting." ; exit 1;;
|
*) echo "Architecture not supported, exiting." ; exit 1;;
|
||||||
esac
|
esac
|
||||||
RegUrl="https://github.com/regclient/regclient/releases/latest/download/regctl-linux-$architecture"
|
RegUrl="https://github.com/regclient/regclient/releases/latest/download/regctl-linux-$architecture"
|
||||||
if [[ $(builtin type -P curl) ]]; then curl -L $RegUrl > "$ScriptWorkDir/regctl" ; chmod +x "$ScriptWorkDir/regctl" ; regbin="$ScriptWorkDir/regctl" ;
|
if [[ $(command -v curl) ]]; then curl -L $RegUrl > "$ScriptWorkDir/regctl" ; chmod +x "$ScriptWorkDir/regctl" ; regbin="$ScriptWorkDir/regctl" ;
|
||||||
elif [[ $(builtin type -P wget) ]]; then wget $RegUrl -O "$ScriptWorkDir/regctl" ; chmod +x "$ScriptWorkDir/regctl" ; regbin="$ScriptWorkDir/regctl" ;
|
elif [[ $(command -v wget) ]]; then wget $RegUrl -O "$ScriptWorkDir/regctl" ; chmod +x "$ScriptWorkDir/regctl" ; regbin="$ScriptWorkDir/regctl" ;
|
||||||
else
|
else
|
||||||
printf "%s\n" "curl/wget not available - get regctl manually from the repo link, quitting."
|
printf "%s\n" "curl/wget not available - get regctl manually from the repo link, quitting."
|
||||||
fi
|
fi
|
||||||
@@ -181,10 +196,10 @@ else
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
### final check if binary is correct
|
# Final check if binary is correct
|
||||||
$regbin version &> /dev/null || { printf "%s\n" "regctl is not working - try to remove it and re-download it, exiting."; exit 1; }
|
$regbin version &> /dev/null || { printf "%s\n" "regctl is not working - try to remove it and re-download it, exiting."; exit 1; }
|
||||||
|
|
||||||
### Check docker compose binary:
|
# Check docker compose binary
|
||||||
if docker compose version &> /dev/null ; then DockerBin="docker compose" ;
|
if docker compose version &> /dev/null ; then DockerBin="docker compose" ;
|
||||||
elif docker-compose -v &> /dev/null; then DockerBin="docker-compose" ;
|
elif docker-compose -v &> /dev/null; then DockerBin="docker-compose" ;
|
||||||
elif docker -v &> /dev/null; then
|
elif docker -v &> /dev/null; then
|
||||||
@@ -195,7 +210,13 @@ else
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
### Numbered List -function:
|
# Check for jq binary
|
||||||
|
if [[ ! $(command -v jq) ]] ; then
|
||||||
|
printf "%s\n" "No jq binary, please install jq and try again, exiting."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Numbered List function
|
||||||
options() {
|
options() {
|
||||||
num=1
|
num=1
|
||||||
for i in "${GotUpdates[@]}"; do
|
for i in "${GotUpdates[@]}"; do
|
||||||
@@ -204,7 +225,7 @@ for i in "${GotUpdates[@]}"; do
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
### Listing typed exclusions:
|
# Listing typed exclusions
|
||||||
if [[ -n ${Excludes[*]} ]] ; then
|
if [[ -n ${Excludes[*]} ]] ; then
|
||||||
printf "\n%bExcluding these names:%b\n" "$c_blue" "$c_reset"
|
printf "\n%bExcluding these names:%b\n" "$c_blue" "$c_reset"
|
||||||
printf "%s\n" "${Excludes[@]}"
|
printf "%s\n" "${Excludes[@]}"
|
||||||
@@ -212,19 +233,30 @@ if [[ -n ${Excludes[*]} ]] ; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Variables for progress_bar function
|
# Variables for progress_bar function
|
||||||
DocCount=$(docker ps $Stopped --filter "name=$SearchName" --format '{{.Names}}' | wc -l)
|
ContCount=$(docker ps $Stopped --filter "name=$SearchName" --format '{{.Names}}' | wc -l)
|
||||||
RegCheckQue=0
|
RegCheckQue=0
|
||||||
|
|
||||||
### Check the image-hash of every running container VS the registry
|
# Testing and setting timeout binary
|
||||||
|
t_out=$(command -v timeout)
|
||||||
|
if [[ $t_out ]]; then
|
||||||
|
t_out=$(realpath $t_out 2>/dev/null || readlink -f $t_out)
|
||||||
|
if [[ $t_out =~ "busybox" ]]; then
|
||||||
|
t_out="timeout ${Timeout}"
|
||||||
|
else t_out="timeout --foreground ${Timeout}"
|
||||||
|
fi
|
||||||
|
else t_out=""
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check the image-hash of every running container VS the registry
|
||||||
for i in $(docker ps $Stopped --filter "name=$SearchName" --format '{{.Names}}') ; do
|
for i in $(docker ps $Stopped --filter "name=$SearchName" --format '{{.Names}}') ; do
|
||||||
((RegCheckQue+=1))
|
((RegCheckQue+=1))
|
||||||
progress_bar "$RegCheckQue" "$DocCount"
|
progress_bar "$RegCheckQue" "$ContCount"
|
||||||
### Looping every item over the list of excluded names and skipping:
|
# Looping every item over the list of excluded names and skipping
|
||||||
for e in "${Excludes[@]}" ; do [[ "$i" == "$e" ]] && continue 2 ; done
|
for e in "${Excludes[@]}" ; do [[ "$i" == "$e" ]] && continue 2 ; done
|
||||||
RepoUrl=$(docker inspect "$i" --format='{{.Config.Image}}')
|
RepoUrl=$(docker inspect "$i" --format='{{.Config.Image}}')
|
||||||
LocalHash=$(docker image inspect "$RepoUrl" --format '{{.RepoDigests}}')
|
LocalHash=$(docker image inspect "$RepoUrl" --format '{{.RepoDigests}}')
|
||||||
### Checking for errors while setting the variable:
|
# Checking for errors while setting the variable
|
||||||
if RegHash=$($regbin image digest --list "$RepoUrl" 2>&1) ; then
|
if RegHash=$(${t_out} $regbin -v error image digest --list "$RepoUrl" 2>&1) ; then
|
||||||
if [[ "$LocalHash" = *"$RegHash"* ]] ; then
|
if [[ "$LocalHash" = *"$RegHash"* ]] ; then
|
||||||
NoUpdates+=("$i")
|
NoUpdates+=("$i")
|
||||||
else
|
else
|
||||||
@@ -235,29 +267,29 @@ for i in $(docker ps $Stopped --filter "name=$SearchName" --format '{{.Names}}')
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
# Here the RegHash is the result of an error code.
|
# Here the RegHash is the result of an error code
|
||||||
GotErrors+=("$i - ${RegHash}")
|
GotErrors+=("$i - ${RegHash}")
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
### Sort arrays alphabetically
|
# Sort arrays alphabetically
|
||||||
IFS=$'\n'
|
IFS=$'\n'
|
||||||
NoUpdates=($(sort <<<"${NoUpdates[*]}"))
|
NoUpdates=($(sort <<<"${NoUpdates[*]}"))
|
||||||
GotUpdates=($(sort <<<"${GotUpdates[*]}"))
|
GotUpdates=($(sort <<<"${GotUpdates[*]}"))
|
||||||
GotErrors=($(sort <<<"${GotErrors[*]}"))
|
|
||||||
unset IFS
|
unset IFS
|
||||||
### Define how many updates are available
|
|
||||||
|
# Define how many updates are available
|
||||||
UpdCount="${#GotUpdates[@]}"
|
UpdCount="${#GotUpdates[@]}"
|
||||||
|
|
||||||
### List what containers got updates or not
|
# List what containers got updates or not
|
||||||
if [[ -n ${NoUpdates[*]} ]] ; then
|
if [[ -n ${NoUpdates[*]} ]] ; then
|
||||||
printf "\n%bContainers on latest version:%b\n" "$c_green" "$c_reset"
|
printf "\n%bContainers on latest version:%b\n" "$c_green" "$c_reset"
|
||||||
printf "%s\n" "${NoUpdates[@]}"
|
printf "%s\n" "${NoUpdates[@]}"
|
||||||
fi
|
fi
|
||||||
if [[ -n ${GotErrors[*]} ]] ; then
|
if [[ -n ${GotErrors[*]} ]] ; then
|
||||||
printf "\n%bContainers with errors, wont get updated:%b\n" "$c_red" "$c_reset"
|
printf "\n%bContainers with errors, won't get updated:%b\n" "$c_red" "$c_reset"
|
||||||
printf "%s\n" "${GotErrors[@]}"
|
printf "%s\n" "${GotErrors[@]}"
|
||||||
printf "%binfo:%b 'unauthorized' often means not found in a public registry.%b\n" "$c_blue" "$c_reset"
|
printf "%binfo:%b 'unauthorized' often means not found in a public registry.\n" "$c_blue" "$c_reset"
|
||||||
fi
|
fi
|
||||||
if [[ -n ${GotUpdates[*]} ]] ; then
|
if [[ -n ${GotUpdates[*]} ]] ; then
|
||||||
printf "\n%bContainers with updates available:%b\n" "$c_yellow" "$c_reset"
|
printf "\n%bContainers with updates available:%b\n" "$c_yellow" "$c_reset"
|
||||||
@@ -265,7 +297,7 @@ if [[ -n ${GotUpdates[*]} ]] ; then
|
|||||||
[[ -n "$Notify" ]] && { [[ $(type -t send_notification) == function ]] && send_notification "${GotUpdates[@]}" || printf "Could not source notification function.\n" ; }
|
[[ -n "$Notify" ]] && { [[ $(type -t send_notification) == function ]] && send_notification "${GotUpdates[@]}" || printf "Could not source notification function.\n" ; }
|
||||||
fi
|
fi
|
||||||
|
|
||||||
### Optionally get updates if there's any
|
# Optionally get updates if there's any
|
||||||
if [ -n "$GotUpdates" ] ; then
|
if [ -n "$GotUpdates" ] ; then
|
||||||
if [ -z "$AutoUp" ] ; then
|
if [ -z "$AutoUp" ] ; then
|
||||||
printf "\n%bChoose what containers to update.%b\n" "$c_teal" "$c_reset"
|
printf "\n%bChoose what containers to update.%b\n" "$c_teal" "$c_reset"
|
||||||
@@ -280,14 +312,23 @@ if [ -n "$GotUpdates" ] ; then
|
|||||||
do
|
do
|
||||||
((CurrentQue+=1))
|
((CurrentQue+=1))
|
||||||
unset CompleteConfs
|
unset CompleteConfs
|
||||||
ContPath=$(docker inspect "$i" --format '{{ index .Config.Labels "com.docker.compose.project.working_dir" }}')
|
# Extract labels and metadata
|
||||||
ContConfigFile=$(docker inspect "$i" --format '{{ index .Config.Labels "com.docker.compose.project.config_files" }}')
|
ContLabels=$(docker inspect "$i" --format '{{json .Config.Labels}}')
|
||||||
ContName=$(docker inspect "$i" --format '{{ index .Config.Labels "com.docker.compose.service" }}')
|
|
||||||
ContEnv=$(docker inspect "$i" --format '{{index .Config.Labels "com.docker.compose.project.environment_file" }}')
|
|
||||||
ContImage=$(docker inspect "$i" --format='{{.Config.Image}}')
|
ContImage=$(docker inspect "$i" --format='{{.Config.Image}}')
|
||||||
ContUpdateLabel=$(docker inspect "$i" --format '{{ index .Config.Labels "mag37.dockcheck.update" }}')
|
ContPath=$(jq -r '."com.docker.compose.project.working_dir"' <<< "$ContLabels")
|
||||||
ContRestartStack=$(docker inspect "$i" --format '{{ index .Config.Labels "mag37.dockcheck.restart-stack" }}')
|
[ "$ContPath" == "null" ] && ContPath=""
|
||||||
### Checking if compose-values are empty - hence started with docker run:
|
ContConfigFile=$(jq -r '."com.docker.compose.project.config_files"' <<< "$ContLabels")
|
||||||
|
[ "$ContConfigFile" == "null" ] && ContConfigFile=""
|
||||||
|
ContName=$(jq -r '."com.docker.compose.service"' <<< "$ContLabels")
|
||||||
|
[ "$ContName" == "null" ] && ContName=""
|
||||||
|
ContEnv=$(jq -r '."com.docker.compose.project.environment_file"' <<< "$ContLabels")
|
||||||
|
[ "$ContEnv" == "null" ] && ContEnv=""
|
||||||
|
ContUpdateLabel=$(jq -r '."mag37.dockcheck.update"' <<< "$ContLabels")
|
||||||
|
[ "$ContUpdateLabel" == "null" ] && ContUpdateLabel=""
|
||||||
|
ContRestartStack=$(jq -r '."mag37.dockcheck.restart-stack"' <<< "$ContLabels")
|
||||||
|
[ "$ContRestartStack" == "null" ] && ContRestartStack=""
|
||||||
|
|
||||||
|
# Checking if compose-values are empty - hence started with docker run
|
||||||
if [ -z "$ContPath" ] ; then
|
if [ -z "$ContPath" ] ; then
|
||||||
if [ "$DRunUp" == "yes" ] ; then
|
if [ "$DRunUp" == "yes" ] ; then
|
||||||
docker pull "$ContImage"
|
docker pull "$ContImage"
|
||||||
@@ -297,41 +338,29 @@ if [ -n "$GotUpdates" ] ; then
|
|||||||
fi
|
fi
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
### Checking if "com.docker.compose.project.config_files" returns the full path to the config file or just the file name
|
# cd to the compose-file directory to account for people who use relative volumes
|
||||||
if [[ $ContConfigFile = '/'* ]] ; then
|
|
||||||
ComposeFile="$ContConfigFile"
|
|
||||||
else
|
|
||||||
ComposeFile="$ContPath/$ContConfigFile"
|
|
||||||
fi
|
|
||||||
### cd to the compose-file directory to account for people who use relative volumes, eg - ${PWD}/data:data
|
|
||||||
cd "$ContPath" || { echo "Path error - skipping $i" ; continue ; }
|
cd "$ContPath" || { echo "Path error - skipping $i" ; continue ; }
|
||||||
|
## Reformatting path + multi compose
|
||||||
|
if [[ $ContConfigFile = '/'* ]] ; then
|
||||||
|
CompleteConfs=$(for conf in ${ContConfigFile//,/ } ; do printf -- "-f %s " "$conf"; done)
|
||||||
|
else
|
||||||
|
CompleteConfs=$(for conf in ${ContConfigFile//,/ } ; do printf -- "-f %s/%s " "$ContPath" "$conf"; done)
|
||||||
|
fi
|
||||||
printf "\n%bNow updating (%s/%s): %b%s%b\n" "$c_teal" "$CurrentQue" "$NumberofUpdates" "$c_blue" "$i" "$c_reset"
|
printf "\n%bNow updating (%s/%s): %b%s%b\n" "$c_teal" "$CurrentQue" "$NumberofUpdates" "$c_blue" "$i" "$c_reset"
|
||||||
### Checking if Label Only -option is set, and if container got the label
|
# Checking if Label Only -option is set, and if container got the label
|
||||||
[[ "$OnlyLabel" == true ]] && { [[ "$ContUpdateLabel" != true ]] && { echo "No update label, skipping." ; continue ; } }
|
[[ "$OnlyLabel" == true ]] && { [[ "$ContUpdateLabel" != true ]] && { echo "No update label, skipping." ; continue ; } }
|
||||||
docker pull "$ContImage"
|
docker pull "$ContImage"
|
||||||
### Reformat for multi-compose:
|
# Check if the container got an environment file set and reformat it
|
||||||
IFS=',' read -r -a Confs <<< "$ComposeFile" ; unset IFS
|
if [ -n "$ContEnv" ]; then ContEnvs=$(for env in ${ContEnv//,/ } ; do printf -- "--env-file %s " "$env"; done) ; fi
|
||||||
for conf in "${Confs[@]}"; do CompleteConfs+="-f $conf " ; done
|
# Check if the whole stack should be restarted
|
||||||
### Check if the container got an environment file set, use it if so:
|
|
||||||
if [ -n "$ContEnv" ]; then
|
|
||||||
### prepare env-files arguments
|
|
||||||
ContEnvs=$(for env in ${ContEnv//,/ } ; do printf -- "--env-file %s " "$env"; done)
|
|
||||||
### 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
|
$DockerBin ${CompleteConfs} stop ; $DockerBin ${CompleteConfs} ${ContEnvs} up -d
|
||||||
else
|
else
|
||||||
$DockerBin ${CompleteConfs[@]} ${ContEnvs} up -d "$ContName" # unquoted array to allow split - rework?
|
$DockerBin ${CompleteConfs} ${ContEnvs} up -d ${ContName}
|
||||||
fi
|
|
||||||
else
|
|
||||||
if [[ "$ContRestartStack" == true ]] || [[ "$ForceRestartStacks" == true ]] ; then
|
|
||||||
$DockerBin ${CompleteConfs[@]} stop ; $DockerBin ${CompleteConfs[@]} up -d
|
|
||||||
else
|
|
||||||
$DockerBin ${CompleteConfs[@]} up -d "$ContName"
|
|
||||||
fi
|
|
||||||
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"
|
||||||
@@ -341,4 +370,3 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|
||||||
|
|||||||
@@ -2,12 +2,21 @@
|
|||||||
SearchName="$1"
|
SearchName="$1"
|
||||||
for i in $(docker ps --filter "name=$SearchName" --format '{{.Names}}') ; do
|
for i in $(docker ps --filter "name=$SearchName" --format '{{.Names}}') ; do
|
||||||
echo "------------ $i ------------"
|
echo "------------ $i ------------"
|
||||||
ContPath=$(docker inspect "$i" --format '{{ index .Config.Labels "com.docker.compose.project.working_dir" }}')
|
ContLabels=$(docker inspect "$i" --format '{{json .Config.Labels}}')
|
||||||
[ -z "$ContPath" ] && { "$i has no compose labels - skipping" ; continue ; }
|
|
||||||
ContConfigFile=$(docker inspect "$i" --format '{{ index .Config.Labels "com.docker.compose.project.config_files" }}')
|
|
||||||
ContName=$(docker inspect "$i" --format '{{ index .Config.Labels "com.docker.compose.service" }}')
|
|
||||||
ContEnv=$(docker inspect "$i" --format '{{index .Config.Labels "com.docker.compose.project.environment_file" }}')
|
|
||||||
ContImage=$(docker inspect "$i" --format='{{.Config.Image}}')
|
ContImage=$(docker inspect "$i" --format='{{.Config.Image}}')
|
||||||
|
ContPath=$(jq -r '."com.docker.compose.project.working_dir"' <<< "$ContLabels")
|
||||||
|
[ "$ContPath" == "null" ] && ContPath=""
|
||||||
|
[ -z "$ContPath" ] && { "$i has no compose labels - skipping" ; continue ; }
|
||||||
|
ContConfigFile=$(jq -r '."com.docker.compose.project.config_files"' <<< "$ContLabels")
|
||||||
|
[ "$ContConfigFile" == "null" ] && ContConfigFile=""
|
||||||
|
ContName=$(jq -r '."com.docker.compose.service"' <<< "$ContLabels")
|
||||||
|
[ "$ContName" == "null" ] && ContName=""
|
||||||
|
ContEnv=$(jq -r '."com.docker.compose.project.environment_file"' <<< "$ContLabels")
|
||||||
|
[ "$ContEnv" == "null" ] && ContEnv=""
|
||||||
|
ContUpdateLabel=$(jq -r '."mag37.dockcheck.update"' <<< "$ContLabels")
|
||||||
|
[ "$ContUpdateLabel" == "null" ] && ContUpdateLabel=""
|
||||||
|
ContRestartStack=$(jq -r '."mag37.dockcheck.restart-stack"' <<< "$ContLabels")
|
||||||
|
[ "$ContRestartStack" == "null" ] && ContRestartStack=""
|
||||||
|
|
||||||
if [[ $ContConfigFile = '/'* ]] ; then
|
if [[ $ContConfigFile = '/'* ]] ; then
|
||||||
ComposeFile="$ContConfigFile"
|
ComposeFile="$ContConfigFile"
|
||||||
@@ -20,6 +29,8 @@ for i in $(docker ps --filter "name=$SearchName" --format '{{.Names}}') ; do
|
|||||||
echo -e "Compose files:\t\t$ComposeFile"
|
echo -e "Compose files:\t\t$ComposeFile"
|
||||||
echo -e "Environment files:\t$ContEnv"
|
echo -e "Environment files:\t$ContEnv"
|
||||||
echo -e "Container image:\t$ContImage"
|
echo -e "Container image:\t$ContImage"
|
||||||
|
echo -e "Update label:\t$ContUpdateLabel"
|
||||||
|
echo -e "Restart Stack label:\t$ContRestartStack"
|
||||||
echo
|
echo
|
||||||
echo "Mounts:"
|
echo "Mounts:"
|
||||||
docker inspect -f '{{ range .Mounts }}{{ .Source }}:{{ .Destination }}{{ printf "\n" }}{{ end }}' "$i"
|
docker inspect -f '{{ range .Mounts }}{{ .Source }}:{{ .Destination }}{{ printf "\n" }}{{ end }}' "$i"
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 404 KiB After Width: | Height: | Size: 472 KiB |
BIN
extras/example_old.gif
Normal file
BIN
extras/example_old.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 404 KiB |
@@ -1,34 +0,0 @@
|
|||||||
### DISCLAIMER: This is a third party addition to dockcheck - best effort testing.
|
|
||||||
#
|
|
||||||
# Copy/rename this file to notify.sh to enable email notifications on Synology DSM
|
|
||||||
# DSM Notification Email has to be configured manually.
|
|
||||||
# Modify to your liking - changing SendMailTo and Subject and content.
|
|
||||||
|
|
||||||
send_notification() {
|
|
||||||
Updates=("$@")
|
|
||||||
UpdToString=$( printf "%s\n" "${Updates[@]}" )
|
|
||||||
FromHost=$(hostname)
|
|
||||||
|
|
||||||
# User variables:
|
|
||||||
# change this to your usual destination for synology DSM notification emails
|
|
||||||
SendMailTo="me@mydomain.com"
|
|
||||||
SubjectTag="diskstation"
|
|
||||||
|
|
||||||
printf "\nSending email notification.\n"
|
|
||||||
|
|
||||||
ssmtp $SendMailTo << __EOF
|
|
||||||
From: "$FromHost" <$SendMailTo>
|
|
||||||
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
|
|
||||||
|
|
||||||
From $FromHost
|
|
||||||
|
|
||||||
__EOF
|
|
||||||
}
|
|
||||||
52
notify_templates/notify_DSM.sh
Normal file
52
notify_templates/notify_DSM.sh
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
### DISCLAIMER: This is a third party addition to dockcheck - best effort testing.
|
||||||
|
# INFO: ssmtp is depcerated - consider to use msmtp instead.
|
||||||
|
#
|
||||||
|
# Copy/rename this file to notify.sh to enable the notification snipppet.
|
||||||
|
# mSMTP/sSMTP has to be installed and configured manually.
|
||||||
|
# The existing DSM Notification Email configuration will be used automatically.
|
||||||
|
# Modify to your liking - changing SendMailTo and Subject and content.
|
||||||
|
|
||||||
|
MSMTP=$(which msmtp)
|
||||||
|
SSMTP=$(which ssmtp)
|
||||||
|
|
||||||
|
if [ -n "$MSMTP" ] ; then
|
||||||
|
MailPkg=$MSMTP
|
||||||
|
elif [ -n "$SSMTP" ] ; then
|
||||||
|
MailPkg=$SSMTP
|
||||||
|
else
|
||||||
|
echo "No msmtp or ssmtp binary found in PATH: $PATH" ; exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
send_notification() {
|
||||||
|
[ -s "$ScriptWorkDir"/urls.list ] && releasenotes || Updates=("$@")
|
||||||
|
UpdToString=$( printf '%s\\n' "${Updates[@]}" )
|
||||||
|
FromHost=$(hostname)
|
||||||
|
CfgFile="/usr/syno/etc/synosmtp.conf"
|
||||||
|
|
||||||
|
# User variables:
|
||||||
|
# Automatically sends to your usual destination for synology DSM notification emails.
|
||||||
|
# You can also manually override by assigning something else to SendMailTo below.
|
||||||
|
SendMailTo=$(grep 'eventmail1' $CfgFile | sed -n 's/.*"\([^"]*\)".*/\1/p')
|
||||||
|
#SendMailTo="me@mydomain.com"
|
||||||
|
|
||||||
|
SubjectTag=$(grep 'eventsubjectprefix' $CfgFile | sed -n 's/.*"\([^"]*\)".*/\1/p')
|
||||||
|
SenderName=$(grep 'smtp_from_name' $CfgFile | sed -n 's/.*"\([^"]*\)".*/\1/p')
|
||||||
|
SenderMail=$(grep 'smtp_from_mail' $CfgFile | sed -n 's/.*"\([^"]*\)".*/\1/p')
|
||||||
|
SenderMail=${SenderMail:-$(grep 'eventmail1' $CfgFile | sed -n 's/.*"\([^"]*\)".*/\1/p')}
|
||||||
|
|
||||||
|
printf "\nSending email notification.\n"
|
||||||
|
|
||||||
|
printf -v MessageBody "🐋 Containers on $FromHost with updates available:\n\n$UpdToString"
|
||||||
|
|
||||||
|
$MailPkg $SendMailTo << __EOF
|
||||||
|
From: "$SenderName" <$SenderMail>
|
||||||
|
date:$(date -R)
|
||||||
|
To: <$SendMailTo>
|
||||||
|
Subject: $SubjectTag Updates available on $FromHost
|
||||||
|
Content-Type: text/plain; charset=UTF-8; format=flowed
|
||||||
|
Content-Transfer-Encoding: 7bit
|
||||||
|
|
||||||
|
$MessageBody
|
||||||
|
From $SenderName
|
||||||
|
__EOF
|
||||||
|
}
|
||||||
@@ -5,20 +5,15 @@
|
|||||||
# Modify to fit your setup - if API, set AppriseURL to your Apprise ip/domain.
|
# Modify to fit your setup - if API, set AppriseURL to your Apprise ip/domain.
|
||||||
|
|
||||||
send_notification() {
|
send_notification() {
|
||||||
Updates=("$@")
|
[ -s "$ScriptWorkDir"/urls.list ] && releasenotes || Updates=("$@")
|
||||||
UpdToString=$( printf "%s\n" "${Updates[@]}" )
|
UpdToString=$( printf '%s\\n' "${Updates[@]}" )
|
||||||
FromHost=$(hostname)
|
FromHost=$(hostname)
|
||||||
|
|
||||||
printf "\nSending Apprise notification\n"
|
printf "\nSending Apprise notification\n"
|
||||||
|
|
||||||
MessageTitle="$FromHost - updates available."
|
MessageTitle="$FromHost - updates available."
|
||||||
# Setting the MessageBody variable here.
|
# Setting the MessageBody variable here.
|
||||||
read -d '\n' MessageBody << __EOF
|
printf -v MessageBody "🐋 Containers on $FromHost with updates available:\n$UpdToString"
|
||||||
Containers on $FromHost with updates available:
|
|
||||||
|
|
||||||
$UpdToString
|
|
||||||
|
|
||||||
__EOF
|
|
||||||
|
|
||||||
# Modify to fit your setup:
|
# Modify to fit your setup:
|
||||||
apprise -vv -t "$MessageTitle" -b "$MessageBody" \
|
apprise -vv -t "$MessageTitle" -b "$MessageBody" \
|
||||||
@@ -33,5 +28,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
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
28
notify_templates/notify_discord.sh
Normal file
28
notify_templates/notify_discord.sh
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
### 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 - set DiscordWebhookUrl
|
||||||
|
|
||||||
|
send_notification() {
|
||||||
|
[ -s "$ScriptWorkDir"/urls.list ] && releasenotes || Updates=("$@")
|
||||||
|
UpdToString=$( printf '%s\\n' "${Updates[@]}" )
|
||||||
|
|
||||||
|
echo "$UpdToString"
|
||||||
|
FromHost=$(hostname)
|
||||||
|
|
||||||
|
# platform specific notification code would go here
|
||||||
|
printf "\nSending Discord notification\n"
|
||||||
|
|
||||||
|
# Setting the MessageBody variable here.
|
||||||
|
MessageBody="🐋 Containers on $FromHost with updates available: \n$UpdToString"
|
||||||
|
|
||||||
|
# Modify to fit your setup:
|
||||||
|
DiscordWebhookUrl="PasteYourFullDiscordWebhookURL"
|
||||||
|
|
||||||
|
MsgBody="{\"username\":\"$FromHost\",\"content\":\"$MessageBody\"}"
|
||||||
|
|
||||||
|
curl -sS -o /dev/null --fail -X POST -H "Content-Type: application/json" -d "$MsgBody" "$DiscordWebhookUrl"
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@@ -4,11 +4,13 @@
|
|||||||
# generic sample, the "Hello World" of notification addons
|
# generic sample, the "Hello World" of notification addons
|
||||||
|
|
||||||
send_notification() {
|
send_notification() {
|
||||||
Updates=("$@")
|
[ -s "$ScriptWorkDir"/urls.list ] && releasenotes || Updates=("$@")
|
||||||
UpdToString=$( printf "%s\n" "${Updates[@]}" )
|
UpdToString=$( printf '%s\\n' "${Updates[@]}" )
|
||||||
|
|
||||||
FromHost=$(hostname)
|
FromHost=$(hostname)
|
||||||
|
|
||||||
# platform specific notification code would go here
|
# platform specific notification code would go here
|
||||||
printf "\n%bGeneric notification addon:%b" "$c_green" "$c_reset"
|
printf "\n%bGeneric notification addon:%b" "$c_green" "$c_reset"
|
||||||
printf "\nThe following docker containers on %s need to be updated:\n%s\n" "$FromHost" "$UpdToString"
|
printf "\nThe following docker containers on %s need to be updated:\n" "$FromHost"
|
||||||
|
printf "$UpdToString"
|
||||||
}
|
}
|
||||||
29
notify_templates/notify_gotify.sh
Normal file
29
notify_templates/notify_gotify.sh
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
### 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 - set GotifyUrl and GotifyToken.
|
||||||
|
|
||||||
|
send_notification() {
|
||||||
|
[ -s "$ScriptWorkDir"/urls.list ] && releasenotes || Updates=("$@")
|
||||||
|
UpdToString=$( printf '%s\\n' "${Updates[@]}" )
|
||||||
|
FromHost=$(hostname)
|
||||||
|
|
||||||
|
# platform specific notification code would go here
|
||||||
|
printf "\nSending Gotify notification\n"
|
||||||
|
|
||||||
|
# Setting the MessageTitle and MessageBody variable here.
|
||||||
|
MessageTitle="${FromHost} - updates available."
|
||||||
|
printf -v MessageBody "🐋 Containers on $FromHost with updates available:\n$UpdToString"
|
||||||
|
|
||||||
|
# Modify to fit your setup:
|
||||||
|
GotifyToken="Your Gotify token here"
|
||||||
|
GotifyUrl="https://api.gotify/message?token=${GotifyToken}"
|
||||||
|
|
||||||
|
curl \
|
||||||
|
-F "title=${MessageTitle}" \
|
||||||
|
-F "message=${MessageBody}" \
|
||||||
|
-F "priority=5" \
|
||||||
|
-X POST "${GotifyUrl}" &> /dev/null
|
||||||
|
|
||||||
|
}
|
||||||
28
notify_templates/notify_matrix.sh
Normal file
28
notify_templates/notify_matrix.sh
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
### 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 - set MatrixServer, Room_id and AccessToken
|
||||||
|
|
||||||
|
send_notification() {
|
||||||
|
[ -s "$ScriptWorkDir"/urls.list ] && releasenotes || Updates=("$@")
|
||||||
|
UpdToString=$( printf '%s\\n' "${Updates[@]}" )
|
||||||
|
FromHost=$(hostname)
|
||||||
|
|
||||||
|
# platform specific notification code would go here
|
||||||
|
printf "\nSending Matrix notification\n"
|
||||||
|
|
||||||
|
# Setting the MessageBody variable here.
|
||||||
|
MessageBody="🐋 Containers on $FromHost with updates available: \n$UpdToString"
|
||||||
|
|
||||||
|
# Modify to fit your setup:
|
||||||
|
AccessToken="Your Matrix token here"
|
||||||
|
Room_id="Enter Room_id here"
|
||||||
|
MatrixServer="Enter Your HomeServer URL"
|
||||||
|
MsgBody="{\"msgtype\":\"m.text\",\"body\":\"$MessageBody\"}"
|
||||||
|
|
||||||
|
# URL Example: https://matrix.org/_matrix/client/r0/rooms/!xxxxxx:example.com/send/m.room.message?access_token=xxxxxxxx
|
||||||
|
|
||||||
|
curl -sS -o /dev/null --fail -X POST "$MatrixServer/_matrix/client/r0/rooms/$Room_id/send/m.room.message?access_token=$AccessToken" -H 'Content-Type: application/json' -d "$MsgBody"
|
||||||
|
|
||||||
|
}
|
||||||
@@ -5,20 +5,15 @@
|
|||||||
# Use your unique Topic Name in the URL below.
|
# Use your unique Topic Name in the URL below.
|
||||||
|
|
||||||
send_notification() {
|
send_notification() {
|
||||||
Updates=("$@")
|
[ -s "$ScriptWorkDir"/urls.list ] && releasenotes || Updates=("$@")
|
||||||
UpdToString=$( printf "%s\n" "${Updates[@]}" )
|
UpdToString=$( printf '%s\\n' "${Updates[@]}" )
|
||||||
FromHost=$(hostname)
|
FromHost=$(hostname)
|
||||||
|
|
||||||
printf "\nSending ntfy.sh notification\n"
|
printf "\nSending ntfy.sh notification\n"
|
||||||
|
|
||||||
MessageTitle="$FromHost - updates available."
|
MessageTitle="$FromHost - updates available."
|
||||||
# Setting the MessageBody variable here.
|
# Setting the MessageBody variable here.
|
||||||
read -d '\n' MessageBody << __EOF
|
printf -v MessageBody "🐋 Containers on $FromHost with updates available:\n$UpdToString"
|
||||||
Containers on $FromHost with updates available:
|
|
||||||
|
|
||||||
$UpdToString
|
|
||||||
|
|
||||||
__EOF
|
|
||||||
|
|
||||||
# Modify to fit your setup:
|
# Modify to fit your setup:
|
||||||
NtfyUrl="ntfy.sh/YourUniqueTopicName"
|
NtfyUrl="ntfy.sh/YourUniqueTopicName"
|
||||||
@@ -6,8 +6,8 @@
|
|||||||
# Modify to fit your setup - set Url and Token.
|
# Modify to fit your setup - set Url and Token.
|
||||||
|
|
||||||
send_notification() {
|
send_notification() {
|
||||||
Updates=("$@")
|
[ -s "$ScriptWorkDir"/urls.list ] && releasenotes || Updates=("$@")
|
||||||
UpdToString=$( printf "%s\n" "${Updates[@]}" )
|
UpdToString=$( printf '%s\\n' "${Updates[@]}" )
|
||||||
FromHost=$(hostname)
|
FromHost=$(hostname)
|
||||||
|
|
||||||
# platform specific notification code would go here
|
# platform specific notification code would go here
|
||||||
@@ -15,7 +15,7 @@ printf "\nSending pushbullet notification\n"
|
|||||||
|
|
||||||
MessageTitle="$FromHost - updates available."
|
MessageTitle="$FromHost - updates available."
|
||||||
# Setting the MessageBody variable here.
|
# Setting the MessageBody variable here.
|
||||||
MessageBody="Containers on $FromHost with updates available: $UpdToString"
|
printf -v MessageBody "🐋 Containers on $FromHost with updates available:\n$UpdToString"
|
||||||
|
|
||||||
# Modify to fit your setup:
|
# Modify to fit your setup:
|
||||||
PushUrl="https://api.pushbullet.com/v2/pushes"
|
PushUrl="https://api.pushbullet.com/v2/pushes"
|
||||||
32
notify_templates/notify_pushover.sh
Normal file
32
notify_templates/notify_pushover.sh
Normal 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() {
|
||||||
|
[ -s "$ScriptWorkDir"/urls.list ] && releasenotes || Updates=("$@")
|
||||||
|
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.
|
||||||
|
printf -v MessageBody "🐋 Containers on $FromHost with updates available:\n$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
|
||||||
|
}
|
||||||
@@ -1,12 +1,24 @@
|
|||||||
### DISCLAIMER: This is a third party addition to dockcheck - best effort testing.
|
### DISCLAIMER: This is a third party addition to dockcheck - best effort testing.
|
||||||
|
# INFO: ssmtp is depcerated - consider to use msmtp instead.
|
||||||
#
|
#
|
||||||
# Copy/rename this file to notify.sh to enable the notification snipppet.
|
# Copy/rename this file to notify.sh to enable the notification snipppet.
|
||||||
# sSMTP has to be installed and configured manually.
|
# mSMTP/sSMTP has to be installed and configured manually.
|
||||||
# Modify to fit your setup - changing SendMailFrom, SendMailTo, SubjectTag
|
# Modify to fit your setup - changing SendMailFrom, SendMailTo, SubjectTag
|
||||||
|
|
||||||
|
MSMTP=$(which msmtp)
|
||||||
|
SSMTP=$(which ssmtp)
|
||||||
|
|
||||||
|
if [ -n "$MSMTP" ] ; then
|
||||||
|
MailPkg=$MSMTP
|
||||||
|
elif [ -n "$SSMTP" ] ; then
|
||||||
|
MailPkg=$SSMTP
|
||||||
|
else
|
||||||
|
echo "No msmtp or ssmtp binary found in PATH: $PATH" ; exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
send_notification() {
|
send_notification() {
|
||||||
Updates=("$@")
|
[ -s "$ScriptWorkDir"/urls.list ] && releasenotes || Updates=("$@")
|
||||||
UpdToString=$( printf "%s\n" "${Updates[@]}" )
|
UpdToString=$( printf '%s\\n' "${Updates[@]}" )
|
||||||
FromHost=$(hostname)
|
FromHost=$(hostname)
|
||||||
|
|
||||||
# User variables:
|
# User variables:
|
||||||
@@ -16,7 +28,9 @@ SubjectTag="dockcheck"
|
|||||||
|
|
||||||
printf "\nSending email notification.\n"
|
printf "\nSending email notification.\n"
|
||||||
|
|
||||||
ssmtp $SendMailTo << __EOF
|
printf -v MessageBody "🐋 Containers on $FromHost with updates available:\n\n$UpdToString"
|
||||||
|
|
||||||
|
$MailPkg $SendMailTo << __EOF
|
||||||
From: "$FromHost" <$SendMailFrom>
|
From: "$FromHost" <$SendMailFrom>
|
||||||
date:$(date -R)
|
date:$(date -R)
|
||||||
To: <$SendMailTo>
|
To: <$SendMailTo>
|
||||||
@@ -24,9 +38,7 @@ Subject: [$SubjectTag] Updates available on $FromHost
|
|||||||
Content-Type: text/plain; charset=UTF-8; format=flowed
|
Content-Type: text/plain; charset=UTF-8; format=flowed
|
||||||
Content-Transfer-Encoding: 7bit
|
Content-Transfer-Encoding: 7bit
|
||||||
|
|
||||||
The following containers on $FromHost have updates available:
|
$MessageBody
|
||||||
|
|
||||||
$UpdToString
|
|
||||||
|
|
||||||
__EOF
|
__EOF
|
||||||
}
|
}
|
||||||
@@ -5,8 +5,8 @@
|
|||||||
# Modify to fit your setup - set TelegramChatId and TelegramToken.
|
# Modify to fit your setup - set TelegramChatId and TelegramToken.
|
||||||
|
|
||||||
send_notification() {
|
send_notification() {
|
||||||
Updates=("$@")
|
[ -s "$ScriptWorkDir"/urls.list ] && releasenotes || Updates=("$@")
|
||||||
UpdToString=$( printf "%s\n" "${Updates[@]}" )
|
UpdToString=$( printf '%s\\n' "${Updates[@]}" )
|
||||||
FromHost=$(hostname)
|
FromHost=$(hostname)
|
||||||
|
|
||||||
# platform specific notification code would go here
|
# platform specific notification code would go here
|
||||||
@@ -19,7 +19,8 @@ send_notification() {
|
|||||||
TelegramToken="Your Telegram token here"
|
TelegramToken="Your Telegram token here"
|
||||||
TelegramChatId="Your Telegram ChatId here"
|
TelegramChatId="Your Telegram ChatId here"
|
||||||
TelegramUrl="https://api.telegram.org/bot$TelegramToken"
|
TelegramUrl="https://api.telegram.org/bot$TelegramToken"
|
||||||
TelegramData="{\"chat_id\":\"$TelegramChatId\",\"text\":\"$MessageBody\",\"disable_notification\": false}"
|
TelegramTopicID=12345678 ## Set to 0 if not using specific topic within chat
|
||||||
|
TelegramData="{\"chat_id\":\"$TelegramChatId\",\"text\":\"$MessageBody\",\"message_thread_id\":\"$TelegramTopicID\",\"disable_notification\": false}"
|
||||||
|
|
||||||
curl -sS -o /dev/null --fail -X POST "$TelegramUrl/sendMessage" -H 'Content-Type: application/json' -d "$TelegramData"
|
curl -sS -o /dev/null --fail -X POST "$TelegramUrl/sendMessage" -H 'Content-Type: application/json' -d "$TelegramData"
|
||||||
|
|
||||||
35
notify_templates/urls.list
Normal file
35
notify_templates/urls.list
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
# 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
|
||||||
|
bruceforce-vaultwarden-backup https://github.com/Bruceforce/vaultwarden-backup/blob/main/CHANGELOG.md
|
||||||
|
actual_server https://actualbudget.org/blog
|
||||||
|
gotify https://github.com/gotify/server/releases
|
||||||
|
traefik https://github.com/traefik/traefik/releases
|
||||||
|
caddy https://github.com/caddyserver/caddy/releases
|
||||||
|
|
||||||
|
calibre https://github.com/linuxserver/docker-calibre/releases
|
||||||
|
calibre-web https://github.com/linuxserver/docker-calibre-web/releases
|
||||||
|
readarr https://github.com/Readarr/Readarr/releases
|
||||||
|
audiobookshelf https://github.com/advplyr/audiobookshelf/releases
|
||||||
|
|
||||||
|
gluetun https://github.com/qdm12/gluetun/releases
|
||||||
|
bazarr https://github.com/morpheus65535/bazarr/releases
|
||||||
|
bazarr-ls https://github.com/linuxserver/docker-bazarr/releases
|
||||||
|
prowlarr https://github.com/Prowlarr/Prowlarr/releases
|
||||||
|
prowlarr-ls https://github.com/linuxserver/docker-prowlarr/releases
|
||||||
|
recyclarr https://github.com/recyclarr/recyclarr/releases
|
||||||
|
sabnzbd https://github.com/linuxserver/docker-sabnzbd/releases
|
||||||
|
sonarr https://github.com/linuxserver/docker-sonarr/releases
|
||||||
|
radarr https://github.com/linuxserver/docker-radarr/releases
|
||||||
|
lidarr https://github.com/linuxserver/docker-lidarr/releases
|
||||||
|
jellyseerr https://github.com/Fallenbagel/jellyseerr/releases
|
||||||
|
jellyfin https://github.com/jellyfin/jellyfin/releases
|
||||||
|
|
||||||
|
home-assistant https://github.com/home-assistant/docker/releases
|
||||||
|
zigbee2mqtt https://github.com/Koenkk/zigbee2mqtt/releases
|
||||||
|
mqtt https://github.com/eclipse/mosquitto/tags
|
||||||
Reference in New Issue
Block a user