Skip to content

Commit 2ff71f9

Browse files
committed
feat: make run_console_local.sh sh compatible
Signed-off-by: wilmardo <[email protected]>
1 parent 0d47c7a commit 2ff71f9

File tree

1 file changed

+20
-17
lines changed

1 file changed

+20
-17
lines changed

scripts/run_console_local.sh

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/bin/sh
22

33
# Colors definition
44
readonly RED=$(tput setaf 1)
@@ -17,7 +17,7 @@ verify_podman_binary() {
1717
# Add port as 9000:9000 as arg when the SO is MacOS or Win
1818
add_host_port_arg (){
1919
args="--net=host"
20-
if [[ "$OSTYPE" == "darwin"* ]] || uname -r | grep -q 'Microsoft'; then
20+
if [ -z "${OSTYPE##*"darwin"*}" ] || uname -r | grep -q 'Microsoft'; then
2121
args="-p 9000:9000"
2222
fi
2323
}
@@ -30,30 +30,33 @@ run_ocp_console_image (){
3030
secretname=$(kubectl get serviceaccount default --namespace=kube-system -o jsonpath='{.secrets[0].name}')
3131
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)
3232

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

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

5962
# Calling the functions

0 commit comments

Comments
 (0)