mirror of
https://github.com/mag37/dockcheck.git
synced 2026-03-02 07:00:34 +01:00
Converted to jq metadata check.
Added jq binary check, fixed consistent command -v syntax.
This commit is contained in:
parent
9937d6bc3f
commit
8da2cbe611
1 changed files with 23 additions and 8 deletions
31
dockcheck.sh
31
dockcheck.sh
|
|
@ -174,7 +174,7 @@ SearchName="$1"
|
||||||
IFS=',' read -r -a Excludes <<< "$Exclude" ; unset IFS
|
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 [[ $(command -v "regctl") ]]; then regbin="regctl" ;
|
if [[ $(command -v regctl) ]]; then regbin="regctl" ;
|
||||||
elif [[ -f "$ScriptWorkDir/regctl" ]]; then regbin="$ScriptWorkDir/regctl" ;
|
elif [[ -f "$ScriptWorkDir/regctl" ]]; then regbin="$ScriptWorkDir/regctl" ;
|
||||||
else
|
else
|
||||||
read -r -p "Required dependency 'regctl' missing, do you want it downloaded? y/[n] " GetDep
|
read -r -p "Required dependency 'regctl' missing, do you want it downloaded? y/[n] " GetDep
|
||||||
|
|
@ -210,6 +210,12 @@ else
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Check for jq binary
|
||||||
|
if [[ ! $(command -v jq) ]] ; then
|
||||||
|
printf "%s\n" "No jq binary, please install jq and try again, exiting."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# Numbered List function
|
# Numbered List function
|
||||||
options() {
|
options() {
|
||||||
num=1
|
num=1
|
||||||
|
|
@ -231,7 +237,7 @@ DocCount=$(docker ps $Stopped --filter "name=$SearchName" --format '{{.Names}}'
|
||||||
RegCheckQue=0
|
RegCheckQue=0
|
||||||
|
|
||||||
# Testing and setting timeout binary
|
# Testing and setting timeout binary
|
||||||
t_out=$(command -v "timeout")
|
t_out=$(command -v timeout)
|
||||||
if [[ $t_out ]]; then
|
if [[ $t_out ]]; then
|
||||||
t_out=$(realpath $t_out 2>/dev/null || readlink -f $t_out)
|
t_out=$(realpath $t_out 2>/dev/null || readlink -f $t_out)
|
||||||
if [[ $t_out =~ "busybox" ]]; then
|
if [[ $t_out =~ "busybox" ]]; then
|
||||||
|
|
@ -306,13 +312,22 @@ if [ -n "$GotUpdates" ] ; then
|
||||||
do
|
do
|
||||||
((CurrentQue+=1))
|
((CurrentQue+=1))
|
||||||
unset CompleteConfs
|
unset CompleteConfs
|
||||||
ContPath=$(docker inspect "$i" --format '{{ index .Config.Labels "com.docker.compose.project.working_dir" }}')
|
# Extract labels and metadata
|
||||||
ContConfigFile=$(docker inspect "$i" --format '{{ index .Config.Labels "com.docker.compose.project.config_files" }}')
|
ContLabels=$(docker inspect "$i" --format '{{json .Config.Labels}}')
|
||||||
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}}')
|
ContImage=$(docker inspect "$i" --format='{{.Config.Image}}')
|
||||||
ContUpdateLabel=$(docker inspect "$i" --format '{{ index .Config.Labels "mag37.dockcheck.update" }}')
|
ContPath=$(jq -r '."com.docker.compose.project.working_dir"' <<< "$ContLabels")
|
||||||
ContRestartStack=$(docker inspect "$i" --format '{{ index .Config.Labels "mag37.dockcheck.restart-stack" }}')
|
[ "$ContPath" == "null" ] && ContPath=""
|
||||||
|
ContConfigFile=$(jq -r '."com.docker.compose.project.config_files"' <<< "$ContLabels")
|
||||||
|
[ "$ContConfigFile" == "null" ] && ContConfigFile=""
|
||||||
|
ContName=$(jq -r '."com.docker.compose.service"' <<< "$ContLabels")
|
||||||
|
[ "$ContName" == "null" ] && ContName=""
|
||||||
|
ContEnv=$(jq -r '."com.docker.compose.project.environment_file"' <<< "$ContLabels")
|
||||||
|
[ "$ContEnv" == "null" ] && ContEnv=""
|
||||||
|
ContUpdateLabel=$(jq -r '."mag37.dockcheck.update"' <<< "$ContLabels")
|
||||||
|
[ "$ContUpdateLabel" == "null" ] && ContUpdateLabel=""
|
||||||
|
ContRestartStack=$(jq -r '."mag37.dockcheck.restart-stack"' <<< "$ContLabels")
|
||||||
|
[ "$ContRestartStack" == "null" ] && ContRestartStack=""
|
||||||
|
|
||||||
# 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
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue