diff --git a/quickstart/docker/image/run-with-ziti-cli.sh b/quickstart/docker/image/run-with-ziti-cli.sh index 13f83d232..e231c9ee5 100755 --- a/quickstart/docker/image/run-with-ziti-cli.sh +++ b/quickstart/docker/image/run-with-ziti-cli.sh @@ -29,7 +29,10 @@ if [[ -f "${initFile}" ]]; then fi # give the controller scripts time to start and create the ziti environment file if running in docker compose -until $(test -f "${ZITI_HOME}/ziti.env"); do echo "waiting for ziti.env..."; sleep 2; done +until $(test -f "${ZITI_HOME}/ziti.env"); do echo "waiting for ziti.env..."; sleep 1; done + +# Pause shortly to avoid the intermittent error of reading the file before it's completely done being written to. +sleep 1 . "${ZITI_SCRIPTS}/ziti-cli-functions.sh" diff --git a/quickstart/docker/image/ziti-cli-functions.sh b/quickstart/docker/image/ziti-cli-functions.sh index fd1e1692e..d8f4ac73e 100755 --- a/quickstart/docker/image/ziti-cli-functions.sh +++ b/quickstart/docker/image/ziti-cli-functions.sh @@ -291,10 +291,11 @@ function _portCheck { elif [[ -n "$BASH_VERSION" ]]; then envVarValue="${!envVar}" else - echo -e "Unknown/Unsupported shell, cannot check port status" - return 1 + echo -e "$(YELLOW "Unknown/Unsupported shell, cannot verify availability of ${2-}'s intended port, proceed with caution")" + return 0 fi + echo -e "Checking if ${2-}'s port (${envVarValue}) is available" portCheckResult=$(lsof -w -i :"${envVarValue}" 2> /dev/null) if [[ "${portCheckResult}" != "" ]]; then # Controller management plane echo -e "$(RED " ")" @@ -510,8 +511,11 @@ function ziti_expressConfiguration { returnCnt=$((returnCnt + $?)) _portCheck "ZITI_CTRL_MGMT_PORT" "Controller Management Plane" returnCnt=$((returnCnt + $?)) - _portCheck "ZITI_EDGE_ROUTER_LISTENER_BIND_PORT" "Router Listener Bind Port" - returnCnt=$((returnCnt + $?)) + if [[ "${ZITI_EDGE_ROUTER_LISTENER_BIND_PORT-}" != "" ]]; then + # This port can be explicitly set but is not always, only check if set + _portCheck "ZITI_EDGE_ROUTER_LISTENER_BIND_PORT" "Router Listener Bind Port" + returnCnt=$((returnCnt + $?)) + fi if [[ "returnCnt" -gt "0" ]]; then return 1; fi #checkHostsFile diff --git a/ziti/cmd/ziti/cmd/create_config_router_edge_test.go b/ziti/cmd/ziti/cmd/create_config_router_edge_test.go index 2340771ab..98dc1eda2 100644 --- a/ziti/cmd/ziti/cmd/create_config_router_edge_test.go +++ b/ziti/cmd/ziti/cmd/create_config_router_edge_test.go @@ -191,7 +191,7 @@ func TestBlankEdgeRouterNameBecomesHostname(t *testing.T) { } func TestDefaultZitiEdgeRouterListenerBindPort(t *testing.T) { - expectedDefaultPort := "10080" + expectedDefaultPort := TEST_ROUTER_LISTENER_PORT // Make sure the related env vars are unset _ = os.Unsetenv("ZITI_EDGE_ROUTER_LISTENER_BIND_PORT") diff --git a/ziti/cmd/ziti/cmd/create_config_router_fabric_test.go b/ziti/cmd/ziti/cmd/create_config_router_fabric_test.go index 6f5fb47fb..5b7805092 100644 --- a/ziti/cmd/ziti/cmd/create_config_router_fabric_test.go +++ b/ziti/cmd/ziti/cmd/create_config_router_fabric_test.go @@ -9,6 +9,8 @@ import ( "time" ) +var TEST_ROUTER_LISTENER_PORT = 10080 + func TestExecuteCreateConfigRouterFabricHasNonBlankTemplateValues(t *testing.T) { routerName := "MyFabricRouter" expectedNonEmptyStringFields := []string{".Router.Listener.BindPort", ".ZitiHome", ".Hostname", ".Router.Name", ".Router.IdentityCert", ".Router.IdentityServerCert", ".Router.IdentityKey", ".Router.IdentityCA", ".Router.Edge.Hostname", ".Router.Edge.Port"} @@ -112,7 +114,7 @@ func TestFabricRouterOutputPathDoesNotExist(t *testing.T) { } func TestDefaultZitiFabricRouterListenerBindPort(t *testing.T) { - expectedDefaultPort := "10080" + expectedDefaultPort := TEST_ROUTER_LISTENER_PORT // Make sure the related env vars are unset _ = os.Unsetenv("ZITI_EDGE_ROUTER_LISTENER_BIND_PORT")