From a5dec5f28afced736ba8dac6e8f6d205dfc2ae15 Mon Sep 17 00:00:00 2001 From: Chun-Hao Liu Date: Wed, 25 Dec 2024 06:34:41 +0800 Subject: [PATCH 1/3] [#5976] Improvement(bin):Add validation checks to the startup scripts to prevent incorrect usage --- bin/{common.sh => common.sh.template} | 7 +++++++ ...server.sh => gravitino-iceberg-rest-server.sh.template} | 0 bin/{gravitino.sh => gravitino.sh.template} | 0 build.gradle.kts | 4 ++-- 4 files changed, 9 insertions(+), 2 deletions(-) rename bin/{common.sh => common.sh.template} (92%) rename bin/{gravitino-iceberg-rest-server.sh => gravitino-iceberg-rest-server.sh.template} (100%) rename bin/{gravitino.sh => gravitino.sh.template} (100%) diff --git a/bin/common.sh b/bin/common.sh.template similarity index 92% rename from bin/common.sh rename to bin/common.sh.template index a6f002ad91d..a2fc0cedadc 100644 --- a/bin/common.sh +++ b/bin/common.sh.template @@ -18,6 +18,13 @@ # Referred from Apache Submarine's common.sh implementation # bin/common.sh +GRAVITINO_VERSION=GRAVITINO_VERSION_PLACEHOLDER +if [[ "$GRAVITINO_VERSION" == *_VERSION_PLACEHOLDER ]]; then + echo "GRAVITINO_VERSION is not set. Please make sure you are running the script from the distribution/package/bin and before running the script, run './gradle clean build -x test compileDistribution'" + exit 1 +fi + + if [ -L "${BASH_SOURCE-$0}" ]; then FWDIR=$(dirname "$(readlink "${BASH_SOURCE-$0}")") else diff --git a/bin/gravitino-iceberg-rest-server.sh b/bin/gravitino-iceberg-rest-server.sh.template similarity index 100% rename from bin/gravitino-iceberg-rest-server.sh rename to bin/gravitino-iceberg-rest-server.sh.template diff --git a/bin/gravitino.sh b/bin/gravitino.sh.template similarity index 100% rename from bin/gravitino.sh rename to bin/gravitino.sh.template diff --git a/build.gradle.kts b/build.gradle.kts index 5e93992e34e..d4c5e33ce01 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -598,7 +598,7 @@ tasks { fileName.replace(".template", "") } eachFile { - if (name == "gravitino-env.sh") { + if (name == "gravitino-env.sh" || name == "common.sh") { filter { line -> line.replace("GRAVITINO_VERSION_PLACEHOLDER", "$version") } @@ -643,7 +643,7 @@ tasks { fileName.replace(".template", "") } eachFile { - if (name == "gravitino-env.sh") { + if (name == "gravitino-env.sh" || name == "common.sh") { filter { line -> line.replace("GRAVITINO_VERSION_PLACEHOLDER", "$version") } From 6b38ae9e7c00c85676222e8408dab51beb23fc51 Mon Sep 17 00:00:00 2001 From: Chun-Hao Liu Date: Wed, 25 Dec 2024 06:59:47 +0800 Subject: [PATCH 2/3] [#5976] Improvement(bin): Remove the '.template' file extension from bin/common.sh --- bin/{common.sh.template => common.sh} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename bin/{common.sh.template => common.sh} (100%) diff --git a/bin/common.sh.template b/bin/common.sh similarity index 100% rename from bin/common.sh.template rename to bin/common.sh From fe87ce53ac10e1f934aa1d3051662e5b1fa2e9c7 Mon Sep 17 00:00:00 2001 From: Chun-Hao Liu Date: Wed, 25 Dec 2024 10:48:59 +0800 Subject: [PATCH 3/3] [#5976] Improvement(bin): Update the error message for startup failures /Adjust the version check /Revert the root build.gradle.kts files --- bin/common.sh | 12 +++++------- build.gradle.kts | 4 ++-- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/bin/common.sh b/bin/common.sh index a2fc0cedadc..33ea68db12b 100644 --- a/bin/common.sh +++ b/bin/common.sh @@ -18,13 +18,6 @@ # Referred from Apache Submarine's common.sh implementation # bin/common.sh -GRAVITINO_VERSION=GRAVITINO_VERSION_PLACEHOLDER -if [[ "$GRAVITINO_VERSION" == *_VERSION_PLACEHOLDER ]]; then - echo "GRAVITINO_VERSION is not set. Please make sure you are running the script from the distribution/package/bin and before running the script, run './gradle clean build -x test compileDistribution'" - exit 1 -fi - - if [ -L "${BASH_SOURCE-$0}" ]; then FWDIR=$(dirname "$(readlink "${BASH_SOURCE-$0}")") else @@ -49,6 +42,11 @@ if [[ -f "${GRAVITINO_CONF_DIR}/gravitino-env.sh" ]]; then . "${GRAVITINO_CONF_DIR}/gravitino-env.sh" fi +if [[ -z "${GRAVITINO_VERSION}" ]]; then + echo -e "No GRAVITINO_VERSION was found, you may need to:\n1. Run the gravitino.sh script on the compiled Gravitino.\n2. Run the gravitino.sh script in the release package." + exit 1 +fi + GRAVITINO_CLASSPATH+=":${GRAVITINO_CONF_DIR}" JVM_VERSION=8 diff --git a/build.gradle.kts b/build.gradle.kts index d4c5e33ce01..5e93992e34e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -598,7 +598,7 @@ tasks { fileName.replace(".template", "") } eachFile { - if (name == "gravitino-env.sh" || name == "common.sh") { + if (name == "gravitino-env.sh") { filter { line -> line.replace("GRAVITINO_VERSION_PLACEHOLDER", "$version") } @@ -643,7 +643,7 @@ tasks { fileName.replace(".template", "") } eachFile { - if (name == "gravitino-env.sh" || name == "common.sh") { + if (name == "gravitino-env.sh") { filter { line -> line.replace("GRAVITINO_VERSION_PLACEHOLDER", "$version") }