1
- #! /bin/bash
1
+ #! /bin/sh
2
2
3
3
# Colors definition
4
4
readonly RED=$( tput setaf 1)
@@ -17,7 +17,7 @@ verify_podman_binary() {
17
17
# Add port as 9000:9000 as arg when the SO is MacOS or Win
18
18
add_host_port_arg (){
19
19
args=" --net=host"
20
- if [[ " $ OSTYPE" == " darwin" * ] ] || uname -r | grep -q ' Microsoft' ; then
20
+ if [ -z " ${ OSTYPE##* " darwin" * } " ] || uname -r | grep -q ' Microsoft' ; then
21
21
args=" -p 9000:9000"
22
22
fi
23
23
}
@@ -30,30 +30,33 @@ run_ocp_console_image (){
30
30
secretname=$( kubectl get serviceaccount default --namespace=kube-system -o jsonpath=' {.secrets[0].name}' )
31
31
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)
32
32
33
- echo -e " Using $endpoint "
34
- $POD_MANAGER run -dit --rm $args \
33
+ echo " Using $endpoint "
34
+ $POD_MANAGER run -d --rm $args \
35
35
-e BRIDGE_USER_AUTH=" disabled" \
36
36
-e BRIDGE_K8S_MODE=" off-cluster" \
37
37
-e BRIDGE_K8S_MODE_OFF_CLUSTER_ENDPOINT=" $endpoint " \
38
38
-e BRIDGE_K8S_MODE_OFF_CLUSTER_SKIP_VERIFY_TLS=true \
39
39
-e BRIDGE_K8S_AUTH=" bearer-token" \
40
40
-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 &
42
42
}
43
43
44
44
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
57
60
}
58
61
59
62
# Calling the functions
0 commit comments