forked from FISCO-BCOS/fisco-bcos-browser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy_browser.sh
217 lines (113 loc) · 4.6 KB
/
deploy_browser.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
#!/bin/bash
###################### 参数配置 ######################
userName="test" #需要创建的数据库用户
password="123456" #需要创建的数据库用户密码
passwordRoot="123456" #数据库root账号的密码
dbName="bcos_browser" #需要创建的数据库名
dbIp="192.168.1.100" #数据库所在机器IP
tomcatpath="/software/tomcat/" #tomcat所在路径
###################### 参数配置结束 ####################
#################### 计算全局路径####################
dirpath="$(cd "$(dirname "$0")" && pwd)"
#server gradle build 路径
serverpath="${dirpath}/server/fisco-bcos-browser"
#page gradle build 路径
pagepath="${dirpath}/page/fisco-bcos-browser"
#生成war包cp进Tomcat路径
deployserverpath="${tomcatpath}/webapps"
#启动Tomcat bin目录下的项目启动脚本路径
startbroswer="${tomcatpath}/bin"
###################### 配置数据库 ######################
echo "开始配置数据库..."
#新建数据库
mysql -uroot -p${passwordRoot} --silent -h ${dbIp} -e "
drop database if exists ${dbName};
create database ${dbName} default character set utf8 collate utf8_general_ci;
set global event_scheduler = 1;
quit"
#删除用户
mysql -uroot -p${passwordRoot} --silent -h ${dbIp} -e "
delete from mysql.user where User='${userName}';
drop user ${userName}@'%';
drop user ${userName}@'localhost';
quit">/dev/null 2>&1
#新建用户
mysql -uroot -p${passwordRoot} --silent -h ${dbIp} -e "
create user '${userName}'@'localhost' identified by '${password}';
create user '${userName}'@'%' identified by '${password}';
quit"
#导入数据库的表
mysql -uroot -p${passwordRoot} -h ${dbIp} -e "
use ${dbName};
source ${serverpath}/script/db/bcos_browser_table.sql;
source ${serverpath}/script/db/bcos_browser_table_v2.sql;
grant all on ${dbName}.* to '${userName}'@'localhost';
grant all on ${dbName}.* to '${userName}'@'%';
grant all on mysql.proc to '${userName}'@'localhost';
grant all on mysql.proc to '${userName}'@'%';
grant execute on procedure ${dbName}.procedure_insert_table_tb_single_stat_by_day to '${userName}'@'localhost';
grant execute on procedure ${dbName}.procedure_insert_table_tb_single_stat_by_day to '${userName}'@'%';
grant execute on procedure ${dbName}.procedure_insert_table_tb_stat_transaction_by_day to '${userName}'@'localhost';
grant execute on procedure ${dbName}.procedure_insert_table_tb_stat_transaction_by_day to '${userName}'@'%';
grant execute on procedure ${dbName}.procedure_insert_table_tb_stat_block_by_day to '${userName}'@'localhost';
grant execute on procedure ${dbName}.procedure_insert_table_tb_stat_block_by_day to '${userName}'@'%';
quit"
###################### 配置server ######################
# execute sql end
set -e
echo "开始配置server...."
echo "
db.ip=${dbIp}
db.user=${userName}
db.password=${password}
db.database=${dbName}
db.port=3306
db.initialSize=10
db.minIdle=0
db.maxActive=100
db.maxWait=10000
db.timeBetweenEvictionRunsMillis=60000
db.minEvictableIdleTimeMillis=300000
startTrigger.schedule.time=0/3 * * * * ?
blockInfoTrigger.schedule.time=0/5 * * * * ?
pendingTransTrigger.schedule.time=0/1 * * * * ?
NodeInfoTrigger.schedule.time=0/5 * * * * ?
" > ${serverpath}/src/main/resources/application.properties
#server gradle build and cp
echo "gradle build start"
echo "${serverpath}"
cd ${serverpath}
gradle build
#sudo rm ${deployserverpath}/bcos-server* -rf
#sudo cp "${serverpath}/bcos-server/apps/bcos-server.war" "${deployserverpath}"
###################### 配置page ######################
#page gradle build and cp
cd ${pagepath}
echo "开始配置page...."
echo "
jdbc_driverClassName = com.mysql.jdbc.Driver
jdbc_initialSize = 5
jdbc_maxActive = 20
jdbc_minIdle = 5
jdbc_maxIdle = 5
jdbc_maxWait = 60000
jdbc_url = jdbc:mysql://${dbIp}/${dbName}
jdbc_username = ${userName}
jdbc_password = ${password}
" > ${pagepath}/src/main/resources/jdbc.properties
echo "${pagepath}"
gradle build
#sudo rm ${deployserverpath}/fisco-bcos-browser* -rf
#sudo cp "${pagepath}/dist/apps/fisco-bcos-browser.war" "${deployserverpath}"
echo "gradle build end"
###################### 启动tomcat ######################
echo "开始部署浏览器应用..."
cd ${startbroswer}
#set +e && sudo sh shutdown.sh && set -e
sudo rm ${deployserverpath}/fisco-bcos-server* -rf
sudo cp "${serverpath}/fisco-bcos-server/apps/fisco-bcos-server.war" "${deployserverpath}"
sudo rm ${deployserverpath}/fisco-bcos-browser* -rf
sudo cp "${pagepath}/dist/apps/fisco-bcos-browser.war" "${deployserverpath}"
sudo sh startup.sh
echo "部署成功!请继续在每台机器上部署report脚本。"
exit;