mirror of
https://github.com/mag37/dockcheck.git
synced 2026-04-18 02:17:46 +00:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
331d2cc5a7 | ||
|
|
35f460ed61 | ||
|
|
aab63901d0 | ||
|
|
5e53fabbf6 | ||
|
|
8b3926fd5d | ||
|
|
049413cf5a |
@@ -17,6 +17,7 @@
|
|||||||
___
|
___
|
||||||
## :bell: Changelog
|
## :bell: Changelog
|
||||||
|
|
||||||
|
- **v0.4.2**: 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.
|
||||||
@@ -47,6 +48,7 @@ Options:"
|
|||||||
-p Auto-Prune dangling images after update.
|
-p Auto-Prune dangling images after update.
|
||||||
-r Allow updating images for docker run, wont update the container.
|
-r Allow updating images for docker run, wont update the container.
|
||||||
-s Include stopped containers in the check. (Logic: docker ps -a).
|
-s Include stopped containers in the check. (Logic: docker ps -a).
|
||||||
|
-t Set a timeout (in seconds) per container for registry checkups, 10 is default.
|
||||||
-v Prints current version.
|
-v Prints current version.
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
12
dockcheck.sh
12
dockcheck.sh
@@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
VERSION="v0.4.1"
|
VERSION="v0.4.2"
|
||||||
### ChangeNotes: Syntax and logic cleanups, bugfixes for multi compose and env-files.
|
### ChangeNotes: Added timeout option to skip container if registry check takes too long (10s default).
|
||||||
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"
|
||||||
|
|
||||||
@@ -32,6 +32,7 @@ Help() {
|
|||||||
echo "-p Auto-Prune dangling images after update."
|
echo "-p Auto-Prune dangling images after update."
|
||||||
echo "-r Allow updating images for docker run, wont update the container."
|
echo "-r Allow updating images for docker run, wont update the container."
|
||||||
echo "-s Include stopped containers in the check. (Logic: docker ps -a)."
|
echo "-s Include stopped containers in the check. (Logic: docker ps -a)."
|
||||||
|
echo "-t Set a timeout (in seconds) per container for registry checkups, 10 is default."
|
||||||
echo "-v Prints current version."
|
echo "-v Prints current version."
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,7 +45,7 @@ c_teal="\033[0;36m"
|
|||||||
c_reset="\033[0m"
|
c_reset="\033[0m"
|
||||||
|
|
||||||
Stopped=""
|
Stopped=""
|
||||||
while getopts "aynpfrhlisvme:d:" options; do
|
while getopts "aynpfrhlisvme:d:t:" options; do
|
||||||
case "${options}" in
|
case "${options}" in
|
||||||
a|y) AutoUp="yes" ;;
|
a|y) AutoUp="yes" ;;
|
||||||
n) AutoUp="no" ;;
|
n) AutoUp="no" ;;
|
||||||
@@ -56,6 +57,7 @@ while getopts "aynpfrhlisvme:d:" options; do
|
|||||||
e) Exclude=${OPTARG} ;;
|
e) Exclude=${OPTARG} ;;
|
||||||
m) declare c_{red,green,yellow,blue,teal,reset}="" ;;
|
m) declare c_{red,green,yellow,blue,teal,reset}="" ;;
|
||||||
s) Stopped="-a" ;;
|
s) Stopped="-a" ;;
|
||||||
|
t) Timeout="${OPTARG:-10}" ;;
|
||||||
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 ;;
|
||||||
@@ -83,7 +85,7 @@ self_update_curl() {
|
|||||||
|
|
||||||
self_update() {
|
self_update() {
|
||||||
cd "$ScriptWorkDir" || { printf "Path error, skipping update.\n" ; return ; }
|
cd "$ScriptWorkDir" || { printf "Path error, skipping update.\n" ; return ; }
|
||||||
if [[ $(builtin type -P git) ]] && [[ "$(git ls-remote --get-url)" =~ .*"mag37/dockcheck".* ]] ; then
|
if [[ $(builtin type -P git) ]] && [[ "$(git ls-remote --get-url 2>/dev/null)" =~ .*"mag37/dockcheck".* ]] ; then
|
||||||
printf "\n%s\n" "Pulling the latest version."
|
printf "\n%s\n" "Pulling the latest version."
|
||||||
git pull --force || { printf "Git error, manually pull/clone.\n" ; return ; }
|
git pull --force || { printf "Git error, manually pull/clone.\n" ; return ; }
|
||||||
printf "\n%s\n" "--- starting over with the updated version ---"
|
printf "\n%s\n" "--- starting over with the updated version ---"
|
||||||
@@ -223,7 +225,7 @@ for i in $(docker ps $Stopped --filter "name=$SearchName" --format '{{.Names}}')
|
|||||||
RepoUrl=$(docker inspect "$i" --format='{{.Config.Image}}')
|
RepoUrl=$(docker inspect "$i" --format='{{.Config.Image}}')
|
||||||
LocalHash=$(docker image inspect "$RepoUrl" --format '{{.RepoDigests}}')
|
LocalHash=$(docker image inspect "$RepoUrl" --format '{{.RepoDigests}}')
|
||||||
### Checking for errors while setting the variable:
|
### Checking for errors while setting the variable:
|
||||||
if RegHash=$($regbin image digest --list "$RepoUrl" 2>&1) ; then
|
if RegHash=$(timeout ${Timeout} $regbin image digest --list "$RepoUrl" 2>&1) ; then
|
||||||
if [[ "$LocalHash" = *"$RegHash"* ]] ; then
|
if [[ "$LocalHash" = *"$RegHash"* ]] ; then
|
||||||
NoUpdates+=("$i")
|
NoUpdates+=("$i")
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -23,6 +23,6 @@ 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 PUT "$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"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user