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

muchunjin pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/incubator-streampark.git


The following commit(s) were added to refs/heads/dev by this push:
     new ded8c4f5b [Improve] workspace local permission check (#2557)
ded8c4f5b is described below

commit ded8c4f5b722baf439b8824f13aceb2062106112
Author: benjobs <[email protected]>
AuthorDate: Sat Apr 22 22:36:42 2023 +0800

    [Improve] workspace local permission check (#2557)
    
    Co-authored-by: benjobs <[email protected]>
---
 .../src/main/assembly/bin/streampark.sh            | 42 ++++++++++++++++++----
 1 file changed, 35 insertions(+), 7 deletions(-)

diff --git 
a/streampark-console/streampark-console-service/src/main/assembly/bin/streampark.sh
 
b/streampark-console/streampark-console-service/src/main/assembly/bin/streampark.sh
index 4ea6bd1d8..09805c179 100755
--- 
a/streampark-console/streampark-console-service/src/main/assembly/bin/streampark.sh
+++ 
b/streampark-console/streampark-console-service/src/main/assembly/bin/streampark.sh
@@ -257,6 +257,23 @@ print_logo() {
   printf '      %s   ──────── Apache StreamPark, Make stream processing easier 
ô~ô!%s\n\n'         $PRIMARY  $RESET
 }
 
+parse_yaml() {
+   local prefix=$2
+   local s='[[:space:]]*' w='[a-zA-Z0-9_]*' fs=$(echo @|tr @ '\034')
+   sed -ne "s|^\($s\):|\1|" \
+        -e "s|^\($s\)\($w\)$s:$s[\"']\(.*\)[\"']$s\$|\1$fs\2$fs\3|p" \
+        -e "s|^\($s\)\($w\)$s:$s\(.*\)$s\$|\1$fs\2$fs\3|p"  $1 |
+   awk -F$fs '{
+      indent = length($1)/2;
+      vname[indent] = $2;
+      for (i in vname) {if (i > indent) {delete vname[i]}}
+      if (length($3) > 0) {
+         vn=""; for (i=0; i<indent; i++) {vn=(vn)(vname[i])("_")}
+         printf("%s%s%s=\"%s\"\n", "'$prefix'",vn, $2, $3);
+      }
+   }'
+}
+
 # shellcheck disable=SC2120
 running() {
   if [ -f "$APP_PID" ]; then
@@ -303,14 +320,25 @@ start() {
 
   PROPER="${APP_CONF}/application.yml"
   if [[ ! -f "$PROPER" ]] ; then
-    PROPER="${APP_CONF}/application.properties"
-    if [[ ! -f "$PROPER" ]] ; then
-      echo_r "Usage: properties file (application.properties|application.yml) 
not found! ";
-    else
-      echo_g "Usage: properties file:application.properties ";
-    fi
+    echo_r "ERROR: config file application.yml invalid or not found! ";
+    exit 1;
   else
-    echo_g "Usage: properties file:application.yml ";
+    echo_g "Usage: config file: $PROPER ";
+  fi
+
+  # shellcheck disable=SC2046
+  eval $(parse_yaml "${PROPER}" "conf_")
+  # shellcheck disable=SC2001
+  # shellcheck disable=SC2154
+  # shellcheck disable=SC2155
+  local workspace=$(echo "$conf_streampark_workspace_local" | sed 's/#.*$//g')
+  if [[ ! -d $workspace ]]; then
+    echo_r "ERROR: streampark.workspace.local: \"$workspace\" is invalid path, 
Please reconfigure in application.yml"
+    exit 1;
+  fi
+  if [[ ! -w $workspace ]] || [[ ! -r $workspace ]]; then
+      echo_r "ERROR: streampark.workspace.local: \"$workspace\" Permission 
denied! "
+      exit 1;
   fi
 
   if [ "${HADOOP_HOME}"x == ""x ]; then

Reply via email to