forked from FISCO-BCOS/FISCO-BCOS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
start_meshchain.sh
153 lines (123 loc) · 3.73 KB
/
start_meshchain.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
#!/bin/sh
ethName="fisco-bcos"
function deployContractAndStart()
{
if [ ! -d ./systemcontractv2 ];then
echo "目录 ./systemcontractv2 不存在"
exit
fi
if [ ! -d ./tool ];then
echo "目录 ./tool 不存在"
exit
fi
for node in `ls | grep "node_"`
do
#start eth
cd $node
chmod a+x fisco-solc
dir=`pwd`
export PATH=${PATH}:${dir}
port=`grep "\"rpcport\":\"[0-9]\+\"" config.json | grep -o "[0-9]\+"`
if [ ${port}"" = "" ];then
echo "not found rpcport in ${node}/config.json"
exit
fi
pid=`lsof -i :${port} | grep "${port}" | awk '{print $2}'`
if [ ${pid}"" != "" ];then
echo "${ethName} is running.pid:${pid},kill it and start."
kill ${pid}
fi
sh -c "setsid ./${ethName} --config config.json --genesis genesis.json >> .stdout 2>&1 &"
cd ..
done
sleep 3
ip=`grep "listenip" node_1/config.json | grep -o "[0-9]\+.[0-9]\+.[0-9]\+.[0-9]\+"`
port=`grep "rpcport" node_1/config.json | grep -o "[0-9]\+"`
if [ ${ip}"" = "" ];then
echo "node_1/config.json listenip not match"
exit
fi
if [ ${port}"" = "" ];then
echo "node_1/config.json rpcport not match"
exit
fi
sed -i "s/127.0.0.1:[0-9]\+/${ip}:${port}/g" ./systemcontractv2/config.js
babelNode=`which babel-node`
if [ ${babelNode}"" = "" ];then
echo "babel-node not in PATH."
exit
fi
cd systemcontractv2
if [ ! -d ./node_modules ];then
npm=`which npm`
if [ ${npm}"" = "" ];then
echo "npm not found in PATH"
exit
fi
npm install
fi
babel-node deploy.js > .contract.address
if [ ! $? = 0 ];then
echo "deploy system contract failed"
exit
fi
systemContractAddress=`grep "系统代理合约:" .contract.address | awk -F ":" '{print $2}'`
if [ ${systemContractAddress}"" = "" ];then
echo "get system address failed"
exit
fi
rm .contract.address
cd ..
for node in `ls | grep "node_"`
do
cd $node
sysOld='"systemproxyaddress":"0x0"'
sysNew="\"systemproxyaddress\":\""${systemContractAddress}"\""
sed -i "s/${sysOld}/${sysNew}/g" config.json
match=`grep ${sysOld} config.json | wc -l`
if [ !${match} = 0 ];then
echo "replace system address failed."
exit
fi
port=`grep "\"rpcport\":\"[0-9]\+\"" config.json | grep -o "[0-9]\+"`
if [ ${port}"" = "" ];then
echo "not found rpcport in ${node}"
exit
fi
pid=`lsof -i :${port} | grep "${port}" | awk '{print $2}'`
if [ ${pid}"" != "" ];then
echo "start to kill ${ethName} pid:${pid} and start"
kill ${pid}
fi
sh -c "setsid ./${ethName} --config config.json --genesis genesis.json >> .stdout 2>&1 &"
cd ..
done
#wait for eth init
sleep 3
cd tool
if [ ! -d ./node_modules ];then
cp ../systemcontractv2/node_modules ./ -R
fi
cp ../systemcontractv2/config.js ./
echo "deploy Meshchain.sol start..."
babel-node deploy.js Meshchain
if [ ! $? = 0 ];then
echo "deploy Meshchain.sol contract failed"
exit
fi
babel-node abi_name_service_tool.js list > .abilist
if [ -f .abilist ];then
ifDeploy=`grep 'Meshchain' .abilist | wc -l`
if [ ${ifDeploy} = "0" ];then
babel-node abi_name_service_tool.js add Meshchain
else
babel-node abi_name_service_tool.js update Meshchain
fi
rm .abilist
echo "deploy Meshchain.sol success..."
else
echo "not found .abilist file"
exit
fi
}
deployContractAndStart