diff --git a/remote_cli/README b/remote_cli/README index 8d963f6..207a620 100644 --- a/remote_cli/README +++ b/remote_cli/README @@ -137,3 +137,15 @@ kubectl config --kubeconfig ${OUTPUT_FILE} use-context stxcluster-default 2. openstack image create --disk-format qcow2 --container-format bare \ --public --file /wd/centos63.qcow2 centos63-image + +7. Some commands used by remote CLI are designed to leave you in a shell prompt. + Examples of such commands are "openstack" or "kubectl exec -ti + -- /bin/bash". There are cases where the mechanism for identifying commands + that should leave you in a shell prompt is not identifying them correctly. + If users encounter such scenarios, they can force the shell or force disable + the shell options using the FORCE_SHELL or FORCE_NO_SHELL variables before + the command. You cannot use both variables at the same time. + + Examples: + - force shell: FORCE_SHELL=true kubectl exec -ti -- /bin/bash + - disable shell: FORCE_NO_SHELL=true kubectl exec -- ls diff --git a/remote_cli/client_wrapper.sh b/remote_cli/client_wrapper.sh index 6374292..521b230 100755 --- a/remote_cli/client_wrapper.sh +++ b/remote_cli/client_wrapper.sh @@ -35,8 +35,27 @@ for exp in $EXPORTS; do fi done -if [ -z "$2" ]; then - exec docker run -ti ${COMMAND_ENV} ${VOLUME_LIST} --workdir /wd ${CLIENT_IMAGE_NAME} "$@" -else - exec docker run -t ${COMMAND_ENV} ${VOLUME_LIST} --workdir /wd ${CLIENT_IMAGE_NAME} "$@" +if [[ -z "$FORCE_SHELL" ]] || [[ "$FORCE_SHELL" != "true" ]]; then + FORCE_SHELL="false" +fi + +if [[ -z "$FORCE_NO_SHELL" ]] || [[ "$FORCE_NO_SHELL" != "true" ]]; then + FORCE_NO_SHELL="false" +fi + +if [[ "$FORCE_SHELL" == "true" ]] && [[ "$FORCE_NO_SHELL" == "true" ]]; then + echo "Error: cannot set both FORCE_SHELLL and FORCE_NO_SHELL variables at the same time". + echo "Unset one of them and re-run the command" + exit 1 +fi + + +if [[ "$FORCE_SHELL" == "true" ]]; then + exec docker run --rm -ti ${COMMAND_ENV} ${VOLUME_LIST} --workdir /wd ${CLIENT_IMAGE_NAME} "$@" +elif [[ "$FORCE_NO_SHELL" == "true" ]]; then + exec docker run --rm -t ${COMMAND_ENV} ${VOLUME_LIST} --workdir /wd ${CLIENT_IMAGE_NAME} "$@" +elif [ -z "$2" ]; then + exec docker run --rm -ti ${COMMAND_ENV} ${VOLUME_LIST} --workdir /wd ${CLIENT_IMAGE_NAME} "$@" +else + exec docker run --rm -t ${COMMAND_ENV} ${VOLUME_LIST} --workdir /wd ${CLIENT_IMAGE_NAME} "$@" fi