From 03a3e49650d9839e67456e514288d7a183ee8451 Mon Sep 17 00:00:00 2001 From: mag37 Date: Tue, 7 Feb 2023 14:56:18 +0100 Subject: [PATCH] Streamlining selection. No need to choose yes-no before choosing contianers, q/n to quit. Cleaned some wording and order of messages. --- dockcheck.sh | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/dockcheck.sh b/dockcheck.sh index 9bc437a..87f05d3 100755 --- a/dockcheck.sh +++ b/dockcheck.sh @@ -1,5 +1,5 @@ #!/bin/bash -VERSION="v0.1.3" +VERSION="v0.1.4" Github="https://github.com/mag37/dockcheck" ### Check if there's a new release of the script: @@ -74,9 +74,10 @@ done ### Choose from list -function: choosecontainers() { 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 (eg. 1,3,4): ' Choice - if [ "$Choice" == "0" ] ; then + read -p "Enter number(s) separated by comma, [q] to quit: " Choice + if [[ "$Choice" =~ [qQnN] ]] ; then + exit 0 + elif [ "$Choice" == "0" ] ; then SelectedUpdates=( "${NumberedUpdates[@]:1}" ) ChoiceClean=$(echo "$Choice" |sed 's/[,.:;]/ /g') else @@ -86,8 +87,9 @@ choosecontainers() { done fi done - printf "\nYou've SelectedUpdates:\n" + printf "\nUpdating containers:\n" printf "%s\n" "${SelectedUpdates[@]}" + printf "\n" } ### Check the image-hash of every running container VS the registry @@ -130,13 +132,12 @@ fi ### Optionally get updates if there's any if [ -n "$GotUpdates" ] ; then if [ -z "$UpdYes" ] ; then - printf "\n\033[36;1mDo you want to update? y/[n]\033[0m " - read UpdYes - [ "$UpdYes" != "${UpdYes#[Yy]}" ] && choosecontainers + printf "\n\033[36;1mChoose what containers to update.\033[0m\n" + choosecontainers else SelectedUpdates=( "${GotUpdates[@]}" ) fi - if [ "$UpdYes" != "${UpdYes#[Yy]}" ] ; then + if [ "$UpdYes" == "${UpdYes#[Nn]}" ] ; then for i in "${SelectedUpdates[@]}" do ContPath=$(docker inspect "$i" --format '{{ index .Config.Labels "com.docker.compose.project.config_files" }}') @@ -152,3 +153,4 @@ else fi exit 0 +