cleaned up some variable names and help-section

This commit is contained in:
mag37 2023-12-23 20:47:23 +01:00
parent e39ea0748f
commit 24438124eb

View File

@ -20,14 +20,14 @@ Help() {
echo "Example: dockcheck.sh -y -d 10 -e nextcloud,heimdall" echo "Example: dockcheck.sh -y -d 10 -e nextcloud,heimdall"
echo echo
echo "Options:" echo "Options:"
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 "-e X Exclude containers, separated by comma."
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 "-h Print this Help."
echo "-m Monochrome mode, no printf color codes."
echo "-n No updates, only checking availability."
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"
echo "-m Monochrome mode, no printf color codes."
echo "-s Include stopped containers in the check. (Logic: docker ps -a)" echo "-s Include stopped containers in the check. (Logic: docker ps -a)"
} }
@ -43,10 +43,10 @@ c_reset="\033[0m"
Stopped="" Stopped=""
while getopts "aynprhsme:d:" options; do while getopts "aynprhsme:d:" options; do
case "${options}" in case "${options}" in
a|y) UpdYes="yes" ;; a|y) AutoUp="yes" ;;
n) UpdYes="no" ;; n) AutoUp="no" ;;
r) DrUp="yes" ;; r) DRunUp="yes" ;;
p) PruneQ="yes" ;; p) AutoPrune="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" ;;
@ -128,7 +128,7 @@ datecheck() {
### 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 "$UpdYes" ]] && self_update_select ; } [[ "$VERSION" != "$LatestRelease" ]] && { printf "New version available! Local: %s - Latest: %s \n Change Notes: %s \n" "$VERSION" "$LatestRelease" "$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"
@ -231,18 +231,18 @@ if [[ -n ${GotErrors[*]} ]] ; then
fi 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 "$UpdYes" ]] && options || printf "%s\n" "${GotUpdates[@]}" [[ -z "$AutoUp" ]] && 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 "$AutoUp" ] ; then
printf "\n%bChoose what containers to update.%b\n" "$c_teal" "$c_reset" printf "\n%bChoose what containers to update.%b\n" "$c_teal" "$c_reset"
choosecontainers choosecontainers
else else
SelectedUpdates=( "${GotUpdates[@]}" ) SelectedUpdates=( "${GotUpdates[@]}" )
fi fi
if [ "$UpdYes" == "${UpdYes#[Nn]}" ] ; then if [ "$AutoUp" == "${AutoUp#[Nn]}" ] ; then
NumberofUpdates="${#SelectedUpdates[@]}" NumberofUpdates="${#SelectedUpdates[@]}"
CurrentQue=0 CurrentQue=0
for i in "${SelectedUpdates[@]}" for i in "${SelectedUpdates[@]}"
@ -256,7 +256,7 @@ if [ -n "$GotUpdates" ] ; then
ContImage=$(docker inspect "$i" --format='{{.Config.Image}}') ContImage=$(docker inspect "$i" --format='{{.Config.Image}}')
### 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 [ "$DrUp" == "yes" ] ; then if [ "$DRunUp" == "yes" ] ; 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
@ -286,8 +286,8 @@ if [ -n "$GotUpdates" ] ; then
fi fi
done done
printf "\n%bAll done!%b\n" "$c_green" "$c_reset" 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 "$AutoPrune" ]] && read -r -p "Would you like to prune dangling images? y/[n]: " AutoPrune
[[ "$PruneQ" =~ [yY] ]] && docker image prune -f [[ "$AutoPrune" =~ [yY] ]] && docker image prune -f
else else
printf "\nNo updates installed, exiting.\n" printf "\nNo updates installed, exiting.\n"
fi fi