From 9371d4a6882e78944c8adc1728b2925fe25842ac Mon Sep 17 00:00:00 2001 From: knrt10 Date: Sun, 12 Jul 2020 18:40:52 +0530 Subject: [PATCH] Add user prompt for multiple profile If a user has multiple profiles running they can be asked to select from which they want files copied from Signed-off-by: knrt10 --- script.sh | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/script.sh b/script.sh index 9b4d46b..1d85274 100644 --- a/script.sh +++ b/script.sh @@ -4,10 +4,29 @@ USERNAME=`id -un` cd ~/.kube mkdir -p keys -profile=$(minikube profile list -o json | jq '.valid' | jq -r '.[].Name') +profiles=$(minikube profile list -o json | jq -r '.valid | .[] | select(.Status=="Running") | .Name') + +profiles_count=$(echo "$profiles" | wc -l | tr -d '[:space:]') + +if [ "$profiles_count" != 1 ]; then + options=($profiles) + echo "Select running cluster you want to copy files from?" + select opt in "${options[@]}" + do + profile_name=$opt + if [ "$profile_name" == "" ]; then + echo "Wrong option" + continue + fi + break + done + else + profile_name=$profiles +fi + cp /Users/${USERNAME}/.minikube/ca.crt keys/ -cp /Users/${USERNAME}/.minikube/profiles/$profile/client.crt keys/ -cp /Users/${USERNAME}/.minikube/profiles/$profile/client.key keys/ +cp /Users/${USERNAME}/.minikube/profiles/$profile_name/client.crt keys/ +cp /Users/${USERNAME}/.minikube/profiles/$profile_name/client.key keys/ gsed -i "s/\/Users\/${USERNAME}\/.minikube\/profiles\/minikube/.\/keys/g" config gsed -i "s/\/Users\/${USERNAME}\/.minikube/.\/keys/g" config