Skip to content

Commit fb49d82

Browse files
Merge pull request #388 from liuyou2/dev-1.0.0
Optimize the packaged deployment module of dss1.0.0
2 parents cd2a1a6 + 1b00cf9 commit fb49d82

File tree

10 files changed

+1111
-261
lines changed

10 files changed

+1111
-261
lines changed

assembly/bin/appconn-install.sh

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
#!/bin/sh
2+
#Actively load user env
3+
source ~/.bashrc
4+
shellDir=`dirname $0`
5+
workDir=`cd ${shellDir}/..;pwd`
6+
7+
SOURCE_ROOT=${workDir}
8+
9+
#load config
10+
source ${SOURCE_ROOT}/conf/config.sh
11+
source ${SOURCE_ROOT}/conf/db.sh
12+
13+
APPCONN_NAME=''
14+
APPCONN_INSTALL_IP=127.0.0.1
15+
APPCONN_INSTALL_PORT=8088
16+
17+
#echo "Current path of init sql is ${DB_DML_PATH}"
18+
LOCAL_IP="`ifconfig | grep 'inet' | grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $2}'`"
19+
20+
function isSuccess(){
21+
if [ $? -ne 0 ]; then
22+
echo "Failed to " + $1
23+
exit 1
24+
else
25+
echo "Succeed to" + $1
26+
fi
27+
}
28+
29+
PROC_NAME=DSSProjectServerApplication
30+
ProcNumber=`ps -ef |grep -w $PROC_NAME|grep -v grep|wc -l`
31+
if [ $ProcNumber -le 0 ];then
32+
echo "${PROC_NAME} is not running,Please check whether DSS is installed"
33+
exit 1000
34+
else
35+
echo "Begine to install appconn"
36+
fi
37+
38+
##choose install mysql mode
39+
function initInstallAppConn() {
40+
echo "Please select the type of installation component?"
41+
echo " 1: schedulis"
42+
echo " 2: visualis"
43+
echo " 3:Your AppConn Name"
44+
echo " 4:exit"
45+
read -p "Please input the choice:" idx
46+
if [[ '1' = "$idx" ]];then
47+
APPCONN_NAME="schedulis"
48+
elif [[ '2' = "$idx" ]];then
49+
APPCONN_NAME="visualis"
50+
elif [[ '4' = "$idx" ]];then
51+
echo "no choice,exit!"
52+
exit 1
53+
else
54+
APPCONN_NAME=$idx
55+
fi
56+
echo "Current installation component is ${APPCONN_NAME}"
57+
58+
echo ""
59+
echo "If this machine(127.0.0.1) is installed, enter 1"
60+
echo "For others, you need to enter a complete IP address."
61+
read -p "Please enter the ip of appconn: " ip
62+
APPCONN_INSTALL_IP=$ip
63+
if [[ '1' = "$ip" ]];then
64+
APPCONN_INSTALL_IP="127.0.0.1"
65+
fi
66+
echo "You input ip is ${APPCONN_INSTALL_IP}"
67+
68+
echo ""
69+
read -p "Please enter the port of appconn:" port
70+
APPCONN_INSTALL_PORT=$port
71+
echo "You input ip is ${APPCONN_INSTALL_PORT}"
72+
}
73+
74+
function replaceCommonIp() {
75+
if [[ $APPCONN_INSTALL_IP == "127.0.0.1" ]] || [[ $APPCONN_INSTALL_IP == "0.0.0.0" ]];then
76+
echo "APPCONN_INSTALL_IP is equals $APPCONN_INSTALL_IP, we will change it to ip address"
77+
APPCONN_INSTALL_IP=$LOCAL_IP
78+
fi
79+
}
80+
81+
##choose execute mysql mode
82+
function executeSQL() {
83+
TEMP_DB_DML_PATH=${SOURCE_ROOT}/dss-appconns/${APPCONN_NAME}/db
84+
DB_DML_PATH=$TEMP_DB_DML_PATH/init_real.sql
85+
cp -rf $TEMP_DB_DML_PATH/init.sql $DB_DML_PATH
86+
sed -i "s/APPCONN_INSTALL_IP/$APPCONN_INSTALL_IP/g" $DB_DML_PATH
87+
sed -i "s/APPCONN_INSTALL_PORT/$APPCONN_INSTALL_PORT/g" $DB_DML_PATH
88+
sed -i "s#DSS_INSTALL_HOME_VAL#$DSS_INSTALL_HOME#g" $DB_DML_PATH
89+
mysql -h$MYSQL_HOST -P$MYSQL_PORT -u$MYSQL_USER -p$MYSQL_PASSWORD -D$MYSQL_DB --default-character-set=utf8 -e "source $DB_DML_PATH"
90+
isSuccess "source $DB_DML_PATH"
91+
echo "the table update finished"
92+
}
93+
94+
echo ""
95+
echo "step1:Initialize installation settings"
96+
initInstallAppConn
97+
echo ""
98+
99+
echo "step2:replaceIp"
100+
replaceCommonIp
101+
echo ""
102+
103+
echo "step3:update database"
104+
executeSQL
105+
echo ""
106+
107+
echo "step4:refresh appconn load"
108+
curl -H "Token-Code:BML-AUTH" -H "Token-User:hadoop" -X GET http://${GATEWAY_INSTALL_IP}:${GATEWAY_PORT}/api/rest_j/v1/dss/framework/project/appconn/${APPCONN_NAME}/load
109+
echo ""
110+
111+
echo "Please restart services of DSS's and Linkis's"
112+

assembly/bin/checkEnv.sh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/bin/sh
2+
#
3+
# Copyright 2019 WeBank
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
say() {
18+
printf 'check command fail \n %s\n' "$1"
19+
}
20+
21+
err() {
22+
say "$1" >&2
23+
exit 1
24+
}
25+
26+
check_cmd() {
27+
command -v "$1" > /dev/null 2>&1
28+
}
29+
30+
need_cmd() {
31+
if ! check_cmd "$1"; then
32+
err "need '$1' (your linux command not found)"
33+
fi
34+
}
35+
echo "<-----start to check used cmd---->"
36+
need_cmd yum
37+
need_cmd java
38+
need_cmd mysql
39+
need_cmd telnet
40+
need_cmd tar
41+
need_cmd sed
42+
need_cmd dos2unix
43+
echo "<-----end to check used cmd---->"

assembly/bin/excecuteSQL.sh

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
#!/bin/sh
2+
3+
function checkExternalServer(){
4+
echo "telnet check for your $SERVER_NAME, if you wait for a long time,may be your $SERVER_NAME does not prepared"
5+
result=`echo -e "\n" | telnet $EXTERNAL_SERVER_IP $EXTERNAL_SERVER_PORT 2>/dev/null | grep Connected | wc -l`
6+
if [ $result -eq 1 ]; then
7+
echo "$SERVER_NAME is OK."
8+
else
9+
echo "$SERVER_NAME is Bad. You need to prepare the' $SERVER_NAME ' environment in advance"
10+
exit 1
11+
fi
12+
}
13+
14+
## choose install mode
15+
function chooseInstallMode() {
16+
echo "Simple installation mode"
17+
#check for Java
18+
checkJava
19+
#check for mysql
20+
SERVER_NAME=MYSQL
21+
EXTERNAL_SERVER_IP=$MYSQL_HOST
22+
EXTERNAL_SERVER_PORT=$MYSQL_PORT
23+
checkExternalServer
24+
}
25+
26+
##choose install mysql mode
27+
function chooseInstallMySQLMode() {
28+
echo "Do you want to clear Dss table information in the database?"
29+
echo " 1: Do not execute table-building statements"
30+
echo " 2: Dangerous! Clear all data and rebuild the tables."
31+
echo ""
32+
MYSQL_INSTALL_MODE=1
33+
read -p "Please input the choice:" idx
34+
if [[ '2' = "$idx" ]];then
35+
MYSQL_INSTALL_MODE=2
36+
echo "You chose Rebuild the table"
37+
elif [[ '1' = "$idx" ]];then
38+
MYSQL_INSTALL_MODE=1
39+
echo "You chose not execute table-building statements"
40+
else
41+
echo "no choice,exit!"
42+
exit 1
43+
fi
44+
45+
##init db
46+
if [[ '2' = "$MYSQL_INSTALL_MODE" ]];then
47+
ENV_FLAG="dev"
48+
DB_CONF_PATH=${workDir}/db
49+
DB_DML_PATH=$DB_CONF_PATH/dss_dml_real.sql
50+
replaceAppConnInstanceSQL
51+
executeSQL
52+
fi
53+
}
54+
55+
##choose execute mysql mode
56+
function executeSQL() {
57+
chooseInstallMode
58+
59+
sed -i "s/GATEWAY_INSTALL_IP/$GATEWAY_INSTALL_IP/g" $DB_DML_PATH
60+
sed -i "s/GATEWAY_PORT/$GATEWAY_PORT/g" $DB_DML_PATH
61+
62+
sed -i "s#DSS_INSTALL_HOME_VAL#$DSS_INSTALL_HOME#g" $DB_DML_PATH
63+
64+
mysql -h$MYSQL_HOST -P$MYSQL_PORT -u$MYSQL_USER -p$MYSQL_PASSWORD -D$MYSQL_DB --default-character-set=utf8 -e "source $DB_CONF_PATH/dss_ddl.sql"
65+
isSuccess "source dss_ddl.sql"
66+
mysql -h$MYSQL_HOST -P$MYSQL_PORT -u$MYSQL_USER -p$MYSQL_PASSWORD -D$MYSQL_DB --default-character-set=utf8 -e "source $DB_DML_PATH"
67+
isSuccess "source dss_dml_real.sql"
68+
echo "Rebuild the table"
69+
}
70+
71+
function replaceAppConnInstanceSQL() {
72+
DB_DML_PATH=$DB_CONF_PATH/dss_dml_real.sql
73+
cp -rf $DB_CONF_PATH/dss_dml.sql $DB_DML_PATH
74+
sed -i "s#ORCHESTRATOR_IP#$DSS_FRAMEWORK_ORCHESTRATOR_SERVER_INSTALL_IP#g" $DB_DML_PATH
75+
sed -i "s#ORCHESTRATOR_PORT#$DSS_FRAMEWORK_ORCHESTRATOR_SERVER_PORT#g" $DB_DML_PATH
76+
77+
sed -i "s#WORKFLOW_IP#$DSS_WORKFLOW_SERVER_INSTALL_IP#g" $DB_DML_PATH
78+
sed -i "s#WORKFLOW_PORT#$DSS_WORKFLOW_SERVER_PORT#g" $DB_DML_PATH
79+
80+
sed -i "s#EVENTCHECKER_JDBC_URL#$EVENTCHECKER_JDBC_URL#g" $DB_DML_PATH
81+
sed -i "s#EVENTCHECKER_JDBC_USERNAME#$EVENTCHECKER_JDBC_USERNAME#g" $DB_DML_PATH
82+
sed -i "s#EVENTCHECKER_JDBC_PASSWORD#$EVENTCHECKER_JDBC_PASSWORD#g" $DB_DML_PATH
83+
84+
sed -i "s#DATACHECKER_JOB_JDBC_URL#$DATACHECKER_JOB_JDBC_URL#g" $DB_DML_PATH
85+
sed -i "s#DATACHECKER_JOB_JDBC_USERNAME#$DATACHECKER_JOB_JDBC_USERNAME#g" $DB_DML_PATH
86+
sed -i "s#DATACHECKER_JOB_JDBC_PASSWORD#$DATACHECKER_JOB_JDBC_PASSWORD#g" $DB_DML_PATH
87+
88+
sed -i "s#DATACHECKER_BDP_JDBC_URL#$DATACHECKER_BDP_JDBC_URL#g" $DB_DML_PATH
89+
sed -i "s#DATACHECKER_BDP_JDBC_USERNAME#$DATACHECKER_BDP_JDBC_USERNAME#g" $DB_DML_PATH
90+
sed -i "s#DATACHECKER_BDP_JDBC_PASSWORD#$DATACHECKER_BDP_JDBC_PASSWORD#g" $DB_DML_PATH
91+
92+
sed -i "s#BDP_MASK_IP#127.0.0.1#g" $DB_DML_PATH
93+
sed -i "s#BDP_MASK_PORT#8087#g" $DB_DML_PATH
94+
95+
sed -i "s#EMAIL_HOST#${EMAIL_HOST}#g" $DB_DML_PATH
96+
sed -i "s#EMAIL_PORT#${EMAIL_PORT}#g" $DB_DML_PATH
97+
sed -i "s#EMAIL_USERNAME#${EMAIL_USERNAME}#g" $DB_DML_PATH
98+
sed -i "s#EMAIL_PASSWORD#${EMAIL_PASSWORD}#g" $DB_DML_PATH
99+
sed -i "s#EMAIL_PROTOCOL#${EMAIL_PROTOCOL}#g" $DB_DML_PATH
100+
}
101+
102+
chooseInstallMySQLMode

0 commit comments

Comments
 (0)