rework of the printf's color escape codes
This commit is contained in:
parent
d39badea36
commit
ab30f22343
25
dockcheck.sh
25
dockcheck.sh
@ -30,6 +30,15 @@ Help() {
|
|||||||
echo "-s Include stopped containers in the check. (Logic: docker ps -a)"
|
echo "-s Include stopped containers in the check. (Logic: docker ps -a)"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
### Colors:
|
||||||
|
c_red="\033[0;31m"
|
||||||
|
c_green="\033[0;32m"
|
||||||
|
c_yellow="\033[0;33m"
|
||||||
|
c_blue="\033[0;34m"
|
||||||
|
c_teal="\033[0;36m"
|
||||||
|
c_reset="\033[0m"
|
||||||
|
|
||||||
|
|
||||||
Stopped=""
|
Stopped=""
|
||||||
while getopts "aynprhse:d:" options; do
|
while getopts "aynprhse:d:" options; do
|
||||||
case "${options}" in
|
case "${options}" in
|
||||||
@ -172,7 +181,7 @@ done
|
|||||||
|
|
||||||
### Listing typed exclusions:
|
### Listing typed exclusions:
|
||||||
if [[ -n ${Excludes[*]} ]] ; then
|
if [[ -n ${Excludes[*]} ]] ; then
|
||||||
printf "\n\033[0;34mExcluding these names:\033[0m\n"
|
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
|
||||||
@ -211,22 +220,22 @@ UpdCount="${#GotUpdates[@]}"
|
|||||||
|
|
||||||
### List what containers got updates or not
|
### List what containers got updates or not
|
||||||
if [[ -n ${NoUpdates[*]} ]] ; then
|
if [[ -n ${NoUpdates[*]} ]] ; then
|
||||||
printf "\n\033[0;32mContainers on latest version:\033[0m\n"
|
printf "\n%bContainers on latest version:%b\n" "$c_green" "$c_reset"
|
||||||
printf "%s\n" "${NoUpdates[@]}"
|
printf "%s\n" "${NoUpdates[@]}"
|
||||||
fi
|
fi
|
||||||
if [[ -n ${GotErrors[*]} ]] ; then
|
if [[ -n ${GotErrors[*]} ]] ; then
|
||||||
printf "\n\033[0;31mContainers with errors, wont get updated:\033[0m\n"
|
printf "\n%bContainers with errors, wont get updated:%b\n" "$c_red" "$c_reset"
|
||||||
printf "%s\n" "${GotErrors[@]}"
|
printf "%s\n" "${GotErrors[@]}"
|
||||||
fi
|
fi
|
||||||
if [[ -n ${GotUpdates[*]} ]] ; then
|
if [[ -n ${GotUpdates[*]} ]] ; then
|
||||||
printf "\n\033[0;33mContainers with updates available:\033[0m\n"
|
printf "\n%bContainers with updates available:%b\n" "$c_yellow" "$c_reset"
|
||||||
[[ -z "$UpdYes" ]] && options || printf "%s\n" "${GotUpdates[@]}"
|
[[ -z "$UpdYes" ]] && options || printf "%s\n" "${GotUpdates[@]}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
### Optionally get updates if there's any
|
### Optionally get updates if there's any
|
||||||
if [ -n "$GotUpdates" ] ; then
|
if [ -n "$GotUpdates" ] ; then
|
||||||
if [ -z "$UpdYes" ] ; then
|
if [ -z "$UpdYes" ] ; then
|
||||||
printf "\n\033[0;36mChoose what containers to update.\033[0m\n"
|
printf "\n%bChoose what containers to update.%b\n" "$c_teal" "$c_reset"
|
||||||
choosecontainers
|
choosecontainers
|
||||||
else
|
else
|
||||||
SelectedUpdates=( "${GotUpdates[@]}" )
|
SelectedUpdates=( "${GotUpdates[@]}" )
|
||||||
@ -249,7 +258,7 @@ if [ -n "$GotUpdates" ] ; then
|
|||||||
docker pull "$ContImage"
|
docker pull "$ContImage"
|
||||||
printf "%s\n" "$i got a new image downloaded, rebuild manually with preferred 'docker run'-parameters"
|
printf "%s\n" "$i got a new image downloaded, rebuild manually with preferred 'docker run'-parameters"
|
||||||
else
|
else
|
||||||
printf "\n\033[33;1m%s\033[0m has no compose labels, probably started with docker run - \033[33;1mskipping\033[0m\n\n" "$i"
|
printf "\n%b%s%b has no compose labels, probably started with docker run - %bskipping%b\n\n" "$c_yellow" "$i" "$c_reset" "$c_yellow" "$c_reset"
|
||||||
fi
|
fi
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
@ -261,7 +270,7 @@ if [ -n "$GotUpdates" ] ; then
|
|||||||
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 "$ContPath" || { 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"
|
printf "\n%bNow updating (%s/%s): %b%s%b\n" "$c_teal" "$CurrentQue" "$NumberofUpdates" "$c_blue" "$i" "$c_reset"
|
||||||
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
|
||||||
@ -274,7 +283,7 @@ if [ -n "$GotUpdates" ] ; then
|
|||||||
$DockerBin ${CompleteConfs[@]} up -d "$ContName" # unquoted array to allow split - rework?
|
$DockerBin ${CompleteConfs[@]} up -d "$ContName" # unquoted array to allow split - rework?
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
printf "\033[0;32mAll done!\033[0m\n"
|
printf "\n%bAll done!%b\n" "$c_green" "$c_reset"
|
||||||
[[ -z "$PruneQ" ]] && read -r -p "Would you like to prune dangling images? y/[n]: " PruneQ
|
[[ -z "$PruneQ" ]] && read -r -p "Would you like to prune dangling images? y/[n]: " PruneQ
|
||||||
[[ "$PruneQ" =~ [yY] ]] && docker image prune -f
|
[[ "$PruneQ" =~ [yY] ]] && docker image prune -f
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user