-
Notifications
You must be signed in to change notification settings - Fork 25
/
deploy.sh
executable file
·158 lines (140 loc) · 4.91 KB
/
deploy.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
#!/bin/bash
source ./common/script/common.inc
source run.config
set -e
#SOURCE_CODE_DIR=$(pwd)
applicationFile=${SOURCE_CODE_DIR}/dist/conf/application.properties
port=$(grep "server\.port" $applicationFile |awk -F "=" '{print $2}')
function reloadAddressForWeb() {
export WEB_PID=`ps aux|grep "BuildToolApplication" | grep -v grep|awk '{print $2}'|head -1`
if [ -n "$WEB_PID" ];then
curl http://localhost:${port}/weid/weid-build-tools/reloadAddress
fi
}
function show_address()
{
cd ${SOURCE_CODE_DIR}
if [ ! -f weIdContract.address ];then
echo "deploy contract failed."
exit 1
fi
echo "contract is deployed with success."
echo "===========================================."
weid_address=$(cat weIdContract.address)
echo "weid contract address is ${weid_address}"
cpt_address=$(cat cptController.address)
echo "cpt contract address is ${cpt_address}"
issuer_address=$(cat authorityIssuer.address)
echo "authority issuer contract address is ${issuer_address}"
evidence_address=$(cat evidenceController.address)
echo "evidence contract address is ${evidence_address}"
specificIssuer_address=$(cat specificIssuer.address)
echo "specificIssuer contract address is ${specificIssuer_address}"
echo "===========================================."
echo ""
}
function deploy_contract()
{
echo " "
echo "begin to deploy contract, please wait....."
cd ${SOURCE_CODE_DIR}
#deploy contract to your blockchain nodes
build_classpath
java ${JAVA_OPTS} -cp "$CLASSPATH" com.webank.weid.command.DeployContract --chain-id ${chain_id} $@
if [ ! $? -eq 0 ]; then
echo "deploy contract failed, please check."
exit $?;
fi
#if [ -d ${SOURCE_CODE_DIR}/output/admin ];then
# rm -rf ${SOURCE_CODE_DIR}/output/admin
#fi
#mkdir -p ${SOURCE_CODE_DIR}/output/admin
#the copy action in deploy contract
#mv ecdsa_key.pub ${SOURCE_CODE_DIR}/output/admin
#mv ecdsa_key ${SOURCE_CODE_DIR}/output/admin
rm -f private_key
rm -f public_key
rm -f hash
rm -f weid
}
function deploy_system_cpt()
{
echo "begin to deploy system contract..."
cd ${SOURCE_CODE_DIR}
build_classpath
java ${JAVA_OPTS} -cp "$CLASSPATH" com.webank.weid.command.DeploySystemCpt
if [ ! $? -eq 0 ]; then
echo "deploy system cpt failed, please check."
exit $?;
fi
echo "deploy system cpt done."
}
function clean_data()
{
#delete useless files
cd ${SOURCE_CODE_DIR}
if [ -f weIdContract.address ];then
rm -f weIdContract.address
fi
if [ -f cptController.address ];then
rm -f cptController.address
fi
if [ -f authorityIssuer.address ];then
rm -f authorityIssuer.address
fi
if [ -f evidenceController.address ];then
rm -f evidenceController.address
fi
if [ -f specificIssuer.address ];then
rm -f specificIssuer.address
fi
}
function check_node_cert(){
cd ${SOURCE_CODE_DIR}/resources/conf
if [ "${blockchain_fiscobcos_version}" = "1" ];then
if [ ! -f ca.crt -o ! -f client.keystore ];then
echo "ERROR : fisco bcos version is 1.3, ca.crt and client.keystore are needed."
exit 1
fi
elif [ "${blockchain_fiscobcos_version}" = "2" ];then
if [ "${sm_crypto}" = "0" ];then
if [ ! -f ca.crt -o ! -f sdk.crt -o ! -f sdk.key ];then
echo "ERROR : fisco bcos version is 2.0. encrypt type is ECDSA, ca.crt, sdk.crt and sdk.key are needed."
exit 1
fi
else
if [ ! -f gmca.crt -o ! -f gmsdk.crt -o ! -f gmsdk.key -o ! -f gmensdk.crt -o ! -f gmensdk.key ];then
echo "ERROR : fisco bcos version is 2.0, encrypt type is SM2, gmca.crt, gmsdk.crt, gmsdk.key, gmensdk.crt and gmensdk.key are needed."
exit 1
fi
fi
elif [ "${blockchain_fiscobcos_version}" = "3" ];then
if [ "${sm_crypto}" = "0" ];then
if [ ! -f ca.crt -o ! -f sdk.crt -o ! -f sdk.key ];then
echo "ERROR : fisco bcos version is 3.0. encrypt type is ECDSA, ca.crt, sdk.crt and sdk.key are needed."
exit 1
fi
else
if [ ! -f sm_ca.crt -o ! -f sm_sdk.crt -o ! -f sm_sdk.key -o ! -f sm_ensdk.crt -o ! -f sm_ensdk.key ];then
echo "ERROR : fisco bcos version is 3.0, encrypt type is SM2, sm_ca.crt, sm_sdk.crt, sm_sdk.key, sm_ensdk.crt and sm_ensdk.key are needed."
exit 1
fi
fi
else
echo "the version : ${blockchain_fiscobcos_version} is not supported, we only support FISCO BCOS 1.3 and 2.0."
exit 1
fi
}
function main()
{
check_jdk
check_node_cert
deploy_contract $@
show_address
#modify_config
# deploy systemCpt in deploy contract
#deploy_system_cpt
clean_data
reloadAddressForWeb
}
main $@