This is an automated email from the ASF dual-hosted git repository.

jshao pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/gravitino.git


The following commit(s) were added to refs/heads/main by this push:
     new 39ad18afa0 [#5976] Improvement(bin):Add validation checks to the 
startup scripts to prevent incorrect usage (#5977)
39ad18afa0 is described below

commit 39ad18afa0738c20071f969955dc01e9d4c6ff24
Author: Chun-Hao Liu <[email protected]>
AuthorDate: Wed Jan 15 11:12:59 2025 +0800

    [#5976] Improvement(bin):Add validation checks to the startup scripts to 
prevent incorrect usage (#5977)
    
    ### What changes were proposed in this pull request?
    
    #5976
    
    - Add file suffix ‘template’ to the following scripts:
        - bin/gravitino.sh
        - bin/common.sh
        - bin/gravitino-iceberg-rest-server.sh
    - Add a validation check on `GRAVITINO_VERSION` in the script
    bin/common.sh ( renamed to bin/common.sh.template ) with the followings
    :
    
        ```bash
        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
    
        ```
    
    - Update the following tasks in the root build.gradle.kts as described
    below :
        - compileDistribution
        - compileIcebergRESTServer
        ```bash
         eachFile {
              if (name == "gravitino-env.sh" || name == "common.sh") {
                filter { line ->
                  line.replace("GRAVITINO_VERSION_PLACEHOLDER", "$version")
                }
              }
            }
        ```
    
    ### Why are the changes needed?
    
    To prevent incorrect usage with startup scripts
    
    ### Does this PR introduce _any_ user-facing change?
    
    No
    
    ### How was this patch tested?
    - The scripts below will exit with status 1 and print an error message
    with the correct instructions
    ```bash
    
    cd bin
    gravitino.sh.template start
    gravitino-iceberg-rest-server.sh.template start
    ```
    
    - correct way to run gravitino :
    ```bash
    ./gradle clean build -x test compileDistribution
    
    cd distribution/package/bin
    
    ./gravitino.sh start
    
    ./gravitino-iceberg-rest-server.sh start
    
    ```
---
 bin/{common.sh => common.sh.template}                            | 9 +++++++++
 ...-rest-server.sh => gravitino-iceberg-rest-server.sh.template} | 0
 bin/{gravitino.sh => gravitino.sh.template}                      | 0
 docs/getting-started.md                                          | 4 ++--
 4 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/bin/common.sh b/bin/common.sh.template
similarity index 90%
rename from bin/common.sh
rename to bin/common.sh.template
index a6f002ad91..b81710a3fc 100644
--- a/bin/common.sh
+++ b/bin/common.sh.template
@@ -42,6 +42,15 @@ if [[ -f "${GRAVITINO_CONF_DIR}/gravitino-env.sh" ]]; then
   . "${GRAVITINO_CONF_DIR}/gravitino-env.sh"
 fi
 
+if [[ -z "${GRAVITINO_VERSION}" ]]; then
+  echo -e "GRAVITINO_VERSION is not set, you may need to:\n" \
+  "1. Ensure that a compiled version of Gravitino is available at " \
+  "\${GRAVITINO_HOME}/distribution/package. You may need to compile it first, 
" \
+  "if you are installing the software from source code.\n" \
+  "2. Execute gravitino.sh in the \${GRAVITINO_HOME}/distribution/package/bin 
directory."
+  exit 1
+fi
+
 GRAVITINO_CLASSPATH+=":${GRAVITINO_CONF_DIR}"
 
 JVM_VERSION=8
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/docs/getting-started.md b/docs/getting-started.md
index 7b9ce193d2..f729d418ac 100644
--- a/docs/getting-started.md
+++ b/docs/getting-started.md
@@ -176,10 +176,10 @@ To use Gravitino locally on macOS or Linux, follow these 
similar steps:
 
    Or, you can install Gravitino from scratch, follow 
[how-to-build](./how-to-build.md) and [how-to-install](./how-to-install.md).
 
-3. Start Gravitino using the gravitino.sh script:
+3. Start Gravitino using the gravitino.sh script in the binary release package 
or Docker image:
 
     ```shell
-    <path-to-gravitino>/bin/gravitino.sh start
+    ${GRAVITINO_HOME}/bin/gravitino.sh start
     ```
 
 ## Installing Apache Hive on AWS or Google Cloud Platform

Reply via email to