Streamlining selection.

No need to choose yes-no before choosing contianers, q/n to quit.
Cleaned some wording and order of messages.
This commit is contained in:
mag37
2023-02-07 14:56:18 +01:00
parent 44f9742bde
commit 03a3e49650

View File

@@ -1,5 +1,5 @@
#!/bin/bash #!/bin/bash
VERSION="v0.1.3" VERSION="v0.1.4"
Github="https://github.com/mag37/dockcheck" Github="https://github.com/mag37/dockcheck"
### Check if there's a new release of the script: ### Check if there's a new release of the script:
@@ -74,9 +74,10 @@ done
### Choose from list -function: ### Choose from list -function:
choosecontainers() { choosecontainers() {
while [[ "$ChoiceClean" =~ [A-Za-z] || -z "$ChoiceClean" ]]; do while [[ "$ChoiceClean" =~ [A-Za-z] || -z "$ChoiceClean" ]]; do
printf "What containers do you like to update? \n" read -p "Enter number(s) separated by comma, [q] to quit: " Choice
read -p 'Enter number(s) separated by comma (eg. 1,3,4): ' Choice if [[ "$Choice" =~ [qQnN] ]] ; then
if [ "$Choice" == "0" ] ; then exit 0
elif [ "$Choice" == "0" ] ; then
SelectedUpdates=( "${NumberedUpdates[@]:1}" ) SelectedUpdates=( "${NumberedUpdates[@]:1}" )
ChoiceClean=$(echo "$Choice" |sed 's/[,.:;]/ /g') ChoiceClean=$(echo "$Choice" |sed 's/[,.:;]/ /g')
else else
@@ -86,8 +87,9 @@ choosecontainers() {
done done
fi fi
done done
printf "\nYou've SelectedUpdates:\n" printf "\nUpdating containers:\n"
printf "%s\n" "${SelectedUpdates[@]}" printf "%s\n" "${SelectedUpdates[@]}"
printf "\n"
} }
### Check the image-hash of every running container VS the registry ### Check the image-hash of every running container VS the registry
@@ -130,13 +132,12 @@ 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[36;1mDo you want to update? y/[n]\033[0m " printf "\n\033[36;1mChoose what containers to update.\033[0m\n"
read UpdYes choosecontainers
[ "$UpdYes" != "${UpdYes#[Yy]}" ] && choosecontainers
else else
SelectedUpdates=( "${GotUpdates[@]}" ) SelectedUpdates=( "${GotUpdates[@]}" )
fi fi
if [ "$UpdYes" != "${UpdYes#[Yy]}" ] ; then if [ "$UpdYes" == "${UpdYes#[Nn]}" ] ; then
for i in "${SelectedUpdates[@]}" for i in "${SelectedUpdates[@]}"
do do
ContPath=$(docker inspect "$i" --format '{{ index .Config.Labels "com.docker.compose.project.config_files" }}') ContPath=$(docker inspect "$i" --format '{{ index .Config.Labels "com.docker.compose.project.config_files" }}')
@@ -152,3 +153,4 @@ else
fi fi
exit 0 exit 0