syntax cleanup
This commit is contained in:
parent
78d11d1b37
commit
5ed3b90ca4
24
dockcheck.sh
24
dockcheck.sh
@ -52,7 +52,7 @@ while getopts "aynpfrhlisme:d:" options; do
|
|||||||
p) AutoPrune="yes" ;;
|
p) AutoPrune="yes" ;;
|
||||||
l) OnlyLabel=true ;;
|
l) OnlyLabel=true ;;
|
||||||
f) ForceRestartStacks=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}="" ;;
|
||||||
s) Stopped="-a" ;;
|
s) Stopped="-a" ;;
|
||||||
@ -90,7 +90,7 @@ self_update() {
|
|||||||
exec "$ScriptPath" "${ScriptArgs[@]}" # run the new script with old arguments
|
exec "$ScriptPath" "${ScriptArgs[@]}" # run the new script with old arguments
|
||||||
exit 1 # exit the old instance
|
exit 1 # exit the old instance
|
||||||
else
|
else
|
||||||
cd -
|
cd - || { printf "Path error.\n" ; return ; }
|
||||||
self_update_curl
|
self_update_curl
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@ -123,7 +123,7 @@ choosecontainers() {
|
|||||||
datecheck() {
|
datecheck() {
|
||||||
ImageDate=$($regbin image inspect "$RepoUrl" --format='{{.Created}}' | cut -d" " -f1 )
|
ImageDate=$($regbin image inspect "$RepoUrl" --format='{{.Created}}' | cut -d" " -f1 )
|
||||||
ImageAge=$(( ( $(date +%s) - $(date -d "$ImageDate" +%s) )/86400 ))
|
ImageAge=$(( ( $(date +%s) - $(date -d "$ImageDate" +%s) )/86400 ))
|
||||||
if [ $ImageAge -gt $DaysOld ] ; then
|
if [ "$ImageAge" -gt "$DaysOld" ] ; then
|
||||||
return 0
|
return 0
|
||||||
else
|
else
|
||||||
return 1
|
return 1
|
||||||
@ -133,13 +133,13 @@ datecheck() {
|
|||||||
progress_bar() {
|
progress_bar() {
|
||||||
QueCurrent="$1"
|
QueCurrent="$1"
|
||||||
QueTotal="$2"
|
QueTotal="$2"
|
||||||
((Percent=100*${QueCurrent}/${QueTotal}))
|
((Percent=100*QueCurrent/QueTotal))
|
||||||
((Complete=50*${Percent}/100)) # change first number for width (50)
|
((Complete=50*Percent/100)) # change first number for width (50)
|
||||||
((Left=50-${Complete})) # change first number for width (50)
|
((Left=50-Complete)) # change first number for width (50)
|
||||||
BarComplete=$(printf "%${Complete}s" | tr " " "#")
|
BarComplete=$(printf "%${Complete}s" | tr " " "#")
|
||||||
BarLeft=$(printf "%${Left}s" | tr " " "-")
|
BarLeft=$(printf "%${Left}s" | tr " " "-")
|
||||||
[[ $QueTotal == $QueCurrent ]] || printf "\r[%s%s] %s/%s " $BarComplete $BarLeft $QueCurrent $QueTotal
|
[[ "$QueTotal" == "$QueCurrent" ]] || printf "\r[%s%s] %s/%s " "$BarComplete" "$BarLeft" "$QueCurrent" "$QueTotal"
|
||||||
[[ $QueTotal == $QueCurrent ]] && printf "\r[%b%s%b] %s/%s \n" $c_teal $BarComplete $c_reset $QueCurrent $QueTotal
|
[[ "$QueTotal" == "$QueCurrent" ]] && printf "\r[%b%s%b] %s/%s \n" "$c_teal" "$BarComplete" "$c_reset" "$QueCurrent" "$QueTotal"
|
||||||
}
|
}
|
||||||
|
|
||||||
### Version check & initiate self update
|
### Version check & initiate self update
|
||||||
@ -204,7 +204,7 @@ done
|
|||||||
|
|
||||||
### Listing typed exclusions:
|
### Listing typed exclusions:
|
||||||
if [[ -n ${Excludes[*]} ]] ; then
|
if [[ -n ${Excludes[*]} ]] ; then
|
||||||
printf "\n%bExcluding these names:%b\n" $c_blue $c_reset
|
printf "\n%bExcluding these names:%b\n" "$c_blue" "$c_reset"
|
||||||
printf "%s\n" "${Excludes[@]}"
|
printf "%s\n" "${Excludes[@]}"
|
||||||
printf "\n"
|
printf "\n"
|
||||||
fi
|
fi
|
||||||
@ -216,7 +216,7 @@ RegCheckQue=0
|
|||||||
### 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 $Stopped --filter "name=$SearchName" --format '{{.Names}}') ; do
|
for i in $(docker ps $Stopped --filter "name=$SearchName" --format '{{.Names}}') ; do
|
||||||
((RegCheckQue+=1))
|
((RegCheckQue+=1))
|
||||||
progress_bar $RegCheckQue $DocCount
|
progress_bar "$RegCheckQue" "$DocCount"
|
||||||
### Looping every item over the list of excluded names and skipping:
|
### Looping every item over the list of excluded names and skipping:
|
||||||
for e in "${Excludes[@]}" ; do [[ "$i" == "$e" ]] && continue 2 ; done
|
for e in "${Excludes[@]}" ; do [[ "$i" == "$e" ]] && continue 2 ; done
|
||||||
RepoUrl=$(docker inspect "$i" --format='{{.Config.Image}}')
|
RepoUrl=$(docker inspect "$i" --format='{{.Config.Image}}')
|
||||||
@ -260,7 +260,7 @@ fi
|
|||||||
if [[ -n ${GotUpdates[*]} ]] ; then
|
if [[ -n ${GotUpdates[*]} ]] ; then
|
||||||
printf "\n%bContainers with updates available:%b\n" "$c_yellow" "$c_reset"
|
printf "\n%bContainers with updates available:%b\n" "$c_yellow" "$c_reset"
|
||||||
[[ -z "$AutoUp" ]] && options || printf "%s\n" "${GotUpdates[@]}"
|
[[ -z "$AutoUp" ]] && options || printf "%s\n" "${GotUpdates[@]}"
|
||||||
[[ ! -z "$Notify" ]] && { [[ $(type -t send_notification) == function ]] && send_notification "${GotUpdates[@]}" || printf "Could not source notification function.\n" ; }
|
[[ -n "$Notify" ]] && { [[ $(type -t send_notification) == function ]] && send_notification "${GotUpdates[@]}" || printf "Could not source notification function.\n" ; }
|
||||||
fi
|
fi
|
||||||
|
|
||||||
### Optionally get updates if there's any
|
### Optionally get updates if there's any
|
||||||
@ -313,7 +313,7 @@ if [ -n "$GotUpdates" ] ; then
|
|||||||
### 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
|
||||||
### prepare env-files arguments
|
### prepare env-files arguments
|
||||||
ContEnvs=$(for env in ${ContEnv//,/ } ; do printf -- "--env-file %s " $env; done)
|
ContEnvs=$(for env in ${ContEnv//,/ } ; do printf -- "--env-file %s " "$env"; done)
|
||||||
### Check if the whole stack should be restarted
|
### Check if the whole stack should be restarted
|
||||||
if [[ "$ContRestartStack" == true ]] || [[ "$ForceRestartStacks" == true ]] ; then
|
if [[ "$ContRestartStack" == true ]] || [[ "$ForceRestartStacks" == true ]] ; then
|
||||||
$DockerBin ${CompleteConfs[@]} stop ; $DockerBin ${CompleteConfs[@]} ${ContEnvs} up -d
|
$DockerBin ${CompleteConfs[@]} stop ; $DockerBin ${CompleteConfs[@]} ${ContEnvs} up -d
|
||||||
|
Loading…
Reference in New Issue
Block a user