commit
15d3a96b2c
25
README.md
25
README.md
@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
|
|
||||||
### :pushpin: Recent changes:
|
### :pushpin: Recent changes:
|
||||||
|
- **v0.3.0**: Added a flag `-d N` to choose how many days old new images have to be before being pulled and updated.
|
||||||
- **v0.2.6**: regctl check / download logic changed. Now using the scripts directory as primary location.
|
- **v0.2.6**: regctl check / download logic changed. Now using the scripts directory as primary location.
|
||||||
- **v0.2.5**: Added a new option `-s` to include stopped containers in the check for updates.
|
- **v0.2.5**: Added a new option `-s` to include stopped containers in the check for updates.
|
||||||
- **v0.2.4**: Fixed a bug with the Exclude-logic to only exclude exact matches. Added a counter.
|
- **v0.2.4**: Fixed a bug with the Exclude-logic to only exclude exact matches. Added a counter.
|
||||||
@ -39,17 +40,18 @@ ___
|
|||||||
## `dockcheck.sh`
|
## `dockcheck.sh`
|
||||||
```
|
```
|
||||||
$ ./dockcheck.sh -h
|
$ ./dockcheck.sh -h
|
||||||
Syntax: dockcheck.sh [OPTION] [part of name to filter]
|
Syntax: dockcheck.sh [OPTION] [part of name to filter]
|
||||||
Example: dockcheck.sh -a -e nextcloud,heimdall
|
Example: dockcheck.sh -y -d 10 -e nextcloud,heimdall
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
-h Print this Help.
|
-h Print this Help.
|
||||||
-a|y Automatic updates, without interaction.
|
-a|y Automatic updates, without interaction.
|
||||||
-n No updates, only checking availability.
|
-n No updates, only checking availability.
|
||||||
-e Exclude containers, separated by comma.
|
-e X Exclude containers, separated by comma.
|
||||||
-p Auto-Prune dangling images after update.
|
-d N Only update to new images that are N+ days old. Lists too recent with +prefix. 2xSlower.
|
||||||
-r Allow updating images for docker run, wont update the container.
|
-p Auto-Prune dangling images after update.
|
||||||
-s Include stopped containers in the check. (Logic: docker ps -a).
|
-r Allow updating images for docker run, wont update the container.
|
||||||
|
-s Include stopped containers in the check. (Logic: docker ps -a).
|
||||||
```
|
```
|
||||||
|
|
||||||
Basic example:
|
Basic example:
|
||||||
@ -90,8 +92,7 @@ Just a brief, slimmed down version of the script to only print what containers g
|
|||||||
dockcheck is created and released under the [GNU GPL v3.0](https://www.gnu.org/licenses/gpl-3.0-standalone.html) license.
|
dockcheck is created and released under the [GNU GPL v3.0](https://www.gnu.org/licenses/gpl-3.0-standalone.html) license.
|
||||||
___
|
___
|
||||||
|
|
||||||
## Check out a spinoff brother-project:
|
### Check out a spinoff project: [Palleri/DCW](https://github.com/Palleri/DCW) for a WebUI-front with exporters and notifications.
|
||||||
### [Palleri/DCW](https://github.com/Palleri/DCW) for a WebUI-front with exporters and notifications.
|
|
||||||
|
|
||||||
## Special Thanks:
|
## Special Thanks:
|
||||||
- :bison: [t0rnis](https://github.com/t0rnis)
|
- :bison: [t0rnis](https://github.com/t0rnis)
|
||||||
|
36
dockcheck.sh
36
dockcheck.sh
@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
VERSION="v0.2.6"
|
VERSION="v0.3.0"
|
||||||
### ChangeNotes: Logic change on regctl check/download. Will match the scripts workdir.
|
### ChangeNotes: Added feature (-d N) to only update to new images that are N+ days old.
|
||||||
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"
|
||||||
|
|
||||||
@ -17,20 +17,21 @@ 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 -a -e nextcloud,heimdall"
|
echo "Example: dockcheck.sh -y -d 10 -e nextcloud,heimdall"
|
||||||
echo
|
echo
|
||||||
echo "Options:"
|
echo "Options:"
|
||||||
echo "-h Print this Help."
|
echo "-h Print this Help."
|
||||||
echo "-a|y Automatic updates, without interaction."
|
echo "-a|y Automatic updates, without interaction."
|
||||||
echo "-n No updates, only checking availability."
|
echo "-n No updates, only checking availability."
|
||||||
echo "-e Exclude containers, separated by comma."
|
echo "-e X Exclude containers, separated by comma."
|
||||||
|
echo "-d N Only update to new images that are N+ days old. Lists too recent with +prefix and age. 2xSlower."
|
||||||
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)"
|
||||||
}
|
}
|
||||||
|
|
||||||
Stopped=""
|
Stopped=""
|
||||||
while getopts "aynprhse:" options; do
|
while getopts "aynprhse:d:" options; do
|
||||||
case "${options}" in
|
case "${options}" in
|
||||||
a|y) UpdYes="yes" ;;
|
a|y) UpdYes="yes" ;;
|
||||||
n) UpdYes="no" ;;
|
n) UpdYes="no" ;;
|
||||||
@ -38,7 +39,9 @@ while getopts "aynprhse:" options; do
|
|||||||
p) PruneQ="yes" ;;
|
p) PruneQ="yes" ;;
|
||||||
e) Exclude=${OPTARG} ;;
|
e) Exclude=${OPTARG} ;;
|
||||||
s) Stopped="-a" ;;
|
s) Stopped="-a" ;;
|
||||||
h|*) Help ; exit 0 ;;
|
d) DaysOld=${OPTARG}
|
||||||
|
if ! [[ $DaysOld =~ ^[0-9]+$ ]] ; then { printf "Days -d argument given (%s) is not a number.\n" "${DaysOld}" ; exit 2 ; } ; fi ;;
|
||||||
|
h|*) Help ; exit 2 ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
shift "$((OPTIND-1))"
|
shift "$((OPTIND-1))"
|
||||||
@ -102,6 +105,17 @@ choosecontainers() {
|
|||||||
printf "\n"
|
printf "\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
datecheck() {
|
||||||
|
ImageDate=$($regbin image inspect "$RepoUrl" --format='{{.Created}}' | cut -d" " -f1 )
|
||||||
|
ImageAge=$((($(date +%s) - $(date -d "$ImageDate" +%s))/86400))
|
||||||
|
if [ $ImageAge -gt $DaysOld ] ; then
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
### Version check & initiate self update
|
### Version check & initiate self update
|
||||||
[[ "$VERSION" != "$LatestRelease" ]] && { printf "New version available! Local: %s - Latest: %s \n Change Notes: %s \n" "$VERSION" "$LatestRelease" "$LatestChanges" ; [[ -z "$UpdYes" ]] && self_update_select ; }
|
[[ "$VERSION" != "$LatestRelease" ]] && { printf "New version available! Local: %s - Latest: %s \n Change Notes: %s \n" "$VERSION" "$LatestRelease" "$LatestChanges" ; [[ -z "$UpdYes" ]] && self_update_select ; }
|
||||||
|
|
||||||
@ -172,7 +186,15 @@ for i in $(docker ps $Stopped --filter "name=$SearchName" --format '{{.Names}}')
|
|||||||
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>/dev/null) ; then
|
if RegHash=$($regbin image digest --list "$RepoUrl" 2>/dev/null) ; then
|
||||||
if [[ "$LocalHash" = *"$RegHash"* ]] ; then NoUpdates+=("$i"); else GotUpdates+=("$i"); fi
|
if [[ "$LocalHash" = *"$RegHash"* ]] ; then
|
||||||
|
NoUpdates+=("$i")
|
||||||
|
else
|
||||||
|
if [[ -n "$DaysOld" ]] && ! datecheck ; then
|
||||||
|
NoUpdates+=("+$i ${ImageAge}d")
|
||||||
|
else
|
||||||
|
GotUpdates+=("$i")
|
||||||
|
fi
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
GotErrors+=("$i")
|
GotErrors+=("$i")
|
||||||
fi
|
fi
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 333 KiB After Width: | Height: | Size: 404 KiB |
Loading…
Reference in New Issue
Block a user