mirror of
https://github.com/mag37/dockcheck.git
synced 2026-04-18 10:27:54 +00:00
Compare commits
16 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1470055329 | ||
|
|
904cd508d1 | ||
|
|
8ee1366505 | ||
|
|
c063b09003 | ||
|
|
ea096b5dbc | ||
|
|
038a30b628 | ||
|
|
24d82d74b3 | ||
|
|
8ecc354663 | ||
|
|
4a2daa9899 | ||
|
|
ae8a232a1a | ||
|
|
abbb924867 | ||
|
|
05d21a707a | ||
|
|
4817d75d94 | ||
|
|
32f6d428d3 | ||
|
|
4a8afde790 | ||
|
|
0887025412 |
48
README.md
48
README.md
@@ -17,19 +17,22 @@
|
|||||||
|
|
||||||
___
|
___
|
||||||
## :bell: Changelog
|
## :bell: Changelog
|
||||||
|
|
||||||
|
- **v0.3.8**: Fixed `--env-file` logic to work with multiple env-files.
|
||||||
|
- **v0.3.7**: Added support for [labels](#bookmark-labels), added the `-f` option (force restart stack).
|
||||||
- **v0.3.6**: Added pushbullet template.
|
- **v0.3.6**: Added pushbullet template.
|
||||||
- **v0.3.5**: Added a simple progress bar for the registry checkup.
|
- **v0.3.5**: Added a simple progress bar for the registry checkup.
|
||||||
- **v0.3.4**: Added ntfy.sh template and error message on registry fail.
|
- **v0.3.4**: Added ntfy.sh template and error message on registry fail.
|
||||||
- **v0.3.3**: Added Apprise template and the option `-i` inform - to send notifications.
|
- **v0.3.3**: Added Apprise template and the option `-i` inform - to send notifications.
|
||||||
- **v0.3.2**: Added a notify function to wrap a notify-script, currently DSM/Ssmtp + template script.
|
- **v0.3.2**: Added a notify function to wrap a notify-script, currently DSM/Ssmtp + template script.
|
||||||
- **v0.3.1**: Addded option `-m` , monochrome mode - no printf color codes.
|
|
||||||
___
|
___
|
||||||
|
|
||||||
## :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))
|
- [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`.
|
- User will be prompted to download `regctl` if not in `PATH` or `PWD`.
|
||||||
- regctl requires `amd64/arm64` - see [workaround](#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.
|
||||||
___
|
___
|
||||||
|
|
||||||
|
|
||||||
@@ -38,22 +41,25 @@ ___
|
|||||||
## :mag_right: `dockcheck.sh`
|
## :mag_right: `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 -y -d 10 -e nextcloud,heimdall
|
Example: dockcheck.sh -y -d 10 -e nextcloud,heimdall
|
||||||
|
|
||||||
Options:
|
Options:"
|
||||||
-a|y Automatic updates, without interaction.
|
-a|y Automatic updates, without interaction.
|
||||||
-d N Only update to new images that are N+ days old. Lists too recent with +prefix and age. 2xSlower.
|
-d N Only update to new images that are N+ days old. Lists too recent with +prefix and age. 2xSlower.
|
||||||
-e X Exclude containers, separated by comma.
|
-e X Exclude containers, separated by comma.
|
||||||
-h Print this Help.
|
-f Force stack restart after update. Caution: restarts once for every updated container within stack.
|
||||||
-i Inform - send a preconfigured notification.
|
-h Print this Help.
|
||||||
-m Monochrome mode, no printf color codes.
|
-i Inform - send a preconfigured notification.
|
||||||
-n No updates, only checking availability.
|
-l Only update if label is set. See readme.
|
||||||
-p Auto-Prune dangling images after update.
|
-m Monochrome mode, no printf color codes.
|
||||||
-r Allow updating images for docker run, wont update the container.
|
-n No updates, only checking availability.
|
||||||
-s Include stopped containers in the check. (Logic: docker ps -a)
|
-p Auto-Prune dangling images after update.
|
||||||
|
-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:
|
||||||
```
|
```
|
||||||
$ ./dockcheck.sh
|
$ ./dockcheck.sh
|
||||||
@@ -90,6 +96,16 @@ Current templates:
|
|||||||
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
|
||||||
|
Optionally add labels to compose-files. Currently these are the usable labels:
|
||||||
|
```
|
||||||
|
labels:
|
||||||
|
mag37.dockcheck.restart-stack: true
|
||||||
|
mag37.dockcheck.update: true
|
||||||
|
```
|
||||||
|
- `mag37.dockcheck.restart-stack: true` works instead of the `-f` option, forcing stop+restart on the whole compose-stack (Caution: Will restart on every updated container within stack).
|
||||||
|
- `mag37.dockcheck.update: true` will when used with the `-l` option only update containers with this label and skip the rest. Will still list updates as usual.
|
||||||
|
|
||||||
## :roller_coaster: Workaround for non **amd64** / **arm64**
|
## :roller_coaster: Workaround for non **amd64** / **arm64**
|
||||||
`regctl` provides binaries for amd64/arm64, to use on other architecture you could try this workaround.
|
`regctl` provides binaries for amd64/arm64, to use on other architecture you could try this workaround.
|
||||||
Run regctl in a container wrapped in a shell script. Copied from [regclient/docs/install.md](https://github.com/regclient/regclient/blob/main/docs/install.md):
|
Run regctl in a container wrapped in a shell script. Copied from [regclient/docs/install.md](https://github.com/regclient/regclient/blob/main/docs/install.md):
|
||||||
@@ -123,7 +139,7 @@ Containers need to be manually stopped, removed and created again to run on the
|
|||||||
## :scroll: License
|
## :scroll: License
|
||||||
dockcheck is created and released under the [GNU GPL v3.0](https://www.gnu.org/licenses/gpl-3.0-standalone.html) license.
|
dockcheck is created and released under the [GNU GPL v3.0](https://www.gnu.org/licenses/gpl-3.0-standalone.html) license.
|
||||||
|
|
||||||
### :floppy_disk: The [story](https://mag37.org/posts/project_dockcheck/) behind it. 1 year in the mirror.
|
### :floppy_disk: The [story](https://mag37.org/posts/project_dockcheck/) behind it. 1 year in retrospect.
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
|
|||||||
32
dockcheck.sh
32
dockcheck.sh
@@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
VERSION="v0.3.6"
|
VERSION="v0.3.8"
|
||||||
### ChangeNotes: Added a Pushbullet template.
|
### ChangeNotes: Fixed --env-file logic to work with multiple env-files.
|
||||||
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"
|
||||||
|
|
||||||
@@ -24,8 +24,10 @@ Help() {
|
|||||||
echo "-a|y Automatic updates, without interaction."
|
echo "-a|y Automatic updates, without interaction."
|
||||||
echo "-d N Only update to new images that are N+ days old. Lists too recent with +prefix and age. 2xSlower."
|
echo "-d N Only update to new images that are N+ days old. Lists too recent with +prefix and age. 2xSlower."
|
||||||
echo "-e X Exclude containers, separated by comma."
|
echo "-e X Exclude containers, separated by comma."
|
||||||
|
echo "-f Force stack restart after update. Caution: restarts once for every updated container within stack."
|
||||||
echo "-h Print this Help."
|
echo "-h Print this Help."
|
||||||
echo "-i Inform - send a preconfigured notification."
|
echo "-i Inform - send a preconfigured notification."
|
||||||
|
echo "-l Only update if label is set. See readme."
|
||||||
echo "-m Monochrome mode, no printf color codes."
|
echo "-m Monochrome mode, no printf color codes."
|
||||||
echo "-n No updates, only checking availability."
|
echo "-n No updates, only checking availability."
|
||||||
echo "-p Auto-Prune dangling images after update."
|
echo "-p Auto-Prune dangling images after update."
|
||||||
@@ -42,12 +44,14 @@ c_teal="\033[0;36m"
|
|||||||
c_reset="\033[0m"
|
c_reset="\033[0m"
|
||||||
|
|
||||||
Stopped=""
|
Stopped=""
|
||||||
while getopts "aynprhisme:d:" options; do
|
while getopts "aynpfrhlisme:d:" options; do
|
||||||
case "${options}" in
|
case "${options}" in
|
||||||
a|y) AutoUp="yes" ;;
|
a|y) AutoUp="yes" ;;
|
||||||
n) AutoUp="no" ;;
|
n) AutoUp="no" ;;
|
||||||
r) DRunUp="yes" ;;
|
r) DRunUp="yes" ;;
|
||||||
p) AutoPrune="yes" ;;
|
p) AutoPrune="yes" ;;
|
||||||
|
l) OnlyLabel=true ;;
|
||||||
|
f) ForceRestartStacks=true ;;
|
||||||
i) [ -s $ScriptWorkDir/notify.sh ] && { source $ScriptWorkDir/notify.sh ; Notify="yes" ; } ;;
|
i) [ -s $ScriptWorkDir/notify.sh ] && { source $ScriptWorkDir/notify.sh ; Notify="yes" ; } ;;
|
||||||
e) Exclude=${OPTARG} ;;
|
e) Exclude=${OPTARG} ;;
|
||||||
m) declare c_{red,green,yellow,blue,teal,reset}="" ;;
|
m) declare c_{red,green,yellow,blue,teal,reset}="" ;;
|
||||||
@@ -141,7 +145,7 @@ progress_bar() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
### 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 "$AutoUp" ]] && self_update_select ; }
|
[[ "$VERSION" != "$LatestRelease" ]] && { 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" ; [[ -z "$AutoUp" ]] && self_update_select ; }
|
||||||
|
|
||||||
### Set $1 to a variable for name filtering later.
|
### Set $1 to a variable for name filtering later.
|
||||||
SearchName="$1"
|
SearchName="$1"
|
||||||
@@ -275,6 +279,8 @@ if [ -n "$GotUpdates" ] ; then
|
|||||||
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}}')
|
||||||
|
ContUpdateLabel=$(docker inspect "$i" --format '{{ index .Config.Labels "mag37.dockcheck.update" }}')
|
||||||
|
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
|
||||||
@@ -294,16 +300,28 @@ if [ -n "$GotUpdates" ] ; then
|
|||||||
### 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 ; }
|
||||||
printf "\n%bNow updating (%s/%s): %b%s%b\n" "$c_teal" "$CurrentQue" "$NumberofUpdates" "$c_blue" "$i" "$c_reset"
|
printf "\n%bNow updating (%s/%s): %b%s%b\n" "$c_teal" "$CurrentQue" "$NumberofUpdates" "$c_blue" "$i" "$c_reset"
|
||||||
|
### Checking if Label Only -option is set, and if container got the label
|
||||||
|
[[ "$OnlyLabel" == true ]] && { [[ "$ContUpdateLabel" != true ]] && { echo "No update label, skipping." ; continue ; } }
|
||||||
docker pull "$ContImage"
|
docker pull "$ContImage"
|
||||||
### Reformat for multi-compose:
|
### Reformat for multi-compose:
|
||||||
IFS=',' read -r -a Confs <<< "$ComposeFile" ; unset IFS
|
IFS=',' read -r -a Confs <<< "$ComposeFile" ; unset IFS
|
||||||
for conf in "${Confs[@]}"; do CompleteConfs+="-f $conf " ; done
|
for conf in "${Confs[@]}"; do CompleteConfs+="-f $conf " ; done
|
||||||
|
|
||||||
### Check if the container got an environment file set, use it if so:
|
### Check if the container got an environment file set, use it if so:
|
||||||
if [ -n "$ContEnv" ]; then
|
if [ -n "$ContEnv" ]; then
|
||||||
$DockerBin ${CompleteConfs[@]} --env-file "$ContEnv" up -d "$ContName" # unquoted array to allow split - rework?
|
### prepare env-files arguments
|
||||||
|
ContEnvs=$(for env in ${ContEnv//,/ } ; do printf -- "--env-file %s " $env; done)
|
||||||
|
### Check if the whole stack should be restarted
|
||||||
|
if [[ "$ContRestartStack" == true ]] || [[ "$ForceRestartStacks" == true ]] ; then
|
||||||
|
$DockerBin ${CompleteConfs[@]} stop ; $DockerBin ${CompleteConfs[@]} ${ContEnvs} up -d
|
||||||
|
else
|
||||||
|
$DockerBin ${CompleteConfs[@]} ${ContEnvs} up -d "$ContName" # unquoted array to allow split - rework?
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
$DockerBin ${CompleteConfs[@]} up -d "$ContName" # unquoted array to allow split - rework?
|
if [[ "$ContRestartStack" == true ]] || [[ "$ForceRestartStacks" == true ]] ; then
|
||||||
|
$DockerBin ${CompleteConfs[@]} stop ; $DockerBin ${CompleteConfs[@]} up -d
|
||||||
|
else
|
||||||
|
$DockerBin ${CompleteConfs[@]} up -d "$ContName"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
printf "\n%bAll done!%b\n" "$c_green" "$c_reset"
|
printf "\n%bAll done!%b\n" "$c_green" "$c_reset"
|
||||||
|
|||||||
Reference in New Issue
Block a user