Compare commits

...

60 Commits

Author SHA1 Message Date
mag37
9a246b52c4 Merge pull request #39 from mag37/fixing
Fixes `dc_brief.sh` to only exclude exact matches.
2023-07-11 23:33:02 +02:00
mag37
0c33f581f7 Removed old exclude-logic 2023-07-11 23:30:46 +02:00
mag37
b492aacf0f minor edits 2023-07-11 23:11:14 +02:00
mag37
f498138d4b Added recent "exclude containers"-bugfix to the dc_brief.sh 2023-07-11 23:05:34 +02:00
mag37
6a3198eb08 Update dockcheck.sh
patched the self_update logic to respect (and skip interaction) if `-y|a` flag is passed.
2023-06-28 18:03:56 +02:00
mag37
48bfea9fbf Merge pull request #36 from mag37/dev1
Fixes the Exclude-option to only exclude exact matches. 
Formatting: Added counter and info message on current update.
2023-06-27 20:45:12 +02:00
mag37
f2fc5a4d34 Updated: 2.4 info 2023-06-27 19:45:21 +02:00
mag37
f0940e81ec Fixes to the Exclude-option to only exclude exact matches, instead of
wildcarding and excluding by mistake.

Added a counter + message about which container updating.
2023-06-27 19:34:20 +02:00
mag37
a25e648557 Changes to the Exclude-option to only exclude exact matches. 2023-06-21 20:09:31 +02:00
mag37
0e2bdc94ad Update README.md 2023-03-08 12:48:36 +01:00
mag37
19eb57077f selfupd-edit
Changed to if git fails, it'll return to ask for curl/manual.
2023-03-05 21:59:08 +01:00
mag37
1f28c9c144 Update README.md 2023-03-05 21:41:08 +01:00
mag37
0d6da201b7 Update dockcheck.sh
changed url
2023-03-05 21:25:22 +01:00
mag37
ecb1256fbb Merge pull request #32 from mag37/selfupdate
selfupdate func
2023-03-05 21:24:03 +01:00
mag37
afe97c9de5 rdy for main
All in all: 
- Added a self update function, calling either a curl or a git function to update the script.
- Added a dirty changenote-message, will look into improvements later to not curl twice.
2023-03-05 21:19:54 +01:00
mag37
9b6396f6de cleaning
quoting, added env-file check.
2023-03-05 21:13:23 +01:00
mag37
5e58abd8e9 Update dockcheck.sh 2023-03-05 20:45:43 +01:00
mag37
3d7340c91c added changenotes
Addded a dirty way to write out latest changes.
Will try to improve on this later.
2023-03-05 20:44:05 +01:00
mag37
1decbd77b5 cleaning
Just minor cleaning, rearranging
2023-03-05 14:18:57 +01:00
mag37
bcc0c63413 rearranged functions
Moved up choosecontainer-function to the rest of the functions.
Cleaning.
2023-03-05 14:08:56 +01:00
mag37
4a2bc2dded Cleaning
Quoted a variable, reformatted a message
2023-03-05 13:50:28 +01:00
mag37
fd67e0dff1 Update dockcheck.sh 2023-03-04 21:35:47 +01:00
mag37
0fb95ea616 Update dockcheck.sh 2023-03-04 21:28:25 +01:00
mag37
e4cf54c166 Update dockcheck.sh 2023-03-04 21:27:18 +01:00
mag37
e677d8513b Update dockcheck.sh 2023-03-04 21:25:32 +01:00
mag37
d366d4680c Update dockcheck.sh 2023-03-04 20:31:38 +01:00
mag37
76337ee326 Update dockcheck.sh 2023-03-04 20:31:20 +01:00
mag37
6cd90e4597 Update dockcheck.sh 2023-03-04 20:27:13 +01:00
mag37
08ae7a8d23 Update dockcheck.sh 2023-03-04 20:21:31 +01:00
mag37
062c62d071 Update dockcheck.sh 2023-03-04 20:06:41 +01:00
mag37
13549c2018 Update dockcheck.sh 2023-03-04 20:06:08 +01:00
mag37
9094bedfd3 Update dockcheck.sh 2023-03-04 20:05:27 +01:00
mag37
0d4eb4365c Update dockcheck.sh 2023-03-04 20:02:30 +01:00
mag37
ac77470dee Update dockcheck.sh 2023-03-04 20:00:20 +01:00
mag37
ea7a1cd171 Added selfupdating
Added a selfupdating function.
Fixed a forgotten variable (compose-array).
2023-03-04 19:56:26 +01:00
mag37
40910d83b6 Delete example.gif 2023-03-04 09:58:55 +01:00
mag37
d7cc363931 Update README.md 2023-03-04 09:57:31 +01:00
mag37
4f8d6289c2 Update README.md
added donation buttons
added logo by [booYah187](https://github.com/booYah187)
2023-03-04 09:56:16 +01:00
mag37
79febc7356 moved examples.gif 2023-03-04 09:52:46 +01:00
mag37
8acff25f0d added logo
created by https://github.com/booYah187
2023-03-04 09:50:29 +01:00
mag37
2391d6916b Create temp 2023-03-04 09:47:53 +01:00
mag37
e864edc40e Update README.md 2023-03-01 21:02:55 +01:00
mag37
aac065022c urgent
Should not edit on production! Too stressful. Another mistake corrected.
2023-03-01 20:52:17 +01:00
mag37
3e60468d47 urgent
and another fix.
2023-03-01 20:43:06 +01:00
mag37
09c1b769ca urgent fix
too stressed.. typo
2023-03-01 20:39:02 +01:00
mag37
5392c48a57 URGENT
Added info about breakage.
2023-03-01 20:34:29 +01:00
mag37
cc72411de4 troubleshooting
Created for troubleshooting, use if you suspect dockcheck screwed up with errors to easily review your running configs. 
Restart the faulty contianer manually from the compose-file!
2023-03-01 20:27:47 +01:00
mag37
026d5296f8 urgent fix
Screwed up the array with compose-files! It just continued filling up on each loop, should be reset at each loop reset.
Will add info to readme.
2023-03-01 19:52:30 +01:00
mag37
f6e2d50949 +Recent Changes
Added a "Recent Changes" - section up top to make it easier to see what's new with versions.
2023-02-26 23:11:40 +01:00
mag37
432edbfa75 Merge pull request #30 from mag37/testing
multi-compose + exclude
2023-02-26 13:19:37 +01:00
mag37
f233cf3b41 Added info 2023-02-26 13:16:54 +01:00
mag37
7630a95442 Merge pull request #29 from Palleri/patch-2
Added visual "new line" after update check.
2023-02-26 11:58:09 +01:00
Palleri
c7304093bd Added visual "new line" after update check. 2023-02-26 11:24:46 +01:00
mag37
d877a86292 Added exclude-opt
Added options to allow for exclude option to be used
2023-02-26 08:03:15 +01:00
mag37
191d27097d Added exclude-option
Added option to exclude specific containers, full names separated by
comma. `dockcheck.sh -e heimdall,glances`
2023-02-26 07:49:57 +01:00
mag37
4ddb54770e multi-compose fix
Added a hacky fix for multi-compose containers, for example using overrides in
custom directories or multiple override.yml
2023-02-25 10:32:22 +01:00
mag37
c50312dc83 known: profile and multicompose
Added info about known issues related to profiles and multi-compose environments.
2023-02-25 07:56:58 +01:00
mag37
c47c703ce9 added shebang
Forgot about the shebang..
2023-02-23 19:00:35 +01:00
mag37
372e79a12c bugsquash
Added info about pull not respecting image-tags.
2023-02-23 13:18:37 +01:00
mag37
5c2cf75b21 vers.bump - fix breakage
Fixed a breaking error - pulling new images did not use the actual image:tag, but only defaulted to latest.
Hence bumping the version to alert new users to pull the latest.
2023-02-23 13:17:07 +01:00
7 changed files with 175 additions and 59 deletions

View File

@@ -1,5 +1,28 @@
# dockcheck <p align="center">
### A script checking updates for docker images **without pulling** - then selectively auto-update some/all containers. <img src="extras/dockcheck_logo_by_booYah187.png" width="160" title="dockcheck">
</p>
<p align="center">
<img src="https://img.shields.io/badge/coded%20by%20Human-100%25-yellow?style=flat-square" alt="No AI!">
<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>
<img src="https://img.shields.io/github/v/tag/mag37/dockcheck?style=flat-square&label=release" alt="release">
<a href="https://ko-fi.com/mag37"><img src="https://img.shields.io/badge/-Ko--fi-grey?style=flat-square&logo=Ko-fi" alt="Buy me a Coffee"></a>
<a href="https://liberapay.com/user-bin-rob/donate"><img src="https://img.shields.io/badge/-LiberaPay-grey?style=flat-square&logo=liberapay" alt="LiberaPay"></a>
<a href="https://github.com/sponsors/mag37"><img src="https://img.shields.io/badge/-Sponsor-grey?style=flat-square&logo=github" alt="Github Sponsor"></a>
</p>
<h3 align="center">A script checking updates for docker images <b>without pulling</b><br>Then selectively auto-update containers.</h3>
<h4 align="center">With features like excluding specific containers, filter by name, auto-prune dangling images and more.</h4</h3>
### :pushpin: Recent changes:
- **v0.2.4**: Fixed a bug with the Exclude-logic to only exclude exact matches. Added a counter.
- **v0.2.3**: Added a self updating function (curl/git) and a ugly changenote-message for updates.
- **v0.2.2**: Fixed breaking errors with multi-compose, odd breakage and working dir error.
- **v0.2.1**: Added option to exclude a list of containers.
- **v0.2.1**: Added multi-compose support (eg. override).
- **v0.2.0**: Fixed error with container:tag definition.
- **v0.1.9:** Fixed custom env-support.
___ ___
## Dependencies: ## Dependencies:
@@ -9,18 +32,19 @@ User will be prompted to download `regctl` if not in `PATH` or `PWD`
___ ___
![](https://github.com/mag37/dockcheck/blob/main/example.gif) ![](extras/example.gif)
## `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 ng Example: dockcheck.sh -a -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.
-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.
``` ```
@@ -51,26 +75,9 @@ After the updates are complete, you'll get prompted if you'd like to prune dangl
`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.
### :beetle: Squashed Bugs:
- ~~No options for running without updates or auto update.~~
- ~~No filter to check only specific containers.~~
- ~~Faulty registry checkups stopped the updates completely.~~
- ~~No clear checks to skip containers producing errors.~~
- ~~Multi-digest images didn't correctly check with registry, giving false positives on updates.~~
- ~~Not working with filenames other than `docker-compose.yml`~~
- ~~Lists are not alphabetically sorted (due to stacks and other parameters)~~
- ~~Old `docker-compose` binary-check sometimes returned false error~~
- ~~Stacks gets updated as whole, even if only one service is chosen.~~
- ~~Path broken occationally (from inspect) - probably due to old docker-compose binary.~~
- ~~Script breaks if one of the chosen containers are a `docker run` container.~~
- ~~Using relative paths for volumes eg. `${PWD}/data:data` will create the volumes where you stand.~~
- ~~Having no curl/wget leads to corrupt `regctl` without alerting.~~
- ~~Using custom `.env` files does not work.~~
### :hammer: Known issues ### :hammer: Known issues
- ~~No granular choice of what to update (except initial name filter).~~
- No detailed error feedback (just skip + list what's skipped) . - No detailed error feedback (just skip + list what's skipped) .
- Not respecting `--profile` options when re-creating the container.
## `dc_brief.sh` ## `dc_brief.sh`
Just a brief, slimmed down version of the script to only print what containers got updates, no updates or errors. Just a brief, slimmed down version of the script to only print what containers got updates, no updates or errors.
@@ -80,7 +87,7 @@ dockcheck is created and released under the [GNU GPL v3.0](https://www.gnu.org/l
___ ___
## Check out a spinoff brother-project: ## Check out a spinoff brother-project:
### [Palleri/dockcheck-web](https://github.com/Palleri/dockcheck-web) for a WebUI-front! ### [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)

15
dc_brief.sh Normal file → Executable file
View File

@@ -1,8 +1,22 @@
#!/usr/bin/env bash
### If not in PATH, set full path. Else just "regctl" ### If not in PATH, set full path. Else just "regctl"
regbin="regctl" regbin="regctl"
### options to allow exclude:
while getopts "e:" options; do
case "${options}" in
e) Exclude=${OPTARG} ;;
*) exit 0 ;;
esac
done
shift "$((OPTIND-1))"
### Create array of excludes
IFS=',' read -r -a Excludes <<< "$Exclude" ; unset IFS
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
for e in "${Excludes[@]}" ; do [[ "$i" == "$e" ]] && continue 2 ; done
printf ". " printf ". "
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}}')
@@ -34,3 +48,4 @@ 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
printf "\n\n"

View File

@@ -1,37 +1,112 @@
#!/usr/bin/env bash #!/usr/bin/env bash
VERSION="v0.1.9" VERSION="v0.2.4"
### ChangeNotes: Fixes to the Exclude-option to only exclude exact matches. +cleaning
Github="https://github.com/mag37/dockcheck" Github="https://github.com/mag37/dockcheck"
RawUrl="https://raw.githubusercontent.com/mag37/dockcheck/main/dockcheck.sh"
### Variables for self updating
ScriptArgs=( "$@" )
ScriptPath="$(readlink -f "$0")"
ScriptName="$(basename "$ScriptPath")"
ScriptWorkDir="$(dirname "$ScriptPath")"
### Check if there's a new release of the script: ### Check if there's a new release of the script:
LatestRelease="$(curl -s -r 0-50 https://raw.githubusercontent.com/mag37/dockcheck/main/dockcheck.sh | sed -n "/VERSION/s/VERSION=//p" | tr -d '"')" LatestRelease="$(curl -s -r 0-50 $RawUrl | sed -n "/VERSION/s/VERSION=//p" | tr -d '"')"
[ "$VERSION" != "$LatestRelease" ] && printf "New version available! Latest: %s - Local: %s \nGrab it here: %s \n\n" "$LatestRelease" "$VERSION" "$Github" LatestChanges="$(curl -s -r 0-200 $RawUrl | sed -n "/ChangeNotes/s/### ChangeNotes: //p")"
### 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 ng" echo "Example: dockcheck.sh -a -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 "-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"
} }
while getopts "aynprh" options; do while getopts "aynprhe:" options; do
case "${options}" in case "${options}" in
a|y) UpdYes="yes" ;; a|y) UpdYes="yes" ;;
n) UpdYes="no" ;; n) UpdYes="no" ;;
r) DrUp="yes" ;; r) DrUp="yes" ;;
p) PruneQ="yes" ;; p) PruneQ="yes" ;;
e) Exclude=${OPTARG} ;;
h|*) Help ; exit 0 ;; h|*) Help ; exit 0 ;;
esac esac
done done
shift "$((OPTIND-1))" shift "$((OPTIND-1))"
self_update_git() {
cd "$ScriptWorkDir" || { printf "Path error, skipping update.\n" ; return ; }
[[ $(builtin type -P git) ]] || { printf "Git not installed, skipping update.\n" ; return ; }
ScriptUpstream=$(git rev-parse --abbrev-ref --symbolic-full-name "@{upstream}") || { printf "Script not in git directory, choose a different method.\n" ; self_update_select ; return ; }
git fetch
[ -n "$(git diff --name-only "$ScriptUpstream" "$ScriptName")" ] && {
printf "%s\n" "Pulling the latest version."
# git checkout "$ScriptUpstream"
git pull --force
printf "%s\n" "--- starting over with the updated version ---"
cd - || { printf "Path error.\n" ; return ; }
exec "$ScriptPath" "${ScriptArgs[@]}" # run the new script with old arguments
exit 1 # exit the old instance
}
echo "Local is already latest."
}
self_update_curl() {
cp "$ScriptPath" "$ScriptPath".bak
if [[ $(builtin type -P curl) ]]; then
curl -L $RawUrl > "$ScriptPath" ; chmod +x "$ScriptPath"
printf "%s\n" "--- starting over with the updated version ---"
exec "$ScriptPath" "${ScriptArgs[@]}" # run the new script with old arguments
exit 1 # exit the old instance
else
printf "curl not available - download the update manually: %s \n" "$RawUrl"
fi
}
self_update_select() {
read -r -p "Choose update procedure (or do it manually) - git/curl/[no]: " SelfUpQ
if [[ "$SelfUpQ" == "git" ]]; then self_update_git ;
elif [[ "$SelfUpQ" == "curl" ]]; then self_update_curl ;
else printf "Download it manually from the repo: %s \n\n" "$Github"
fi
}
### Choose from list -function:
choosecontainers() {
while [[ -z "$ChoiceClean" ]]; do
read -r -p "Enter number(s) separated by comma, [a] for all - [q] to quit: " Choice
if [[ "$Choice" =~ [qQnN] ]] ; then
exit 0
elif [[ "$Choice" =~ [aAyY] ]] ; then
SelectedUpdates=( "${GotUpdates[@]}" )
ChoiceClean=${Choice//[,.:;]/ }
else
ChoiceClean=${Choice//[,.:;]/ }
for CC in $ChoiceClean ; do
if [[ "$CC" -lt 1 || "$CC" -gt $UpdCount ]] ; then # reset choice if out of bounds
echo "Number not in list: $CC" ; unset ChoiceClean ; break 1
else
SelectedUpdates+=( "${GotUpdates[$CC-1]}" )
fi
done
fi
done
printf "\nUpdating containers:\n"
printf "%s\n" "${SelectedUpdates[@]}"
printf "\n"
}
### 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 ; }
### Set $1 to a variable for name filtering later. ### Set $1 to a variable for name filtering later.
SearchName="$1" SearchName="$1"
### Create array of excludes
IFS=',' read -r -a Excludes <<< "$Exclude" ; unset IFS
### Check if required binary exists in PATH or directory: ### Check if required binary exists in PATH or directory:
if [[ $(builtin type -P "regctl") ]]; then regbin="regctl" ; if [[ $(builtin type -P "regctl") ]]; then regbin="regctl" ;
@@ -60,10 +135,8 @@ fi
$regbin version &> /dev/null || { printf "%s\n" "regctl is not working - try to remove it and re-download it, exiting."; exit 1; } $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 if docker compose version &> /dev/null ; then DockerBin="docker compose" ;
DockerBin="docker compose" elif docker-compose -v &> /dev/null; then DockerBin="docker-compose" ;
elif docker-compose -v &> /dev/null; then
DockerBin="docker-compose"
elif docker -v &> /dev/null; then elif docker -v &> /dev/null; then
printf "%s\n" "No docker compose binary available, using plain docker (Not recommended!)" printf "%s\n" "No docker compose binary available, using plain docker (Not recommended!)"
printf "%s\n" "'docker run' will ONLY update images, not the container itself." printf "%s\n" "'docker run' will ONLY update images, not the container itself."
@@ -81,33 +154,17 @@ for i in "${GotUpdates[@]}"; do
done done
} }
### Choose from list -function: ### Listing typed exclusions:
choosecontainers() { if [[ -n ${Excludes[*]} ]] ; then
while [[ -z "$ChoiceClean" ]]; do printf "\n\033[0;34mExcluding these names:\033[0m\n"
read -r -p "Enter number(s) separated by comma, [a] for all - [q] to quit: " Choice printf "%s\n" "${Excludes[@]}"
if [[ "$Choice" =~ [qQnN] ]] ; then
exit 0
elif [[ "$Choice" =~ [aAyY] ]] ; then
SelectedUpdates=( "${GotUpdates[@]}" )
ChoiceClean=${Choice//[,.:;]/ }
else
ChoiceClean=${Choice//[,.:;]/ }
for CC in $ChoiceClean ; do
if [[ "$CC" -lt 1 || "$CC" -gt $UpdCount ]] ; then # reset choice if out of bounds
echo "Number not in list: $CC" ; unset ChoiceClean ; break 1
else
SelectedUpdates+=( "${GotUpdates[$CC-1]}" )
fi
done
fi
done
printf "\nUpdating containers:\n"
printf "%s\n" "${SelectedUpdates[@]}"
printf "\n" printf "\n"
} 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 --filter "name=$SearchName" --format '{{.Names}}') ; do for i in $(docker ps --filter "name=$SearchName" --format '{{.Names}}') ; do
### Looping every item over the list of excluded names and skipping:
for e in "${Excludes[@]}" ; do [[ "$i" == "$e" ]] && continue 2 ; done
printf ". " printf ". "
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}}')
@@ -151,8 +208,12 @@ if [ -n "$GotUpdates" ] ; then
SelectedUpdates=( "${GotUpdates[@]}" ) SelectedUpdates=( "${GotUpdates[@]}" )
fi fi
if [ "$UpdYes" == "${UpdYes#[Nn]}" ] ; then if [ "$UpdYes" == "${UpdYes#[Nn]}" ] ; then
NumberofUpdates="${#SelectedUpdates[@]}"
CurrentQue=0
for i in "${SelectedUpdates[@]}" for i in "${SelectedUpdates[@]}"
do do
((CurrentQue+=1))
unset CompleteConfs
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" }}')
ContConfigFile=$(docker inspect "$i" --format '{{ index .Config.Labels "com.docker.compose.project.config_files" }}') ContConfigFile=$(docker inspect "$i" --format '{{ index .Config.Labels "com.docker.compose.project.config_files" }}')
ContName=$(docker inspect "$i" --format '{{ index .Config.Labels "com.docker.compose.service" }}') ContName=$(docker inspect "$i" --format '{{ index .Config.Labels "com.docker.compose.service" }}')
@@ -175,13 +236,18 @@ if [ -n "$GotUpdates" ] ; then
ComposeFile="$ContPath/$ContConfigFile" ComposeFile="$ContPath/$ContConfigFile"
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 "$(dirname "${ComposeFile}")" || { echo "Path error - skipping $i" ; continue ; } cd "$ContPath" || { echo "Path error - skipping $i" ; continue ; }
printf "\n\033[0;36mNow updating (%s/%s): \033[0;34m%s\033[0m\n" "$CurrentQue" "$NumberofUpdates" "$i"
docker pull "$ContImage" docker pull "$ContImage"
### Reformat for multi-compose:
IFS=',' read -r -a Confs <<< "$ComposeFile" ; unset IFS
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 -f "$ComposeFile" --env-file "$ContEnv" up -d "$ContName" $DockerBin ${CompleteConfs[@]} --env-file "$ContEnv" up -d "$ContName" # unquoted array to allow split - rework?
else else
$DockerBin -f "$ComposeFile" up -d "$ContName" $DockerBin ${CompleteConfs[@]} up -d "$ContName" # unquoted array to allow split - rework?
fi fi
done done
printf "\033[0;32mAll done!\033[0m\n" printf "\033[0;32mAll done!\033[0m\n"

27
errorCheck.sh Executable file
View File

@@ -0,0 +1,27 @@
#!/usr/bin/env bash
SearchName="$1"
for i in $(docker ps --filter "name=$SearchName" --format '{{.Names}}') ; do
echo "------------ $i ------------"
ContPath=$(docker inspect "$i" --format '{{ index .Config.Labels "com.docker.compose.project.working_dir" }}')
[ -z "$ContPath" ] && { "$i has no compose labels - skipping" ; continue ; }
ContConfigFile=$(docker inspect "$i" --format '{{ index .Config.Labels "com.docker.compose.project.config_files" }}')
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" }}')
ContImage=$(docker inspect "$i" --format='{{.Config.Image}}')
if [[ $ContConfigFile = '/'* ]] ; then
ComposeFile="$ContConfigFile"
else
ComposeFile="$ContPath/$ContConfigFile"
fi
echo -e "Service name:\t\t$ContName"
echo -e "Project working dir:\t$ContPath"
echo -e "Compose files:\t\t$ComposeFile"
echo -e "Environment files:\t$ContEnv"
echo -e "Container image:\t$ContImage"
echo
echo "Mounts:"
docker inspect -f '{{ range .Mounts }}{{ .Source }}:{{ .Destination }}{{ printf "\n" }}{{ end }}' "$i"
echo
done

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

View File

Before

Width:  |  Height:  |  Size: 333 KiB

After

Width:  |  Height:  |  Size: 333 KiB

1
extras/temp Normal file
View File

@@ -0,0 +1 @@
temp