Compare commits

...

26 Commits

Author SHA1 Message Date
mag37
923736c413 version bump+info 2024-08-17 23:00:41 +02:00
mag37
7d825f36c9 Rewrote prune prompt logic, wont prompt if none-interactive flags are used 2024-08-17 22:56:04 +02:00
mag37
29dffbb9b3 Merge pull request #92 from bocan/pre-commit-fixes
style: Add pre-commit checks and code cleanup
2024-08-17 20:39:07 +02:00
Chris Funderburg
588c22afc9 style: Add pre-commit checks and code cleanup
This change adds an optional pre-commit configuration that can be used
to keep the code style clean.  I've also run it across all files and
fixed numerous whitespaces issues.

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

```
pre-commit install
```

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

Feel free to ignore this PR if you're not interested.
2024-08-17 08:50:39 -04:00
mag37
39c69b7648 Update README.md 2024-07-26 07:54:46 +02:00
mag37
35e33b3997 Release info + notification edits. 2024-07-24 20:49:23 +02:00
mag37
a615d759ad Version bump. 2024-07-24 20:46:23 +02:00
mag37
df310c8f50 Merge pull request #90 from mag37/smtp
smtp-changes, deprecate ssmtp, suggest msmtp
2024-07-24 20:41:25 +02:00
mag37
b1448fbb95 smtp-changes, deprecate ssmtp, suggest msmtp 2024-07-24 12:18:23 +02:00
mag37
de67cab998 Merge pull request #88 from yoyoma2/main
zero configuration DSM notification emails
2024-07-02 18:29:53 +02:00
yoyoma2
608c218281 zero configuration DSM notification emails 2024-07-02 11:56:51 -04:00
mag37
3d122f2b86 Update README.md
Notifications updates
2024-06-21 06:25:06 +02:00
mag37
8e280145b9 Merge pull request #87 from cerealconyogurt/home
Create Gotify Template.
2024-06-21 06:16:22 +02:00
cerealconyogurt
da389a04e7 Create notify_gotify.sh
adding Gotify template
2024-06-20 22:05:10 -04:00
mag37
25563d16b6 typo 2024-06-16 23:02:57 +02:00
mag37
4917c97076 Merge pull request #84 from mag37/busyfix
Compat fixes for busyboxs timeout.
2024-06-16 19:39:22 +02:00
mag37
33fc647cb1 compat.changes due to busybox 2024-06-16 19:37:18 +02:00
mag37
abec27c38a potential busybox fix 2024-06-16 07:51:32 +02:00
mag37
082b0f4c7c Merge pull request #82 from mag37/tfix
compat-fixes for timeout and array sorting.
2024-06-12 20:54:30 +02:00
mag37
8521280070 compat-fixes to arrays 2024-06-12 20:50:10 +02:00
mag37
0aac94f27c bugfix non coreutils 2024-06-10 21:09:04 +02:00
mag37
730dba5c3d version bump - bugfix 2024-06-08 19:44:14 +02:00
mag37
f8455d3787 bugfix for non amd64/arm64 arch.
added --foreground to timeout.
2024-06-08 19:43:12 +02:00
mag37
bbe9164554 versionbump 2024-06-03 22:53:10 +02:00
mag37
5d86c79710 Update dockcheck.sh
versionbump for fix
2024-06-03 22:50:07 +02:00
mag37
b0f8431dbf Update dockcheck.sh
timeout default fix
2024-06-03 22:49:14 +02:00
12 changed files with 167 additions and 79 deletions

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

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

View File

@@ -1,7 +1,7 @@
<p align="center"> <p align="center">
<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/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">
@@ -17,7 +17,11 @@
___ ___
## :bell: Changelog ## :bell: Changelog
- **v0.4.2**: Added timeout option to skip container if registry check takes too long (10s default). - **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.
- **v0.4.5**: Bugfixes, compatibility changes to timeout and arrays.
- **v0.4.3**: Added timeout option to skip container if registry check takes too long (10s default).
- **v0.4.1**: Syntax and logic cleanups, bugfixes on multi compose and env-files. - **v0.4.1**: Syntax and logic cleanups, bugfixes on multi compose and env-files.
- **v0.4.0**: Reworked selfupdate (auto git/curl/wget), general syntax cleanup, added -v for version. - **v0.4.0**: Reworked selfupdate (auto git/curl/wget), general syntax cleanup, added -v for version.
- **v0.3.8**: Fixed `--env-file` logic to work with multiple env-files. - **v0.3.8**: Fixed `--env-file` logic to work with multiple env-files.
@@ -69,15 +73,16 @@ 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 proceedes to run `pull` and `up -d` on every container with updates.
After the updates are complete, you'll get prompted if you'd like to prune dangling images. After the updates are complete, you'll get prompted if you'd like to prune dangling images.
___ ___
## :nut_and_bolt: Dependencies ## :nut_and_bolt: Dependencies
- Running docker (duh) and compose, either standalone or plugin. - 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)) - Bash shell or compatible shell of at least v4.3
- User will be prompted to download `regctl` if not in `PATH` or `PWD`. - [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. - regctl requires `amd64/arm64` - see [workaround](#roller_coaster-workaround-for-non-amd64--arm64) if other architecture is used.
## :tent: Install Instructions ## :tent: Install Instructions
@@ -95,22 +100,23 @@ 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!
Use a `notify_X.sh` template file, copy it to `notify.sh`, modify it to your needs! Use a `notify_X.sh` template file, copy it to `notify.sh`, 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. - [Telegram](https://telegram.org/) - Telegram chat API.
- [Matrix-Synapse](https://github.com/element-hq/synapse) - [Matrix](https://matrix.org/), open, secure, decentralised communication. - [Matrix-Synapse](https://github.com/element-hq/synapse) - [Matrix](https://matrix.org/), open, secure, decentralised communication.
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>
## :bookmark: Labels ## :bookmark: Labels
@@ -158,7 +164,7 @@ function dchk {
- Not working well with containers created by Portainer. - Not working well with containers created by Portainer.
## :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.
@@ -171,5 +177,5 @@ ___
## Special Thanks ## Special Thanks
- :bison: [t0rnis](https://github.com/t0rnis) - :bison: [t0rnis](https://github.com/t0rnis)
- :leopard: [Palleri](https://github.com/Palleri) - :leopard: [Palleri](https://github.com/Palleri)

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
VERSION="v0.4.2" VERSION="v0.4.8"
### ChangeNotes: Added timeout option to skip container if registry check takes too long (10s default). ### ChangeNotes: Rewrote prune to not prompt (default no) if -a|-y or -n flags are used. -p will still autoprune.
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"
@@ -16,7 +16,7 @@ LatestChanges="$(curl -s -r 0-200 $RawUrl | sed -n "/ChangeNotes/s/### ChangeNot
### 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"
echo echo
echo "Options:" echo "Options:"
@@ -44,6 +44,7 @@ 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:t:" options; do while getopts "aynpfrhlisvme:d:t:" options; do
case "${options}" in case "${options}" in
@@ -57,7 +58,7 @@ while getopts "aynpfrhlisvme:d:t:" 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:-10}" ;; 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 ;;
@@ -68,12 +69,12 @@ shift "$((OPTIND-1))"
self_update_curl() { self_update_curl() {
cp "$ScriptPath" "$ScriptPath".bak cp "$ScriptPath" "$ScriptPath".bak
if [[ $(builtin type -P curl) ]]; then if [[ $(builtin type -P 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 [[ $(builtin type -P 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
@@ -102,7 +103,7 @@ self_update() {
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
if [[ "$Choice" =~ [qQnN] ]] ; then if [[ "$Choice" =~ [qQnN] ]] ; then
exit 0 exit 0
elif [[ "$Choice" =~ [aAyY] ]] ; then elif [[ "$Choice" =~ [aAyY] ]] ; then
SelectedUpdates=( "${GotUpdates[@]}" ) SelectedUpdates=( "${GotUpdates[@]}" )
@@ -146,9 +147,9 @@ progress_bar() {
} }
### Version check & initiate self update ### Version check & initiate self update
if [[ "$VERSION" != "$LatestRelease" ]] ; then if [[ "$VERSION" != "$LatestRelease" ]] ; then
printf "New version available! %b%s%b ⇒ %b%s%b \n Change Notes: %s \n" "$c_yellow" "$VERSION" "$c_reset" "$c_green" "$LatestRelease" "$c_reset" "$LatestChanges" printf "New version available! %b%s%b ⇒ %b%s%b \n Change Notes: %s \n" "$c_yellow" "$VERSION" "$c_reset" "$c_green" "$LatestRelease" "$c_reset" "$LatestChanges"
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
fi fi
@@ -216,22 +217,33 @@ fi
DocCount=$(docker ps $Stopped --filter "name=$SearchName" --format '{{.Names}}' | wc -l) DocCount=$(docker ps $Stopped --filter "name=$SearchName" --format '{{.Names}}' | wc -l)
RegCheckQue=0 RegCheckQue=0
### Testing and setting timeout binary
t_out=$(type -P "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 ### 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" "$DocCount"
### 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=$(timeout ${Timeout} $regbin image digest --list "$RepoUrl" 2>&1) ; then if RegHash=$(${t_out} $regbin image digest --list "$RepoUrl" 2>&1) ; then
if [[ "$LocalHash" = *"$RegHash"* ]] ; then if [[ "$LocalHash" = *"$RegHash"* ]] ; then
NoUpdates+=("$i") NoUpdates+=("$i")
else else
if [[ -n "$DaysOld" ]] && ! datecheck ; then if [[ -n "$DaysOld" ]] && ! datecheck ; then
NoUpdates+=("+$i ${ImageAge}d") NoUpdates+=("+$i ${ImageAge}d")
else else
GotUpdates+=("$i") GotUpdates+=("$i")
fi fi
fi fi
@@ -242,9 +254,11 @@ for i in $(docker ps $Stopped --filter "name=$SearchName" --format '{{.Names}}')
done done
### Sort arrays alphabetically ### Sort arrays alphabetically
readarray -td '' NoUpdates < <(printf '%s\0' "${NoUpdates[@]}" | sort -z -n) IFS=$'\n'
readarray -td '' GotUpdates < <(printf '%s\0' "${GotUpdates[@]}" | sort -z -n) NoUpdates=($(sort <<<"${NoUpdates[*]}"))
readarray -td '' GotErrors < <(printf '%s\0' "${GotErrors[@]}" | sort -z -n) GotUpdates=($(sort <<<"${GotUpdates[*]}"))
unset IFS
### Define how many updates are available ### Define how many updates are available
UpdCount="${#GotUpdates[@]}" UpdCount="${#GotUpdates[@]}"
@@ -259,13 +273,13 @@ if [[ -n ${GotErrors[*]} ]] ; then
printf "%s\n" "${GotErrors[@]}" printf "%s\n" "${GotErrors[@]}"
printf "%binfo:%b 'unauthorized' often means not found in a public registry.\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"
[[ -z "$AutoUp" ]] && options || printf "%s\n" "${GotUpdates[@]}" [[ -z "$AutoUp" ]] && options || printf "%s\n" "${GotUpdates[@]}"
[[ -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"
@@ -288,14 +302,14 @@ if [ -n "$GotUpdates" ] ; then
ContUpdateLabel=$(docker inspect "$i" --format '{{ index .Config.Labels "mag37.dockcheck.update" }}') ContUpdateLabel=$(docker inspect "$i" --format '{{ index .Config.Labels "mag37.dockcheck.update" }}')
ContRestartStack=$(docker inspect "$i" --format '{{ index .Config.Labels "mag37.dockcheck.restart-stack" }}') ContRestartStack=$(docker inspect "$i" --format '{{ index .Config.Labels "mag37.dockcheck.restart-stack" }}')
### Checking if compose-values are empty - hence started with docker run: ### 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"
printf "%s\n" "$i got a new image downloaded, rebuild manually with preferred 'docker run'-parameters" printf "%s\n" "$i got a new image downloaded, rebuild manually with preferred 'docker run'-parameters"
else else
printf "\n%b%s%b has no compose labels, probably started with docker run - %bskipping%b\n\n" "$c_yellow" "$i" "$c_reset" "$c_yellow" "$c_reset" printf "\n%b%s%b has no compose labels, probably started with docker run - %bskipping%b\n\n" "$c_yellow" "$i" "$c_reset" "$c_yellow" "$c_reset"
fi fi
continue continue
fi fi
### cd to the compose-file directory to account for people who use relative volumes, eg - ${PWD}/data:data ### 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 ; }
@@ -312,15 +326,15 @@ if [ -n "$GotUpdates" ] ; then
### Check if the container got an environment file set and reformat it ### Check if the container got an environment file set and reformat it
if [ -n "$ContEnv" ]; then ContEnvs=$(for env in ${ContEnv//,/ } ; do printf -- "--env-file %s " "$env"; done) ; fi if [ -n "$ContEnv" ]; then ContEnvs=$(for env in ${ContEnv//,/ } ; do printf -- "--env-file %s " "$env"; done) ; fi
### Check if the whole stack should be restarted ### Check if the whole stack should be restarted
if [[ "$ContRestartStack" == true ]] || [[ "$ForceRestartStacks" == true ]] ; then if [[ "$ContRestartStack" == true ]] || [[ "$ForceRestartStacks" == true ]] ; then
$DockerBin ${CompleteConfs} stop ; $DockerBin ${CompleteConfs} ${ContEnvs} up -d $DockerBin ${CompleteConfs} stop ; $DockerBin ${CompleteConfs} ${ContEnvs} up -d
else else
$DockerBin ${CompleteConfs} ${ContEnvs} up -d ${ContName} $DockerBin ${CompleteConfs} ${ContEnvs} up -d ${ContName}
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"
fi fi
@@ -329,4 +343,3 @@ else
fi fi
exit 0 exit 0

View File

@@ -25,13 +25,13 @@ services:
Then browse to the webui. Then browse to the webui.
![](apprise-ex1.png) ![](apprise-ex1.png)
Here you'll click **Configuration Manager**, read the overview and then click on **Configuration**. Here you'll click **Configuration Manager**, read the overview and then click on **Configuration**.
Under **Configuration** you'll craft/paste your notification config. Under **Configuration** you'll craft/paste your notification config.
![](apprise-ex2.png) ![](apprise-ex2.png)
The simplest way is just paste the url's as is (like in the example above). The simplest way is just paste the url's as is (like in the example above).
There are many ways to customize with tags, groups, json and more. Read [caronc/apprise-api](https://github.com/caronc/apprise-api) for more info! There are many ways to customize with tags, groups, json and more. Read [caronc/apprise-api](https://github.com/caronc/apprise-api) for more info!
Look at the [apprise wiki: Notification Services](https://github.com/caronc/apprise/wiki) for more info about how the url syntax for different services works. Look at the [apprise wiki: Notification Services](https://github.com/caronc/apprise/wiki) for more info about how the url syntax for different services works.
You can also use the [caronc/apprise-api](https://github.com/caronc/apprise-api) to host the api as a frontend to an already existing **Apprise**-setup on the host. You can also use the [caronc/apprise-api](https://github.com/caronc/apprise-api) to host the api as a frontend to an already existing **Apprise**-setup on the host.
@@ -40,7 +40,7 @@ You can also use the [caronc/apprise-api](https://github.com/caronc/apprise-api)
### Customize the **notify.sh** file. ### Customize the **notify.sh** file.
After you're done with the setup of the container and tried your notifications, you can copy the `notify_apprise.sh` file to `notify.sh` and start editing it. After you're done with the setup of the container and tried your notifications, you can copy the `notify_apprise.sh` file to `notify.sh` and start editing it.
Comment out/remove the bare metal apprise-command (starting with `apprise -vv -t...`). Comment out/remove the bare metal apprise-command (starting with `apprise -vv -t...`).
Uncomment and edit the `AppriseURL` variable and *curl* line Uncomment and edit the `AppriseURL` variable and *curl* line
It should look something like this when curling the API: It should look something like this when curling the API:
```bash ```bash
@@ -72,11 +72,11 @@ ___
## On host installed **Apprise** ## On host installed **Apprise**
Follow the official guide on [caronc/apprise](https://github.com/caronc/apprise)! Follow the official guide on [caronc/apprise](https://github.com/caronc/apprise)!
### A brief, basic "get started" ### A brief, basic "get started"
- Install **apprise** - Install **apprise**
- python package `pip install apprise` - python package `pip install apprise`
- packaged in EPEL/Fedora `dnf install apprise` - packaged in EPEL/Fedora `dnf install apprise`
- packaged in AUR `[yay/pikaur/paru/other] apprise` - packaged in AUR `[yay/pikaur/paru/other] apprise`
@@ -92,7 +92,7 @@ Then either source the notifications with `-c=/path/to/config/apprise` or store
- Test apprise with a single notification: - Test apprise with a single notification:
- `apprise -vv -t 'test title' -b 'test notification body' 'mailto://myemail:mypass@gmail.com'` - `apprise -vv -t 'test title' -b 'test notification body' 'mailto://myemail:mypass@gmail.com'`
- Set up your notification URL's and test them. - Set up your notification URL's and test them.
- Look at the [apprise wiki: Notification Services](https://github.com/caronc/apprise/wiki) for more info about how the url syntax for different services works. - Look at the [apprise wiki: Notification Services](https://github.com/caronc/apprise/wiki) for more info about how the url syntax for different services works.
### When done, customize the **notify.sh** file. ### When done, customize the **notify.sh** file.
After you're done with the setup of the container and tried your notifications, you can copy the `notify_apprise.sh` file to `notify.sh` and start editing it. After you're done with the setup of the container and tried your notifications, you can copy the `notify_apprise.sh` file to `notify.sh` and start editing it.

View File

@@ -29,7 +29,7 @@ for i in $(docker ps --filter "name=$SearchName" --format '{{.Names}}') ; do
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[*]}")) GotErrors=($(sort <<<"${GotErrors[*]}"))
@@ -44,7 +44,7 @@ if [[ -n ${GotErrors[*]} ]] ; then
printf "\n\033[0;31mContainers with errors, wont get updated:\033[0m\n" printf "\n\033[0;31mContainers with errors, wont get updated:\033[0m\n"
printf "%s\n" "${GotErrors[@]}" printf "%s\n" "${GotErrors[@]}"
fi fi
if [[ -n ${GotUpdates[*]} ]] ; then if [[ -n ${GotUpdates[*]} ]] ; then
printf "\n\033[0;33mContainers with updates available:\033[0m\n" printf "\n\033[0;33mContainers with updates available:\033[0m\n"
printf "%s\n" "${GotUpdates[@]}" printf "%s\n" "${GotUpdates[@]}"
fi fi

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
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" }}') ContPath=$(docker inspect "$i" --format '{{ index .Config.Labels "com.docker.compose.project.working_dir" }}')
[ -z "$ContPath" ] && { "$i has no compose labels - skipping" ; continue ; } [ -z "$ContPath" ] && { "$i has no compose labels - skipping" ; continue ; }
@@ -8,7 +8,7 @@ for i in $(docker ps --filter "name=$SearchName" --format '{{.Names}}') ; do
ContName=$(docker inspect "$i" --format '{{ index .Config.Labels "com.docker.compose.service" }}') 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" }}') 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}}')
if [[ $ContConfigFile = '/'* ]] ; then if [[ $ContConfigFile = '/'* ]] ; then
ComposeFile="$ContConfigFile" ComposeFile="$ContConfigFile"
else else

View File

@@ -1,26 +1,46 @@
### 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 email notifications on Synology DSM # Copy/rename this file to notify.sh to enable the notification snipppet.
# DSM Notification Email has to be configured manually. # 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. # Modify to your liking - changing SendMailTo and Subject and content.
MSMTP=$(which msmtp)
SSMTP=$(which ssmtp)
if [ -n $MSMPT ] ; then
MAIL=$MSMTP
elif [ -n $SSMTP ] && [ -z $MAIL ] ; then
MAIL=$SSMTP
else
echo "No msmtp or ssmtp binary found in PATH: $PATH" ; exit 1
fi
send_notification() { send_notification() {
Updates=("$@") Updates=("$@")
UpdToString=$( printf "%s\n" "${Updates[@]}" ) UpdToString=$( printf "%s\n" "${Updates[@]}" )
FromHost=$(hostname) FromHost=$(hostname)
CfgFile="/usr/syno/etc/synosmtp.conf"
# User variables: # User variables:
# change this to your usual destination for synology DSM notification emails # Automatically sends to your usual destination for synology DSM notification emails.
SendMailTo="me@mydomain.com" # You can also manually override by assigning something else to SendMailTo below.
SubjectTag="diskstation" 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 "\nSending email notification.\n"
ssmtp $SendMailTo << __EOF $MAIL $SendMailTo << __EOF
From: "$FromHost" <$SendMailTo> From: "$SenderName" <$SenderMail>
date:$(date -R) date:$(date -R)
To: <$SendMailTo> To: <$SendMailTo>
Subject: [$SubjectTag] Updates available on $FromHost 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
@@ -28,7 +48,6 @@ The following containers on $FromHost have updates available:
$UpdToString $UpdToString
From $FromHost From $SenderName
__EOF __EOF
} }

View File

@@ -33,5 +33,3 @@ apprise -vv -t "$MessageTitle" -b "$MessageBody" \
# curl -X POST -F "title=$MessageTitle" -F "body=$MessageBody" -F "tags=all" $AppriseURL # curl -X POST -F "title=$MessageTitle" -F "body=$MessageBody" -F "tags=all" $AppriseURL
} }

29
notify_gotify.sh Normal file
View 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() {
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."
MessageBody="Containers on ${FromHost} with updates available: ${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
}

View File

@@ -8,13 +8,13 @@ send_notification() {
Updates=("$@") 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 "\nSending Matrix notification\n" printf "\nSending Matrix notification\n"
# Setting the MessageBody variable here. # Setting the MessageBody variable here.
MessageBody="🐋 Containers on $FromHost with updates available: \n$UpdToString" 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"
@@ -24,5 +24,5 @@ send_notification() {
# 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"
} }

View File

@@ -1,9 +1,21 @@
### 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 $MSMPT ] ; then
MAIL=$MSMTP
elif [ -n $SSMTP ] && [ -z $MAIL ] ; then
MAIL=$SSMTP
else
echo "No msmtp or ssmtp binary found in PATH: $PATH" ; exit 1
fi
send_notification() { send_notification() {
Updates=("$@") Updates=("$@")
UpdToString=$( printf "%s\n" "${Updates[@]}" ) UpdToString=$( printf "%s\n" "${Updates[@]}" )
@@ -16,7 +28,7 @@ SubjectTag="dockcheck"
printf "\nSending email notification.\n" printf "\nSending email notification.\n"
ssmtp $SendMailTo << __EOF $MAIL $SendMailTo << __EOF
From: "$FromHost" <$SendMailFrom> From: "$FromHost" <$SendMailFrom>
date:$(date -R) date:$(date -R)
To: <$SendMailTo> To: <$SendMailTo>

View File

@@ -8,20 +8,20 @@ send_notification() {
Updates=("$@") 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 "\nSending Telegram notification\n" printf "\nSending Telegram notification\n"
# Setting the MessageBody variable here. # Setting the MessageBody variable here.
MessageBody="🐋 Containers on $FromHost with updates available: \n$UpdToString" 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"
TelegramUrl="https://api.telegram.org/bot$TelegramToken" TelegramUrl="https://api.telegram.org/bot$TelegramToken"
TelegramTopicID=12345678 ## Set to 0 if not using specific topic within chat 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}" 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"
} }