diff --git a/docker/docker_build_common.sh b/docker/docker_build_common.sh index 433991645..df639a5d2 100644 --- a/docker/docker_build_common.sh +++ b/docker/docker_build_common.sh @@ -15,6 +15,13 @@ # limitations under the License. get_ipv4_address() { + os="$(uname)" + + if [[ "$os" == "Darwin" ]]; then + ifconfig | awk '/inet / && $2 != "127.0.0.1" { print $2; exit }' + return 0 + fi + if command -v ip &>/dev/null; then ip -o -4 address show | awk '!/127.0.0.1/ {gsub(/\/.*/, "", $4); print $4; exit}' elif command -v ifconfig &>/dev/null; then @@ -58,7 +65,7 @@ function generateControllerPort() { # don't change the length as it is expected 16 bytes of a base64-encoded UUID function randomString() { - echo $(cat /dev/random | env LC_CTYPE=C tr -dc 'a-zA-Z0-9' | fold -w 22 | head -n 1) + openssl rand -base64 16 | tr -dc 'a-zA-Z0-9' | head -c 22 } function checkDocker() { diff --git a/docker/start_app.sh b/docker/start_app.sh index 66956d251..770b7106d 100755 --- a/docker/start_app.sh +++ b/docker/start_app.sh @@ -21,9 +21,9 @@ source $DOCKER_FOLDER/docker_build_common.sh declare -r VERSION=${REVISION:-${VERSION:-main}} declare -r ACCOUNT=${ACCOUNT:-opensource4you} if [[ "$VERSION" == "main" ]]; then - declare -r IMAGE_NAME="ghcr.io/${ACCOUNT,,}/astraea/app:latest" + declare -r IMAGE_NAME="ghcr.io/${ACCOUNT:l}/astraea/app:latest" else - declare -r IMAGE_NAME="ghcr.io/${ACCOUNT,,}/astraea/app:${VERSION,,}" + declare -r IMAGE_NAME="ghcr.io/${ACCOUNT:l}/astraea/app:${VERSION:l}" fi declare -r DOCKERFILE=$DOCKER_FOLDER/app.dockerfile declare -r JMX_PORT=${JMX_PORT:-"$(getRandomPort)"} diff --git a/docker/start_broker.sh b/docker/start_broker.sh index 6249bd70b..ec5fbb559 100755 --- a/docker/start_broker.sh +++ b/docker/start_broker.sh @@ -44,7 +44,7 @@ declare -r JMX_OPTS="-Dcom.sun.management.jmxremote \ -Djava.rmi.server.hostname=$ADDRESS" declare -r HEAP_OPTS="${HEAP_OPTS:-"-Xmx2G -Xms2G"}" declare -r BROKER_PROPERTIES="/tmp/server-${BROKER_PORT}.properties" -declare -r IMAGE_NAME="ghcr.io/${ACCOUNT,,}/astraea/broker:${KAFKA_VERSION,,}" +declare -r IMAGE_NAME="ghcr.io/${ACCOUNT:l}/astraea/broker:${KAFKA_VERSION:l}" declare -r METADATA_VERSION=${METADATA_VERSION:-""} # cleanup the file if it is existent [[ -f "$BROKER_PROPERTIES" ]] && rm -f "$BROKER_PROPERTIES" diff --git a/docker/start_controller.sh b/docker/start_controller.sh index e3806c56c..26fd31ae5 100755 --- a/docker/start_controller.sh +++ b/docker/start_controller.sh @@ -41,7 +41,7 @@ declare -r JMX_OPTS="-Dcom.sun.management.jmxremote \ -Djava.rmi.server.hostname=$ADDRESS" declare -r HEAP_OPTS="${HEAP_OPTS:-"-Xmx2G -Xms2G"}" declare -r CONTROLLER_PROPERTIES="/tmp/controller-${CONTROLLER_PORT}.properties" -declare -r IMAGE_NAME="ghcr.io/${ACCOUNT,,}/astraea/controller:$KAFKA_VERSION" +declare -r IMAGE_NAME="ghcr.io/${ACCOUNT:l}/astraea/controller:$KAFKA_VERSION" declare -r METADATA_VERSION=${METADATA_VERSION:-""} # cleanup the file if it is existent [[ -f "$CONTROLLER_PROPERTIES" ]] && rm -f "$CONTROLLER_PROPERTIES" @@ -268,4 +268,4 @@ if [ "$(echo $?)" -eq 0 ]; then echo "=================================================" else echo "Start up fail" -fi \ No newline at end of file +fi diff --git a/docker/start_worker.sh b/docker/start_worker.sh index 9682b3f2d..4c8daaed2 100755 --- a/docker/start_worker.sh +++ b/docker/start_worker.sh @@ -34,7 +34,7 @@ declare -r JMX_OPTS="-Dcom.sun.management.jmxremote \ declare -r HEAP_OPTS="${HEAP_OPTS:-"-Xmx2G -Xms2G"}" declare -r WORKER_PROPERTIES="/tmp/worker-${WORKER_PORT}.properties" declare -r WORKER_PLUGIN_PATH=${WORKER_PLUGIN_PATH:-/tmp/worker-plugins} -declare -r IMAGE_NAME="ghcr.io/${ACCOUNT,,}/astraea/worker:${KAFKA_VERSION,,}" +declare -r IMAGE_NAME="ghcr.io/${ACCOUNT:l}/astraea/worker:${KAFKA_VERSION:l}" declare -r SCRIPT_LOCATION_IN_CONTAINER="./bin/connect-distributed.sh" # cleanup the file if it is existent [[ -f "$WORKER_PROPERTIES" ]] && rm -f "$WORKER_PROPERTIES"