mirror of
https://github.com/mag37/dockcheck.git
synced 2026-04-18 02:17:46 +00:00
Compare commits
40 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
48057dfc66 | ||
|
|
98e80854be | ||
|
|
dcbdb5becd | ||
|
|
8fc4f41c49 | ||
|
|
9b0b6137a3 | ||
|
|
7ed4286fe7 | ||
|
|
bf1e78d2ff | ||
|
|
9fa398e553 | ||
|
|
9ef2ea7135 | ||
|
|
8c3b899332 | ||
|
|
8110cd8892 | ||
|
|
502a167919 | ||
|
|
61f90893ef | ||
|
|
229cde0efb | ||
|
|
0c6674ac8e | ||
|
|
3e079e2ec5 | ||
|
|
b2d67c9f52 | ||
|
|
3aeee837f9 | ||
|
|
408a8b14dd | ||
|
|
a2868ea505 | ||
|
|
62a3d10b4f | ||
|
|
210c076968 | ||
|
|
65e875e860 | ||
|
|
3655f5ae8a | ||
|
|
78a7e1137f | ||
|
|
76e6a5c38b | ||
|
|
41029f628d | ||
|
|
b918844336 | ||
|
|
27896c18ba | ||
|
|
06ea7fff6d | ||
|
|
e68adb34d0 | ||
|
|
6bc896b193 | ||
|
|
6cba140522 | ||
|
|
73050abf10 | ||
|
|
d4d89c305c | ||
|
|
c436def448 | ||
|
|
96ebe079a4 | ||
|
|
111cb955b1 | ||
|
|
71967277aa | ||
|
|
1548b03a9e |
39
README.md
39
README.md
@@ -16,20 +16,22 @@
|
|||||||
|
|
||||||
<h4 align="center">For Podman - see the fork <a href="https://github.com/sudo-kraken/podcheck">sudo-kraken/podcheck</a>!</h4>
|
<h4 align="center">For Podman - see the fork <a href="https://github.com/sudo-kraken/podcheck">sudo-kraken/podcheck</a>!</h4>
|
||||||
|
|
||||||
|
<h4 align="center">:whale: Docker Hub pull limit :chart_with_downwards_trend: not an issue for checks but for actual pulls - <a href="#whale-docker-hub-pull-limit-chart_with_downwards_trend-not-an-issue-for-checks-but-for-actual-pulls">read more</a></h4>
|
||||||
|
|
||||||
___
|
___
|
||||||
## :bell: Changelog
|
## :bell: Changelog
|
||||||
|
|
||||||
|
- **v0.5.7.0**: Rewritten templates - now with a function to notify when there's a new Dockcheck release.
|
||||||
|
- Manually migrate your current `notify.sh` settings to a new template for new functionality.
|
||||||
|
- **v0.5.6.1**: Async xargs hotfix - due to errors `failed to request manifest head ... context canceled`
|
||||||
|
- Defaulted subprocess to 1 with `MaxAsync=1`, increase to find a stable value in your environment.
|
||||||
|
- Added `-x N` option to pass `MaxAsync` value at runtime.
|
||||||
|
- To disable xargs `-P` flag (max processes) all together, set `MaxAsync` to 0.
|
||||||
|
- **v0.5.6.0**: Heavily improved performance due to async checking for updates.
|
||||||
|
- **v0.5.5.0**: osx and bsd compatibility changes + rewrite of dependency installer
|
||||||
- **v0.5.4.0**: Added support for a Prometheus+node_exporter metric collection through a file collector.
|
- **v0.5.4.0**: Added support for a Prometheus+node_exporter metric collection through a file collector.
|
||||||
- **v0.5.3.0**: Local image check changed (use imageId instead of name) and Gotify-template fixed (whale icon removed).
|
- **v0.5.3.0**: Local image check changed (use imageId instead of name) and Gotify-template fixed (whale icon removed).
|
||||||
- **v0.5.2.1**: Rewrite of dependency downloads, jq can be installed with package manager or static binary.
|
- **v0.5.2.1**: Rewrite of dependency downloads, jq can be installed with package manager or static binary.
|
||||||
- **v0.5.1**: DEPENDENCY WARNING: now requires **jq**. + Upstreaming changes from [sudo-kraken/podcheck](https://github.com/sudo-kraken/podcheck)
|
|
||||||
- **v0.5.0**: Rewritten notify logic - all templates are adjusted and should be migrated!
|
|
||||||
- Copy the custom settings from your current template to the new version of the same template.
|
|
||||||
- Look into, copy and customize the `urls.list` file if that's of interest.
|
|
||||||
- Other changes:
|
|
||||||
- Added Discord notify template.
|
|
||||||
- Verbosity changed of `regctl`.
|
|
||||||
- **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)
|
|
||||||
___
|
___
|
||||||
|
|
||||||
|
|
||||||
@@ -83,6 +85,7 @@ ___
|
|||||||
## :nut_and_bolt: Dependencies
|
## :nut_and_bolt: Dependencies
|
||||||
- Running docker (duh) and compose, either standalone or plugin. (see [Podman fork](https://github.com/sudo-kraken/podcheck)
|
- 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
|
- Bash shell or compatible shell of at least v4.3
|
||||||
|
- POSIX `xargs`, usually default but can be installed with the `findutils` package - to enable async.
|
||||||
- [jq](https://github.com/jqlang/jq)
|
- [jq](https://github.com/jqlang/jq)
|
||||||
- User will be prompted to install with package manager or download static binary.
|
- User will be prompted to install with package manager or download static binary.
|
||||||
- [regclient/regctl](https://github.com/regclient/regclient) (Licensed under [Apache-2.0 License](http://www.apache.org/licenses/LICENSE-2.0))
|
- [regclient/regctl](https://github.com/regclient/regclient) (Licensed under [Apache-2.0 License](http://www.apache.org/licenses/LICENSE-2.0))
|
||||||
@@ -91,6 +94,7 @@ ___
|
|||||||
|
|
||||||
## :tent: Install Instructions
|
## :tent: Install Instructions
|
||||||
Download the script to a directory in **PATH**, I'd suggest using `~/.local/bin` as that's usually in **PATH**.
|
Download the script to a directory in **PATH**, I'd suggest using `~/.local/bin` as that's usually in **PATH**.
|
||||||
|
For OSX/macOS preferably use `/usr/local/bin`.
|
||||||
```sh
|
```sh
|
||||||
# basic example with curl:
|
# basic example with curl:
|
||||||
curl -L https://raw.githubusercontent.com/mag37/dockcheck/main/dockcheck.sh -o ~/.local/bin/dockcheck.sh
|
curl -L https://raw.githubusercontent.com/mag37/dockcheck/main/dockcheck.sh -o ~/.local/bin/dockcheck.sh
|
||||||
@@ -98,6 +102,9 @@ chmod +x ~/.local/bin/dockcheck.sh
|
|||||||
|
|
||||||
# or oneliner with wget:
|
# 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
|
wget -O ~/.local/bin/dockcheck.sh "https://raw.githubusercontent.com/mag37/dockcheck/main/dockcheck.sh" && chmod +x ~/.local/bin/dockcheck.sh
|
||||||
|
|
||||||
|
# OSX or macOS version with curl:
|
||||||
|
curl -L https://raw.githubusercontent.com/mag37/dockcheck/main/dockcheck.sh -o /usr/local/bin/dockcheck.sh && chmod +x /usr/local/bin/dockcheck.sh
|
||||||
```
|
```
|
||||||
Then call the script anywhere with just `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.
|
Add preferred `notify.sh`-template to the same directory - this will not be touched by the scripts self-update function.
|
||||||
@@ -106,6 +113,7 @@ Add preferred `notify.sh`-template to the same directory - this will not be touc
|
|||||||
## :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!
|
||||||
|
Will also send a notification when `dockcheck.sh` itself has an update.
|
||||||
|
|
||||||
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)
|
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:**
|
||||||
@@ -138,6 +146,11 @@ nginx -> https://github.com/docker-library/official-images/blob/master/library
|
|||||||
```
|
```
|
||||||
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.
|
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.
|
||||||
|
|
||||||
|
## :fast_forward: Asyncronous update checks with **xargs**; `-x N` option. (default=1)
|
||||||
|
Pass `-x N` where N is number of subprocesses allowed, experiment in your environment to find a suitable max!
|
||||||
|
Change the default value by editing the `MaxAsync=N` variable in `dockcheck.sh`. To disable the subprocess function set `MaxAsync=0`.
|
||||||
|
|
||||||
|
|
||||||
## :chart_with_upwards_trend: Prometheus and node_exporter
|
## :chart_with_upwards_trend: Prometheus and node_exporter
|
||||||
Dockcheck can be used together with [Prometheus](https://github.com/prometheus/prometheus) and [node_exporter](https://github.com/prometheus/node_exporter) to export metrics via the file collector, scheduled with cron or likely.
|
Dockcheck can be used together with [Prometheus](https://github.com/prometheus/prometheus) and [node_exporter](https://github.com/prometheus/node_exporter) to export metrics via the file collector, scheduled with cron or likely.
|
||||||
This is done with the `-c` option, like this:
|
This is done with the `-c` option, like this:
|
||||||
@@ -179,7 +192,15 @@ 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`).
|
||||||
|
|
||||||
## :guardsman: Function to auth with docker hub before running
|
## :whale: Docker Hub pull limit :chart_with_downwards_trend: not an issue for checks but for actual pulls
|
||||||
|
Due to recent changes in [Docker Hub usage and limits](https://docs.docker.com/docker-hub/usage/)
|
||||||
|
>Unauthenticated users: 10 pulls/hour
|
||||||
|
>Authenticated users with a free account: 100 pulls/hour
|
||||||
|
|
||||||
|
This is not an issue for registry checks. But if you have a large stack and pull more than 10 updates at once consider updating more often or to create a free account.
|
||||||
|
You could use/modify the login-wrapper function in the example below to automate the login prior to running `dockcheck.sh`.
|
||||||
|
|
||||||
|
### :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 {
|
||||||
|
|||||||
144
dockcheck.sh
144
dockcheck.sh
@@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
VERSION="v0.5.4.0"
|
VERSION="v0.5.7.0"
|
||||||
### ChangeNotes: Added support for a Prometheus+node_exporter metric collection through a file collector.
|
### ChangeNotes: Rewritten templates - now with a function to notify when theres a new Dockcheck release.
|
||||||
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,6 +13,10 @@ 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")"
|
||||||
|
|
||||||
|
# User customizable defaults
|
||||||
|
MaxAsync=1
|
||||||
|
Timeout=10
|
||||||
|
|
||||||
# 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 +38,7 @@ 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 "-x N Set max asynchronous subprocesses, 1 default, 0 to disable, 32+ tested."
|
||||||
echo
|
echo
|
||||||
echo "Project source: $Github"
|
echo "Project source: $Github"
|
||||||
}
|
}
|
||||||
@@ -46,9 +51,8 @@ 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 "aynpfrhlisvmc:e:d:t:" options; do
|
while getopts "aynpfrhlisvmc:e:d:t:x:" options; do
|
||||||
case "${options}" in
|
case "${options}" in
|
||||||
a|y) AutoUp="yes" ;;
|
a|y) AutoUp="yes" ;;
|
||||||
c) CollectorTextFileDirectory="${OPTARG}"
|
c) CollectorTextFileDirectory="${OPTARG}"
|
||||||
@@ -64,6 +68,7 @@ while getopts "aynpfrhlisvmc:e:d:t:" options; do
|
|||||||
s) Stopped="-a" ;;
|
s) Stopped="-a" ;;
|
||||||
t) Timeout="${OPTARG}" ;;
|
t) Timeout="${OPTARG}" ;;
|
||||||
v) printf "%s\n" "$VERSION" ; exit 0 ;;
|
v) printf "%s\n" "$VERSION" ; exit 0 ;;
|
||||||
|
x) MaxAsync=${OPTARG} ;;
|
||||||
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 ;;
|
||||||
h|*) Help ; exit 2 ;;
|
h|*) Help ; exit 2 ;;
|
||||||
@@ -131,7 +136,8 @@ choosecontainers() {
|
|||||||
|
|
||||||
datecheck() {
|
datecheck() {
|
||||||
ImageDate=$($regbin -v error 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 ))
|
ImageEpoch=$(date -d "$ImageDate" +%s 2>/dev/null) || ImageEpoch=$(date -f "%Y-%m-%d" -j "$ImageDate" +%s)
|
||||||
|
ImageAge=$(( ( $(date +%s) - $ImageEpoch )/86400 ))
|
||||||
if [ "$ImageAge" -gt "$DaysOld" ] ; then
|
if [ "$ImageAge" -gt "$DaysOld" ] ; then
|
||||||
return 0
|
return 0
|
||||||
else
|
else
|
||||||
@@ -168,6 +174,8 @@ if [[ "$VERSION" != "$LatestRelease" ]] ; then
|
|||||||
if [[ -z "$AutoUp" ]] ; then
|
if [[ -z "$AutoUp" ]] ; then
|
||||||
read -r -p "Would you like to update? y/[n]: " SelfUpdate
|
read -r -p "Would you like to update? y/[n]: " SelfUpdate
|
||||||
[[ "$SelfUpdate" =~ [yY] ]] && self_update
|
[[ "$SelfUpdate" =~ [yY] ]] && self_update
|
||||||
|
else
|
||||||
|
[[ -n "$Notify" ]] && { [[ $(type -t dockcheck_notification) == function ]] && dockcheck_notification "$VERSION" "$LatestRelease" "$LatestChanges" || printf "Could not source notification function.\n" ; }
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -180,7 +188,7 @@ IFS=',' read -r -a Excludes <<< "$Exclude" ; unset IFS
|
|||||||
binary_downloader() {
|
binary_downloader() {
|
||||||
BinaryName="$1"
|
BinaryName="$1"
|
||||||
BinaryUrl="$2"
|
BinaryUrl="$2"
|
||||||
case "$(uname --machine)" in
|
case "$(uname -m)" in
|
||||||
x86_64|amd64) architecture="amd64" ;;
|
x86_64|amd64) architecture="amd64" ;;
|
||||||
arm64|aarch64) architecture="arm64";;
|
arm64|aarch64) architecture="arm64";;
|
||||||
*) printf "\n%bArchitecture not supported, exiting.%b\n" "$c_red" "$c_reset" ; exit 1;;
|
*) printf "\n%bArchitecture not supported, exiting.%b\n" "$c_red" "$c_reset" ; exit 1;;
|
||||||
@@ -195,49 +203,49 @@ binary_downloader() {
|
|||||||
|
|
||||||
distro_checker() {
|
distro_checker() {
|
||||||
if [[ -f /etc/arch-release ]] ; then PkgInstaller="pacman -S"
|
if [[ -f /etc/arch-release ]] ; then PkgInstaller="pacman -S"
|
||||||
elif [[ -f /etc/redhat-release ]] ; then PkgInstaller="dnf install"
|
elif [[ -f /etc/redhat-release ]] ; then PkgInstaller="sudo dnf install"
|
||||||
elif [[ -f /etc/SuSE-release ]] ; then PkgInstaller="zypper install"
|
elif [[ -f /etc/SuSE-release ]] ; then PkgInstaller="sudo zypper install"
|
||||||
elif [[ -f /etc/debian_version ]] ; then PkgInstaller="apt-get install"
|
elif [[ -f /etc/debian_version ]] ; then PkgInstaller="sudo apt-get install"
|
||||||
|
elif [[ $(uname -s) == "Darwin" ]] ; then PkgInstaller="brew install"
|
||||||
else PkgInstaller="ERROR" ; printf "\n%bNo distribution could be determined%b, falling back to static binary.\n" "$c_yellow" "$c_reset"
|
else PkgInstaller="ERROR" ; printf "\n%bNo distribution could be determined%b, falling back to static binary.\n" "$c_yellow" "$c_reset"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Dependency check for jq in PATH or directory
|
# Dependency check + installer function
|
||||||
if [[ $(command -v jq) ]]; then jqbin="jq" ;
|
dependency_check() {
|
||||||
elif [[ -f "$ScriptWorkDir/jq" ]]; then jqbin="$ScriptWorkDir/jq" ;
|
AppName="$1"
|
||||||
|
AppVar="$2"
|
||||||
|
AppUrl="$3"
|
||||||
|
if [[ $(command -v $AppName) ]]; then export $AppVar="$AppName" ;
|
||||||
|
elif [[ -f "$ScriptWorkDir/$AppName" ]]; then export $AppVar="$ScriptWorkDir/$AppName" ;
|
||||||
else
|
else
|
||||||
printf "%s\n" "Required dependency 'jq' missing, do you want to install it?"
|
printf "%s\n" "Required dependency '$AppName' missing, do you want to install it?"
|
||||||
read -r -p "y: With packagemanager (sudo). / s: Download static binary. y/s/[n] " GetJq
|
read -r -p "y: With packagemanager (sudo). / s: Download static binary. y/s/[n] " GetBin
|
||||||
GetJq=${GetJq:-no} # set default to no if nothing is given
|
GetBin=${GetBin:-no} # set default to no if nothing is given
|
||||||
if [[ "$GetJq" =~ [yYsS] ]] ; then
|
if [[ "$GetBin" =~ [yYsS] ]] ; then
|
||||||
[[ "$GetJq" =~ [yY] ]] && distro_checker
|
[[ "$GetBin" =~ [yY] ]] && distro_checker
|
||||||
if [[ -n "$PkgInstaller" && "$PkgInstaller" != "ERROR" ]] ; then
|
if [[ -n "$PkgInstaller" && "$PkgInstaller" != "ERROR" ]] ; then
|
||||||
(sudo $PkgInstaller jq) ; PkgExitcode="$?"
|
[[ $(uname -s) == "Darwin" && "$AppName" == "regctl" ]] && AppName="regclient"
|
||||||
[[ "$PkgExitcode" == 0 ]] && jqbin="jq" || printf "\n%bPackagemanager install failed%b, falling back to static binary.\n" "$c_yellow" "$c_reset"
|
($PkgInstaller $AppName) ; PkgExitcode="$?" && AppName="$1"
|
||||||
|
if [[ "$PkgExitcode" == 0 ]] ; then { export $AppVar="$AppName" && printf "\n%b$AppName installed.%b\n" "$c_green" "$c_reset"; }
|
||||||
|
else printf "\n%bPackagemanager install failed%b, falling back to static binary.\n" "$c_yellow" "$c_reset"
|
||||||
fi
|
fi
|
||||||
if [[ "$GetJq" =~ [nN] || "$PkgInstaller" == "ERROR" || "$PkgExitcode" != 0 ]] ; then
|
fi
|
||||||
binary_downloader "jq" "https://github.com/jqlang/jq/releases/latest/download/jq-linux-TEMP"
|
if [[ "$GetBin" =~ [sS] || "$PkgInstaller" == "ERROR" || "$PkgExitcode" != 0 ]] ; then
|
||||||
[[ -f "$ScriptWorkDir/jq" ]] && jqbin="$ScriptWorkDir/jq"
|
binary_downloader "$AppName" "$AppUrl"
|
||||||
|
[[ -f "$ScriptWorkDir/$AppName" ]] && { export $AppVar="$ScriptWorkDir/$1" && printf "\n%b$AppName downloaded.%b\n" "$c_green" "$c_reset"; }
|
||||||
fi
|
fi
|
||||||
else printf "\n%bDependency missing, exiting.%b\n" "$c_red" "$c_reset" ; exit 1 ;
|
else printf "\n%bDependency missing, exiting.%b\n" "$c_red" "$c_reset" ; exit 1 ;
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
# Final check if binary is correct
|
# Final check if binary is correct
|
||||||
$jqbin --version &> /dev/null || { printf "%s\n" "jq is not working - try to remove it and re-download it, exiting."; exit 1; }
|
[[ "$1" == "jq" ]] && VerFlag="--version"
|
||||||
|
[[ "$1" == "regctl" ]] && VerFlag="version"
|
||||||
|
${!AppVar} $VerFlag &> /dev/null || { printf "%s\n" "$AppName is not working - try to remove it and re-download it, exiting."; exit 1; }
|
||||||
|
}
|
||||||
|
|
||||||
# Dependency check for regctl in PATH or directory
|
dependency_check "regctl" "regbin" "https://github.com/regclient/regclient/releases/latest/download/regctl-linux-TEMP"
|
||||||
if [[ $(command -v regctl) ]]; then regbin="regctl" ;
|
dependency_check "jq" "jqbin" "https://github.com/jqlang/jq/releases/latest/download/jq-linux-TEMP"
|
||||||
elif [[ -f "$ScriptWorkDir/regctl" ]]; then regbin="$ScriptWorkDir/regctl" ;
|
|
||||||
else
|
|
||||||
read -r -p "Required dependency 'regctl' missing, do you want it downloaded? y/[n] " GetRegctl
|
|
||||||
if [[ "$GetRegctl" =~ [yY] ]] ; then
|
|
||||||
binary_downloader "regctl" "https://github.com/regclient/regclient/releases/latest/download/regctl-linux-TEMP"
|
|
||||||
[[ -f "$ScriptWorkDir/regctl" ]] && regbin="$ScriptWorkDir/regctl"
|
|
||||||
else printf "\n%bDependency missing, exiting.%b\n" "$c_red" "$c_reset" ; exit 1 ;
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
# 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; }
|
|
||||||
|
|
||||||
# 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" ;
|
||||||
@@ -281,31 +289,70 @@ if [[ $t_out ]]; then
|
|||||||
else t_out=""
|
else t_out=""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check the image-hash of every running container VS the registry
|
check_image() {
|
||||||
for i in $(docker ps $Stopped --filter "name=$SearchName" --format '{{.Names}}') ; do
|
i="$1"
|
||||||
((RegCheckQue+=1))
|
local Excludes=($Excludes_string)
|
||||||
progress_bar "$RegCheckQue" "$ContCount"
|
for e in "${Excludes[@]}" ; do
|
||||||
# Looping every item over the list of excluded names and skipping
|
if [[ "$i" == "$e" ]]; then
|
||||||
for e in "${Excludes[@]}" ; do [[ "$i" == "$e" ]] && continue 2 ; done
|
echo Skip $i
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
local NoUpdates GotUpdates GotErrors
|
||||||
ImageId=$(docker inspect "$i" --format='{{.Image}}')
|
ImageId=$(docker inspect "$i" --format='{{.Image}}')
|
||||||
RepoUrl=$(docker inspect "$i" --format='{{.Config.Image}}')
|
RepoUrl=$(docker inspect "$i" --format='{{.Config.Image}}')
|
||||||
LocalHash=$(docker image inspect "$ImageId" --format '{{.RepoDigests}}')
|
LocalHash=$(docker image inspect "$ImageId" --format '{{.RepoDigests}}')
|
||||||
|
|
||||||
# Checking for errors while setting the variable
|
# Checking for errors while setting the variable
|
||||||
if RegHash=$(${t_out} $regbin -v error 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")
|
echo NoUpdates "$i"
|
||||||
else
|
else
|
||||||
if [[ -n "$DaysOld" ]] && ! datecheck ; then
|
if [[ -n "$DaysOld" ]] && ! datecheck ; then
|
||||||
NoUpdates+=("+$i ${ImageAge}d")
|
echo NoUpdates "+$i ${ImageAge}d"
|
||||||
else
|
else
|
||||||
GotUpdates+=("$i")
|
echo GotUpdates "$i"
|
||||||
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}")
|
echo GotErrors "$i - ${RegHash}"
|
||||||
fi
|
fi
|
||||||
done
|
}
|
||||||
|
|
||||||
|
# Make required functions and variables available to subprocesses
|
||||||
|
export -f check_image datecheck
|
||||||
|
export Excludes_string="${Excludes[@]}" # Can only export scalar variables
|
||||||
|
export t_out regbin RepoUrl DaysOld
|
||||||
|
|
||||||
|
# Check for POSIX xargs with -P option, fallback without async
|
||||||
|
if (echo "test" | xargs -P 2 >/dev/null 2>&1) && [[ "$MaxAsync" != 0 ]]; then
|
||||||
|
XargsAsync="-P $MaxAsync"
|
||||||
|
else
|
||||||
|
XargsAsync=""
|
||||||
|
[[ "$MaxAsync" != 0 ]] && printf "%bMissing POSIX xargs, consider installing 'findutils' for asynchronous lookups.%b\n" "$c_red" "$c_reset"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Asynchronously check the image-hash of every running container VS the registry
|
||||||
|
while read -r line; do
|
||||||
|
((RegCheckQue+=1))
|
||||||
|
progress_bar "$RegCheckQue" "$ContCount"
|
||||||
|
|
||||||
|
Got=${line%% *} # Extracts the first word (NoUpdates, GotUpdates, GotErrors)
|
||||||
|
item=${line#* }
|
||||||
|
|
||||||
|
case "$Got" in
|
||||||
|
NoUpdates) NoUpdates+=("$item") ;;
|
||||||
|
GotUpdates) GotUpdates+=("$item") ;;
|
||||||
|
GotErrors) GotErrors+=("$item") ;;
|
||||||
|
Skip) ;;
|
||||||
|
*) echo "Error! Unexpected output from subprocess: ${line}" ;;
|
||||||
|
esac
|
||||||
|
done < <( \
|
||||||
|
docker ps $Stopped --filter "name=$SearchName" --format '{{.Names}}' | \
|
||||||
|
xargs ${XargsAsync} -I {} bash -c 'check_image "{}"' \
|
||||||
|
)
|
||||||
|
|
||||||
# Sort arrays alphabetically
|
# Sort arrays alphabetically
|
||||||
IFS=$'\n'
|
IFS=$'\n'
|
||||||
@@ -315,7 +362,7 @@ unset IFS
|
|||||||
|
|
||||||
# Run the prometheus exporter function
|
# Run the prometheus exporter function
|
||||||
if [ -n "$CollectorTextFileDirectory" ] ; then
|
if [ -n "$CollectorTextFileDirectory" ] ; then
|
||||||
source "$ScriptWorkDir"/addons/prometheus/prometheus_collector.sh && prometheus_exporter ${#NoUpdates[@]} ${#GotUpdates[@]} ${#GotError[@]}
|
source "$ScriptWorkDir"/addons/prometheus/prometheus_collector.sh && prometheus_exporter ${#NoUpdates[@]} ${#GotUpdates[@]} ${#GotErrors[@]}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Define how many updates are available
|
# Define how many updates are available
|
||||||
@@ -410,3 +457,4 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|
||||||
|
|||||||
@@ -17,10 +17,9 @@ 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() {
|
|
||||||
[ -s "$ScriptWorkDir"/urls.list ] && releasenotes || Updates=("$@")
|
|
||||||
UpdToString=$( printf '%s\\n' "${Updates[@]}" )
|
|
||||||
FromHost=$(hostname)
|
FromHost=$(hostname)
|
||||||
|
|
||||||
|
trigger_notification() {
|
||||||
CfgFile="/usr/syno/etc/synosmtp.conf"
|
CfgFile="/usr/syno/etc/synosmtp.conf"
|
||||||
|
|
||||||
# User variables:
|
# User variables:
|
||||||
@@ -34,15 +33,11 @@ SenderName=$(grep 'smtp_from_name' $CfgFile | sed -n 's/.*"\([^"]*\)".*/\1/p')
|
|||||||
SenderMail=$(grep 'smtp_from_mail' $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')}
|
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
|
$MailPkg $SendMailTo << __EOF
|
||||||
From: "$SenderName" <$SenderMail>
|
From: "$SenderName" <$SenderMail>
|
||||||
date:$(date -R)
|
date:$(date -R)
|
||||||
To: <$SendMailTo>
|
To: <$SendMailTo>
|
||||||
Subject: $SubjectTag Updates available on $FromHost
|
Subject: $SubjectTag $MessageTitle $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
|
||||||
|
|
||||||
@@ -52,3 +47,28 @@ __EOF
|
|||||||
# This ensures DSM's container manager will also see the update
|
# This ensures DSM's container manager will also see the update
|
||||||
/var/packages/ContainerManager/target/tool/image_upgradable_checker
|
/var/packages/ContainerManager/target/tool/image_upgradable_checker
|
||||||
}
|
}
|
||||||
|
|
||||||
|
send_notification() {
|
||||||
|
[ -s "$ScriptWorkDir"/urls.list ] && releasenotes || Updates=("$@")
|
||||||
|
UpdToString=$( printf '%s\\n' "${Updates[@]}" )
|
||||||
|
|
||||||
|
printf "\nSending email notification.\n"
|
||||||
|
|
||||||
|
MessageTitle="Updates available on"
|
||||||
|
# Setting the MessageBody variable here.
|
||||||
|
printf -v MessageBody "🐋 Containers on $FromHost with updates available:\n\n$UpdToString"
|
||||||
|
|
||||||
|
trigger_notification
|
||||||
|
}
|
||||||
|
|
||||||
|
### Rename (eg. disabled_dockcheck_notification), remove or comment out the following function
|
||||||
|
### to not send notifications when dockcheck itself has updates.
|
||||||
|
dockcheck_notification() {
|
||||||
|
printf "\nSending email dockcheck notification.\n"
|
||||||
|
|
||||||
|
MessageTitle="New version of dockcheck available on"
|
||||||
|
# Setting the MessageBody variable here.
|
||||||
|
printf -v MessageBody "Installed version: $1\nLatest version: $2\n\nChangenotes: $3\n"
|
||||||
|
|
||||||
|
trigger_notification
|
||||||
|
}
|
||||||
|
|||||||
@@ -4,18 +4,11 @@
|
|||||||
# Required receiving services must already be set up.
|
# Required receiving services must already be set up.
|
||||||
# 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() {
|
|
||||||
[ -s "$ScriptWorkDir"/urls.list ] && releasenotes || Updates=("$@")
|
|
||||||
UpdToString=$( printf '%s\\n' "${Updates[@]}" )
|
|
||||||
FromHost=$(hostname)
|
FromHost=$(hostname)
|
||||||
|
|
||||||
printf "\nSending Apprise notification\n"
|
trigger_notification() {
|
||||||
|
|
||||||
MessageTitle="$FromHost - updates available."
|
### Modify to fit your setup:
|
||||||
# Setting the MessageBody variable here.
|
|
||||||
printf -v MessageBody "🐋 Containers on $FromHost with updates available:\n$UpdToString"
|
|
||||||
|
|
||||||
# Modify to fit your setup:
|
|
||||||
apprise -vv -t "$MessageTitle" -b "$MessageBody" \
|
apprise -vv -t "$MessageTitle" -b "$MessageBody" \
|
||||||
mailto://myemail:mypass@gmail.com \
|
mailto://myemail:mypass@gmail.com \
|
||||||
mastodons://{token}@{host} \
|
mastodons://{token}@{host} \
|
||||||
@@ -26,5 +19,29 @@ apprise -vv -t "$MessageTitle" -b "$MessageBody" \
|
|||||||
### Uncomment the AppriseURL and the curl-line below:
|
### Uncomment the AppriseURL and the curl-line below:
|
||||||
# AppriseURL="http://apprise.mydomain.tld:1234/notify/apprise"
|
# AppriseURL="http://apprise.mydomain.tld:1234/notify/apprise"
|
||||||
# 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
|
||||||
|
}
|
||||||
|
|
||||||
|
send_notification() {
|
||||||
|
[ -s "$ScriptWorkDir"/urls.list ] && releasenotes || Updates=("$@")
|
||||||
|
UpdToString=$( printf '%s\\n' "${Updates[@]}" )
|
||||||
|
|
||||||
|
printf "\nSending Apprise notification\n"
|
||||||
|
|
||||||
|
MessageTitle="$FromHost - updates available."
|
||||||
|
# Setting the MessageBody variable here.
|
||||||
|
printf -v MessageBody "🐋 Containers on $FromHost with updates available:\n$UpdToString"
|
||||||
|
|
||||||
|
trigger_notification
|
||||||
|
}
|
||||||
|
|
||||||
|
### Rename (eg. disabled_dockcheck_notification), remove or comment out the following function
|
||||||
|
### to not send notifications when dockcheck itself has updates.
|
||||||
|
dockcheck_notification() {
|
||||||
|
printf "\nSending Apprise dockcheck notification\n"
|
||||||
|
|
||||||
|
MessageTitle="$FromHost - New version of dockcheck available."
|
||||||
|
# Setting the MessageBody variable here.
|
||||||
|
printf -v MessageBody "Installed version: $1 \nLatest version: $2 \n\nChangenotes: $3"
|
||||||
|
|
||||||
|
trigger_notification
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,25 +4,32 @@
|
|||||||
# Required receiving services must already be set up.
|
# Required receiving services must already be set up.
|
||||||
# Modify to fit your setup - set DiscordWebhookUrl
|
# Modify to fit your setup - set DiscordWebhookUrl
|
||||||
|
|
||||||
send_notification() {
|
|
||||||
[ -s "$ScriptWorkDir"/urls.list ] && releasenotes || Updates=("$@")
|
|
||||||
UpdToString=$( printf '%s\\n' "${Updates[@]}" )
|
|
||||||
|
|
||||||
echo "$UpdToString"
|
|
||||||
FromHost=$(hostname)
|
FromHost=$(hostname)
|
||||||
|
|
||||||
# platform specific notification code would go here
|
trigger_notification() {
|
||||||
printf "\nSending Discord notification\n"
|
|
||||||
|
|
||||||
# Setting the MessageBody variable here.
|
|
||||||
MessageBody="🐋 Containers on $FromHost with updates available: \n$UpdToString"
|
|
||||||
|
|
||||||
# Modify to fit your setup:
|
# Modify to fit your setup:
|
||||||
DiscordWebhookUrl="PasteYourFullDiscordWebhookURL"
|
DiscordWebhookUrl="PasteYourFullDiscordWebhookURL"
|
||||||
|
|
||||||
MsgBody="{\"username\":\"$FromHost\",\"content\":\"$MessageBody\"}"
|
MsgBody="{\"username\":\"$FromHost\",\"content\":\"$MessageBody\"}"
|
||||||
|
|
||||||
curl -sS -o /dev/null --fail -X POST -H "Content-Type: application/json" -d "$MsgBody" "$DiscordWebhookUrl"
|
curl -sS -o /dev/null --fail -X POST -H "Content-Type: application/json" -d "$MsgBody" "$DiscordWebhookUrl"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
send_notification() {
|
||||||
|
[ -s "$ScriptWorkDir"/urls.list ] && releasenotes || Updates=("$@")
|
||||||
|
UpdToString=$( printf '%s\\n' "${Updates[@]}" )
|
||||||
|
|
||||||
|
printf "\nSending Discord notification\n"
|
||||||
|
# Setting the MessageBody variable here.
|
||||||
|
MessageBody="🐋 Containers on $FromHost with updates available: \n$UpdToString"
|
||||||
|
|
||||||
|
trigger_notification
|
||||||
|
}
|
||||||
|
|
||||||
|
### Rename (eg. disabled_dockcheck_notification), remove or comment out the following function
|
||||||
|
### to not send notifications when dockcheck itself has updates.
|
||||||
|
dockcheck_notification() {
|
||||||
|
printf "\nSending Discord dockcheck notification\n"
|
||||||
|
MessageBody="$FromHost - New version of dockcheck available: \n Installed version: $1 \nLatest version: $2 \n\nChangenotes: $3"
|
||||||
|
|
||||||
|
trigger_notification
|
||||||
|
}
|
||||||
|
|||||||
@@ -3,14 +3,34 @@
|
|||||||
# Copy/rename this file to notify.sh to enable the notification snippet.
|
# Copy/rename this file to notify.sh to enable the notification snippet.
|
||||||
# generic sample, the "Hello World" of notification addons
|
# generic sample, the "Hello World" of notification addons
|
||||||
|
|
||||||
|
FromHost=$(hostname)
|
||||||
|
|
||||||
|
trigger_notification() {
|
||||||
|
# Modify to fit your setup:
|
||||||
|
printf "\n$MessageTitle\n"
|
||||||
|
printf "\n$MessageBody\n"
|
||||||
|
}
|
||||||
|
|
||||||
send_notification() {
|
send_notification() {
|
||||||
[ -s "$ScriptWorkDir"/urls.list ] && releasenotes || Updates=("$@")
|
[ -s "$ScriptWorkDir"/urls.list ] && releasenotes || Updates=("$@")
|
||||||
UpdToString=$( printf '%s\\n' "${Updates[@]}" )
|
UpdToString=$( printf '%s\\n' "${Updates[@]}" )
|
||||||
|
|
||||||
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" "$FromHost"
|
MessageTitle="$FromHost - updates available."
|
||||||
printf "$UpdToString"
|
printf -v MessageBody "🐋 Containers on $FromHost with updates available:\n$UpdToString"
|
||||||
|
|
||||||
|
trigger_notification
|
||||||
|
}
|
||||||
|
|
||||||
|
### Rename (eg. disabled_dockcheck_notification), remove or comment out the following function
|
||||||
|
### to not send notifications when dockcheck itself has updates.
|
||||||
|
dockcheck_notification() {
|
||||||
|
printf "\nGeneric dockcheck notification\n"
|
||||||
|
|
||||||
|
MessageTitle="$FromHost - New version of dockcheck available."
|
||||||
|
# Setting the MessageBody variable here.
|
||||||
|
printf -v MessageBody "Installed version: $1 \nLatest version: $2 \n\nChangenotes: $3"
|
||||||
|
|
||||||
|
trigger_notification
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,18 +4,9 @@
|
|||||||
# Required receiving services must already be set up.
|
# Required receiving services must already be set up.
|
||||||
# Modify to fit your setup - set GotifyUrl and GotifyToken.
|
# Modify to fit your setup - set GotifyUrl and GotifyToken.
|
||||||
|
|
||||||
send_notification() {
|
|
||||||
[ -s "$ScriptWorkDir"/urls.list ] && releasenotes || Updates=("$@")
|
|
||||||
UpdToString=$( printf '%s\\n' "${Updates[@]}" )
|
|
||||||
FromHost=$(hostname)
|
FromHost=$(hostname)
|
||||||
|
|
||||||
# platform specific notification code would go here
|
trigger_notification() {
|
||||||
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:
|
# Modify to fit your setup:
|
||||||
GotifyToken="Your Gotify token here"
|
GotifyToken="Your Gotify token here"
|
||||||
GotifyUrl="https://api.gotify/message?token=${GotifyToken}"
|
GotifyUrl="https://api.gotify/message?token=${GotifyToken}"
|
||||||
@@ -25,5 +16,30 @@ send_notification() {
|
|||||||
-F "message=${MessageBody}" \
|
-F "message=${MessageBody}" \
|
||||||
-F "priority=5" \
|
-F "priority=5" \
|
||||||
-X POST "${GotifyUrl}" 1> /dev/null
|
-X POST "${GotifyUrl}" 1> /dev/null
|
||||||
|
}
|
||||||
|
|
||||||
|
send_notification() {
|
||||||
|
[ -s "$ScriptWorkDir"/urls.list ] && releasenotes || Updates=("$@")
|
||||||
|
UpdToString=$( printf '%s\\n' "${Updates[@]}" )
|
||||||
|
|
||||||
|
# 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"
|
||||||
|
|
||||||
|
trigger_notification
|
||||||
|
}
|
||||||
|
|
||||||
|
### Rename (eg. disabled_dockcheck_notification), remove or comment out the following function
|
||||||
|
### to not send notifications when dockcheck itself has updates.
|
||||||
|
dockcheck_notification() {
|
||||||
|
printf "\nSending Gotify dockcheck notification\n"
|
||||||
|
|
||||||
|
MessageTitle="$FromHost - New version of dockcheck available."
|
||||||
|
# Setting the MessageBody variable here.
|
||||||
|
printf -v MessageBody "Installed version: $1 \nLatest version: $2 \n\nChangenotes: $3"
|
||||||
|
|
||||||
|
trigger_notification
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,17 +4,9 @@
|
|||||||
# Required receiving services must already be set up.
|
# Required receiving services must already be set up.
|
||||||
# Modify to fit your setup - set MatrixServer, Room_id and AccessToken
|
# 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)
|
FromHost=$(hostname)
|
||||||
|
|
||||||
# platform specific notification code would go here
|
trigger_notification() {
|
||||||
printf "\nSending Matrix notification\n"
|
|
||||||
|
|
||||||
# Setting the MessageBody variable here.
|
|
||||||
MessageBody="🐋 Containers on $FromHost with updates available: \n$UpdToString"
|
|
||||||
|
|
||||||
# Modify to fit your setup:
|
# Modify to fit your setup:
|
||||||
AccessToken="Your Matrix token here"
|
AccessToken="Your Matrix token here"
|
||||||
Room_id="Enter Room_id here"
|
Room_id="Enter Room_id here"
|
||||||
@@ -22,7 +14,30 @@ send_notification() {
|
|||||||
MsgBody="{\"msgtype\":\"m.text\",\"body\":\"$MessageBody\"}"
|
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
|
# 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"
|
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"
|
||||||
|
}
|
||||||
|
|
||||||
|
send_notification() {
|
||||||
|
[ -s "$ScriptWorkDir"/urls.list ] && releasenotes || Updates=("$@")
|
||||||
|
UpdToString=$( printf '%s\\n' "${Updates[@]}" )
|
||||||
|
|
||||||
|
# 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"
|
||||||
|
|
||||||
|
trigger_notification
|
||||||
|
}
|
||||||
|
|
||||||
|
### Rename (eg. disabled_dockcheck_notification), remove or comment out the following function
|
||||||
|
### to not send notifications when dockcheck itself has updates.
|
||||||
|
dockcheck_notification() {
|
||||||
|
printf "\nSending Matrix dockcheck notification\n"
|
||||||
|
|
||||||
|
MessageTitle="$FromHost - New version of dockcheck available."
|
||||||
|
# Setting the MessageBody variable here.
|
||||||
|
printf -v MessageBody "Installed version: $1 \nLatest version: $2 \n\nChangenotes: $3"
|
||||||
|
|
||||||
|
trigger_notification
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,17 +4,9 @@
|
|||||||
# Setup app and subscription at https://ntfy.sh
|
# Setup app and subscription at https://ntfy.sh
|
||||||
# Use your unique Topic Name in the URL below.
|
# Use your unique Topic Name in the URL below.
|
||||||
|
|
||||||
send_notification() {
|
|
||||||
[ -s "$ScriptWorkDir"/urls.list ] && releasenotes || Updates=("$@")
|
|
||||||
UpdToString=$( printf '%s\\n' "${Updates[@]}" )
|
|
||||||
FromHost=$(hostname)
|
FromHost=$(hostname)
|
||||||
|
|
||||||
printf "\nSending ntfy.sh notification\n"
|
trigger_notification() {
|
||||||
|
|
||||||
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:
|
# Modify to fit your setup:
|
||||||
NtfyUrl="ntfy.sh/YourUniqueTopicName"
|
NtfyUrl="ntfy.sh/YourUniqueTopicName"
|
||||||
|
|
||||||
@@ -22,5 +14,29 @@ curl -sS -o /dev/null --show-error --fail \
|
|||||||
-H "Title: $MessageTitle" \
|
-H "Title: $MessageTitle" \
|
||||||
-d "$MessageBody" \
|
-d "$MessageBody" \
|
||||||
$NtfyUrl
|
$NtfyUrl
|
||||||
|
}
|
||||||
|
|
||||||
|
send_notification() {
|
||||||
|
[ -s "$ScriptWorkDir"/urls.list ] && releasenotes || Updates=("$@")
|
||||||
|
UpdToString=$( printf '%s\\n' "${Updates[@]}" )
|
||||||
|
|
||||||
|
printf "\nSending ntfy.sh notification\n"
|
||||||
|
|
||||||
|
MessageTitle="$FromHost - updates available."
|
||||||
|
# Setting the MessageBody variable here.
|
||||||
|
printf -v MessageBody "🐋 Containers on $FromHost with updates available:\n$UpdToString"
|
||||||
|
|
||||||
|
trigger_notification
|
||||||
|
}
|
||||||
|
|
||||||
|
### Rename (eg. disabled_dockcheck_notification), remove or comment out the following function
|
||||||
|
### to not send notifications when dockcheck itself has updates.
|
||||||
|
dockcheck_notification() {
|
||||||
|
printf "\nSending ntfy.sh dockcheck notification\n"
|
||||||
|
|
||||||
|
MessageTitle="$FromHost - New version of dockcheck available."
|
||||||
|
# Setting the MessageBody variable here.
|
||||||
|
printf -v MessageBody "Installed version: $1 \nLatest version: $2 \n\nChangenotes: $3"
|
||||||
|
|
||||||
|
trigger_notification
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,10 +5,20 @@
|
|||||||
# Requires jq installed and in PATH.
|
# Requires jq installed and in PATH.
|
||||||
# Modify to fit your setup - set Url and Token.
|
# Modify to fit your setup - set Url and Token.
|
||||||
|
|
||||||
|
FromHost=$(hostname)
|
||||||
|
|
||||||
|
trigger_notification() {
|
||||||
|
# Modify to fit your setup:
|
||||||
|
PushUrl="https://api.pushbullet.com/v2/pushes"
|
||||||
|
PushToken="Your Pushbullet token here"
|
||||||
|
|
||||||
|
# Requires jq to process json data
|
||||||
|
jq -n --arg title "$MessageTitle" --arg body "$MessageBody" '{body: $body, title: $title, type: "note"}' | curl -sS -o /dev/null --show-error --fail -X POST -H "Access-Token: $PushToken" -H "Content-type: application/json" $PushUrl -d @-
|
||||||
|
}
|
||||||
|
|
||||||
send_notification() {
|
send_notification() {
|
||||||
[ -s "$ScriptWorkDir"/urls.list ] && releasenotes || Updates=("$@")
|
[ -s "$ScriptWorkDir"/urls.list ] && releasenotes || Updates=("$@")
|
||||||
UpdToString=$( printf '%s\\n' "${Updates[@]}" )
|
UpdToString=$( printf '%s\\n' "${Updates[@]}" )
|
||||||
FromHost=$(hostname)
|
|
||||||
|
|
||||||
# platform specific notification code would go here
|
# platform specific notification code would go here
|
||||||
printf "\nSending pushbullet notification\n"
|
printf "\nSending pushbullet notification\n"
|
||||||
@@ -17,11 +27,17 @@ MessageTitle="$FromHost - updates available."
|
|||||||
# Setting the MessageBody variable here.
|
# Setting the MessageBody variable here.
|
||||||
printf -v MessageBody "🐋 Containers on $FromHost with updates available:\n$UpdToString"
|
printf -v MessageBody "🐋 Containers on $FromHost with updates available:\n$UpdToString"
|
||||||
|
|
||||||
# Modify to fit your setup:
|
trigger_notification
|
||||||
PushUrl="https://api.pushbullet.com/v2/pushes"
|
}
|
||||||
PushToken="Your Pushbullet token here"
|
|
||||||
|
### Rename (eg. disabled_dockcheck_notification), remove or comment out the following function
|
||||||
# Requires jq to process json data
|
### to not send notifications when dockcheck itself has updates.
|
||||||
jq -n --arg title "$MessageTitle" --arg body "$MessageBody" '{body: $body, title: $title, type: "note"}' | curl -sS -o /dev/null --show-error --fail -X POST -H "Access-Token: $PushToken" -H "Content-type: application/json" $PushUrl -d @-
|
dockcheck_notification() {
|
||||||
|
printf "\nSending pushbullet dockcheck notification\n"
|
||||||
|
|
||||||
|
MessageTitle="$FromHost - New version of dockcheck available."
|
||||||
|
# Setting the MessageBody variable here.
|
||||||
|
printf -v MessageBody "Installed version: $1 \nLatest version: $2 \n\nChangenotes: $3"
|
||||||
|
|
||||||
|
trigger_notification
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,18 +5,9 @@
|
|||||||
# Requires jq installed and in PATH.
|
# Requires jq installed and in PATH.
|
||||||
# Modify to fit your setup - set Url and Token.
|
# Modify to fit your setup - set Url and Token.
|
||||||
|
|
||||||
send_notification() {
|
|
||||||
[ -s "$ScriptWorkDir"/urls.list ] && releasenotes || Updates=("$@")
|
|
||||||
UpdToString=$( printf '%s\\n' "${Updates[@]}" )
|
|
||||||
FromHost=$(hostname)
|
FromHost=$(hostname)
|
||||||
|
|
||||||
# platform specific notification code would go here
|
trigger_notification() {
|
||||||
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:
|
# Modify to fit your setup:
|
||||||
PushoverUrl="https://api.pushover.net/1/messages.json"
|
PushoverUrl="https://api.pushover.net/1/messages.json"
|
||||||
PushoverUserKey="Your Pushover User Key Here"
|
PushoverUserKey="Your Pushover User Key Here"
|
||||||
@@ -30,3 +21,29 @@ send_notification() {
|
|||||||
-F "message=$MessageBody" \
|
-F "message=$MessageBody" \
|
||||||
$PushoverUrl
|
$PushoverUrl
|
||||||
}
|
}
|
||||||
|
|
||||||
|
send_notification() {
|
||||||
|
[ -s "$ScriptWorkDir"/urls.list ] && releasenotes || Updates=("$@")
|
||||||
|
UpdToString=$( printf '%s\\n' "${Updates[@]}" )
|
||||||
|
|
||||||
|
# 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"
|
||||||
|
|
||||||
|
trigger_notification
|
||||||
|
}
|
||||||
|
|
||||||
|
### Rename (eg. disabled_dockcheck_notification), remove or comment out the following function
|
||||||
|
### to not send notifications when dockcheck itself has updates.
|
||||||
|
dockcheck_notification() {
|
||||||
|
printf "\nSending pushover dockcheck notification\n"
|
||||||
|
|
||||||
|
MessageTitle="$FromHost - New version of dockcheck available."
|
||||||
|
# Setting the MessageBody variable here.
|
||||||
|
printf -v MessageBody "Installed version: $1 \nLatest version: $2 \n\nChangenotes: $3"
|
||||||
|
|
||||||
|
trigger_notification
|
||||||
|
}
|
||||||
|
|||||||
@@ -16,25 +16,19 @@ 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() {
|
|
||||||
[ -s "$ScriptWorkDir"/urls.list ] && releasenotes || Updates=("$@")
|
|
||||||
UpdToString=$( printf '%s\\n' "${Updates[@]}" )
|
|
||||||
FromHost=$(hostname)
|
FromHost=$(hostname)
|
||||||
|
|
||||||
|
trigger_notification() {
|
||||||
# User variables:
|
# User variables:
|
||||||
SendMailFrom="me@mydomain.tld"
|
SendMailFrom="me@mydomain.tld"
|
||||||
SendMailTo="me@mydomain.tld"
|
SendMailTo="me@mydomain.tld"
|
||||||
SubjectTag="dockcheck"
|
SubjectTag="dockcheck"
|
||||||
|
|
||||||
printf "\nSending email notification.\n"
|
|
||||||
|
|
||||||
printf -v MessageBody "🐋 Containers on $FromHost with updates available:\n\n$UpdToString"
|
|
||||||
|
|
||||||
$MailPkg $SendMailTo << __EOF
|
$MailPkg $SendMailTo << __EOF
|
||||||
From: "$FromHost" <$SendMailFrom>
|
From: "$FromHost" <$SendMailFrom>
|
||||||
date:$(date -R)
|
date:$(date -R)
|
||||||
To: <$SendMailTo>
|
To: <$SendMailTo>
|
||||||
Subject: [$SubjectTag] Updates available on $FromHost
|
Subject: [$SubjectTag] $MessageTitle $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
|
||||||
|
|
||||||
@@ -42,3 +36,28 @@ $MessageBody
|
|||||||
|
|
||||||
__EOF
|
__EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
|
send_notification() {
|
||||||
|
[ -s "$ScriptWorkDir"/urls.list ] && releasenotes || Updates=("$@")
|
||||||
|
UpdToString=$( printf '%s\\n' "${Updates[@]}" )
|
||||||
|
|
||||||
|
printf "\nSending email notification.\n"
|
||||||
|
|
||||||
|
MessageTitle="Updates available on"
|
||||||
|
# Setting the MessageBody variable here.
|
||||||
|
printf -v MessageBody "🐋 Containers on $FromHost with updates available:\n\n$UpdToString"
|
||||||
|
|
||||||
|
trigger_notification
|
||||||
|
}
|
||||||
|
|
||||||
|
### Rename (eg. disabled_dockcheck_notification), remove or comment out the following function
|
||||||
|
### to not send notifications when dockcheck itself has updates.
|
||||||
|
dockcheck_notification() {
|
||||||
|
printf "\nSending email dockcheck notification.\n"
|
||||||
|
|
||||||
|
MessageTitle="New version of dockcheck available on"
|
||||||
|
# Setting the MessageBody variable here.
|
||||||
|
printf -v MessageBody "Installed version: $1 \nLatest version: $2 \n\nChangenotes: $3"
|
||||||
|
|
||||||
|
trigger_notification
|
||||||
|
}
|
||||||
|
|||||||
@@ -4,17 +4,9 @@
|
|||||||
# Required receiving services must already be set up.
|
# Required receiving services must already be set up.
|
||||||
# Modify to fit your setup - set TelegramChatId and TelegramToken.
|
# Modify to fit your setup - set TelegramChatId and TelegramToken.
|
||||||
|
|
||||||
send_notification() {
|
|
||||||
[ -s "$ScriptWorkDir"/urls.list ] && releasenotes || Updates=("$@")
|
|
||||||
UpdToString=$( printf '%s\\n' "${Updates[@]}" )
|
|
||||||
FromHost=$(hostname)
|
FromHost=$(hostname)
|
||||||
|
|
||||||
# platform specific notification code would go here
|
trigger_notification() {
|
||||||
printf "\nSending Telegram notification\n"
|
|
||||||
|
|
||||||
# Setting the MessageBody variable here.
|
|
||||||
MessageBody="🐋 Containers on $FromHost with updates available: \n$UpdToString"
|
|
||||||
|
|
||||||
# Modify to fit your setup:
|
# Modify to fit your setup:
|
||||||
TelegramToken="Your Telegram token here"
|
TelegramToken="Your Telegram token here"
|
||||||
TelegramChatId="Your Telegram ChatId here"
|
TelegramChatId="Your Telegram ChatId here"
|
||||||
@@ -23,5 +15,29 @@ send_notification() {
|
|||||||
TelegramData="{\"chat_id\":\"$TelegramChatId\",\"text\":\"$MessageBody\",\"message_thread_id\":\"$TelegramTopicID\",\"disable_notification\": false}"
|
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"
|
||||||
|
}
|
||||||
|
|
||||||
|
send_notification() {
|
||||||
|
[ -s "$ScriptWorkDir"/urls.list ] && releasenotes || Updates=("$@")
|
||||||
|
UpdToString=$( printf '%s\\n' "${Updates[@]}" )
|
||||||
|
|
||||||
|
# platform specific notification code would go here
|
||||||
|
printf "\nSending Telegram notification\n"
|
||||||
|
|
||||||
|
# Setting the MessageBody variable here.
|
||||||
|
MessageBody="🐋 Containers on $FromHost with updates available: \n$UpdToString"
|
||||||
|
|
||||||
|
trigger_notification
|
||||||
|
}
|
||||||
|
|
||||||
|
### Rename (eg. disabled_dockcheck_notification), remove or comment out the following function
|
||||||
|
### to not send notifications when dockcheck itself has updates.
|
||||||
|
dockcheck_notification() {
|
||||||
|
printf "\nSending Telegram dockcheck notification\n"
|
||||||
|
|
||||||
|
MessageTitle="$FromHost - New version of dockcheck available."
|
||||||
|
# Setting the MessageBody variable here.
|
||||||
|
printf -v MessageBody "$FromHost - New version of dockcheck available.\n\nInstalled version: $1 \nLatest version: $2 \n\nChangenotes: $3"
|
||||||
|
|
||||||
|
trigger_notification
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user