You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@linkis.apache.org by pe...@apache.org on 2023/02/05 15:02:22 UTC

[linkis] branch dev-1.3.2 updated: Echo error message to console when initing db in install.sh (#4145)

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

peacewong pushed a commit to branch dev-1.3.2
in repository https://gitbox.apache.org/repos/asf/linkis.git


The following commit(s) were added to refs/heads/dev-1.3.2 by this push:
     new 3f47f826e Echo error message to console when initing db in install.sh (#4145)
3f47f826e is described below

commit 3f47f826ec974d76d91c4eabb98eb7e0421661de
Author: QuantumXiecao <99...@users.noreply.github.com>
AuthorDate: Sun Feb 5 23:02:16 2023 +0800

    Echo error message to console when initing db in install.sh (#4145)
    
    Co-authored-by: xiecao <ha...@alibaba-inc.com>
---
 linkis-dist/bin/common.sh  | 17 ++++++++++++-----
 linkis-dist/bin/install.sh | 20 ++++++++++++++++----
 2 files changed, 28 insertions(+), 9 deletions(-)

diff --git a/linkis-dist/bin/common.sh b/linkis-dist/bin/common.sh
index e3a17877a..7f953d91a 100644
--- a/linkis-dist/bin/common.sh
+++ b/linkis-dist/bin/common.sh
@@ -69,14 +69,22 @@ function copyFile(){
 
 }
 
-function isSuccess(){
-if [ $? -ne 0 ]; then
+function echoErrMsgAndExit() {
     echo -e "${RED}Failed${NC} to $1"
     echo ""
     exit 1
-else
+}
+
+function echoSuccessMsg() {
     echo -e "${GREEN}Succeed${NC} to $1"
     echo ""
+}
+
+function isSuccess(){
+if [ $? -ne 0 ]; then
+    echoErrMsgAndExit $1
+else
+    echoSuccessMsg $1
 fi
 }
 
@@ -84,7 +92,6 @@ function isSuccessWithoutExit(){
 if [ $? -ne 0 ]; then
     echo -e "WARN failed to $1 , but installation will continue,some function may not work properly"
 else
-    echo -e "${GREEN}Succeed${NC} to $1"
-    echo ""
+    echoSuccessMsg $1
 fi
 }
\ No newline at end of file
diff --git a/linkis-dist/bin/install.sh b/linkis-dist/bin/install.sh
index fa6d18cba..891e798b1 100644
--- a/linkis-dist/bin/install.sh
+++ b/linkis-dist/bin/install.sh
@@ -263,10 +263,22 @@ MYSQL_PASSWORD=$(echo ${MYSQL_PASSWORD//'#'/'\#'})
 #init db
 if [[ '2' = "$MYSQL_INSTALL_MODE" ]];then
   mysql -h$MYSQL_HOST -P$MYSQL_PORT -u$MYSQL_USER -p$MYSQL_PASSWORD --default-character-set=utf8 -e "CREATE DATABASE IF NOT EXISTS $MYSQL_DB DEFAULT CHARSET utf8 COLLATE utf8_general_ci;"
-  mysql -h$MYSQL_HOST -P$MYSQL_PORT -u$MYSQL_USER -p$MYSQL_PASSWORD -D$MYSQL_DB  --default-character-set=utf8 -e "source ${LINKIS_HOME}/db/linkis_ddl.sql"
-  isSuccess "source linkis_ddl.sql"
-  mysql -h$MYSQL_HOST -P$MYSQL_PORT -u$MYSQL_USER -p$MYSQL_PASSWORD -D$MYSQL_DB  --default-character-set=utf8 -e "source ${LINKIS_HOME}/db/linkis_dml.sql"
-  isSuccess "source linkis_dml.sql"
+  ddl_result=`mysql -h$MYSQL_HOST -P$MYSQL_PORT -u$MYSQL_USER -p$MYSQL_PASSWORD -D$MYSQL_DB  --default-character-set=utf8 -e "source ${LINKIS_HOME}/db/linkis_ddl.sql" 2>&1`
+  # Check ddl-sql execution result
+  if [[ $? -ne 0 || $ddl_result =~ "ERROR" ]];then
+      echoErrMsgAndExit "$ddl_result"
+  else
+      echoSuccessMsg "source linkis_ddl.sql"
+  fi
+
+  dml_result=`mysql -h$MYSQL_HOST -P$MYSQL_PORT -u$MYSQL_USER -p$MYSQL_PASSWORD -D$MYSQL_DB  --default-character-set=utf8 -e "source ${LINKIS_HOME}/db/linkis_dml.sql" 2>&1`
+  # Check dml-sql execution result
+  if [[ $? -ne 0 || $dml_result =~ "ERROR" ]];then
+      echoErrMsgAndExit "$dml_result"
+  else
+      echoSuccessMsg "source linkis_dml.sql"
+  fi
+
   echo "Rebuild the table"
 fi
 ###########################################################################


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@linkis.apache.org
For additional commands, e-mail: commits-help@linkis.apache.org