Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: make run_console_local.sh working on WSLv1 #1154

Merged
merged 2 commits into from
Dec 21, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 22 additions & 19 deletions scripts/run_console_local.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh

# Colors definition
readonly RED=$(tput setaf 1)
Expand All @@ -17,7 +17,7 @@ verify_podman_binary() {
# Add port as 9000:9000 as arg when the SO is MacOS or Win
add_host_port_arg (){
args="--net=host"
if [[ "$OSTYPE" == "darwin"* ]] || [[ "$(< /proc/version)" == *"@(Microsoft|WSL)"* ]]; then
if [ -z "${OSTYPE##*"darwin"*}" ] || uname -r | grep -q 'Microsoft'; then
args="-p 9000:9000"
fi
}
Expand All @@ -30,30 +30,33 @@ run_ocp_console_image (){
secretname=$(kubectl get serviceaccount default --namespace=kube-system -o jsonpath='{.secrets[0].name}')
endpoint=$(kubectl config view -o json | jq '{myctx: .["current-context"], ctxs: .contexts[], clusters: .clusters[]}' | jq 'select(.myctx == .ctxs.name)' | jq 'select(.ctxs.context.cluster == .clusters.name)' | jq '.clusters.cluster.server' -r)

echo -e "Using $endpoint"
$POD_MANAGER run -dit --rm $args \
echo "Using $endpoint"
$POD_MANAGER run -d --rm $args \
-e BRIDGE_USER_AUTH="disabled" \
-e BRIDGE_K8S_MODE="off-cluster" \
-e BRIDGE_K8S_MODE_OFF_CLUSTER_ENDPOINT=$endpoint \
-e BRIDGE_K8S_MODE_OFF_CLUSTER_ENDPOINT="$endpoint" \
-e BRIDGE_K8S_MODE_OFF_CLUSTER_SKIP_VERIFY_TLS=true \
-e BRIDGE_K8S_AUTH="bearer-token" \
-e BRIDGE_K8S_AUTH_BEARER_TOKEN=$(kubectl get secret "$secretname" --namespace=kube-system -o template --template='{{.data.token}}' | base64 --decode) \
quay.io/openshift/origin-console:latest &> /dev/null
-e BRIDGE_K8S_AUTH_BEARER_TOKEN="$(kubectl get secret "$secretname" --namespace=kube-system -o template --template='{{.data.token}}' | base64 --decode)" \
quay.io/openshift/origin-console:latest > /dev/null 2>&1 &
}

verify_ocp_console_image (){
if [ "$($POD_MANAGER ps -q -f label=io.openshift.build.source-location=https://github.com/openshift/console)" ];
then
container_id="$($POD_MANAGER ps -q -l -f label=io.openshift.build.source-location=https://github.com/openshift/console)"
echo -e "${GREEN}The OLM is accessible via web console at:${RESET}"
echo -e "${GREEN}http://localhost:9000/${RESET}"
echo -e "${GREEN}Press Ctrl-C to quit${RESET}";
$POD_MANAGER attach $container_id
else
echo -e "${RED}Unable to run the console locally. May this port is in usage already.${RESET}"
echo -e "${RED}Check if the OLM is not accessible via web console at: http://localhost:9000/${RESET}"
exit 1
fi
# Try for 5 seconds to reach the image
for i in 1 2 3 4 5; do
if [ "$($POD_MANAGER ps -q -f label=io.openshift.build.source-location=https://github.com/openshift/console)" ]; then
container_id="$($POD_MANAGER ps -q -l -f label=io.openshift.build.source-location=https://github.com/openshift/console)"
echo "${GREEN}The OLM is accessible via web console at:${RESET}"
echo "${GREEN}http://localhost:9000/${RESET}"
echo "${GREEN}Press Ctrl-C to quit${RESET}";
$POD_MANAGER attach "$container_id"
exit 0
fi
sleep 1 # Wait one second to try again
done
echo "${RED}Unable to run the console locally. May this port is in usage already.${RESET}"
echo "${RED}Check if the OLM is not accessible via web console at: http://localhost:9000/${RESET}"
exit 1
}

# Calling the functions
Expand Down