-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup-safe.sh
150 lines (129 loc) · 3.51 KB
/
setup-safe.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
#!/bin/bash
function package() {
# clean
rm -rfv chaincode-deploy-service/target/jib-image.tar
rm -rfv bin/chaincode-deploy-service/target/jib-image.tar
log purple "===> mvn clean install -DskipTests=true compile jib:buildTar"
mvn clean install -DskipTests=true compile jib:buildTar
}
function upload() {
log purple "===> scp chaincode-deploy-service/target/jib-image.tar [email protected]:/tmp/jib-image.tar"
scp -v chaincode-deploy-service/target/jib-image.tar [email protected]:/tmp/jib-image.tar
}
function install() {
# clean
log sky_blue "clean docker image & contrain"
log purple "===> docker rm --force fabric-chaincode-deploy"
count=`docker ps --filter 'name=fabric-chaincode-deploy' | wc -l`
if ((count > 0)); then
docker rm --force fabric-chaincode-deploy
fi
log purple "===> docker image rm chaincode/fabric-chaincode-deploy:0.2"
docker image rm chaincode/fabric-chaincode-deploy:0.2
log purple "===> docker load --input jib-image.tar"
docker load --input /tmp/jib-image.tar
}
function up() {
# run
#log purple "===> docker run .... fabric-chaincode-deploy"
#HYPERLEDGER_FABRIC_SDK_COMMONS_CONFIG="produce/fabric-chaincode.properties"
#HYPERLEDGER_FABRIC_SDK_KV_STORE_CONFIG="produce/fabric-kv-store.properties"
#HYPERLEDGER_FABRIC_SDK_COMMONS_NETWORK_HOST=localhost
#docker run -e HYPERLEDGER_FABRIC_SDK_COMMONS_NETWORK_HOST=localhost -it --rm --name fabric-chaincode-deploy chaincode/fabric-chaincode-deploy:0.1
# start
log purple "===> docker-compose -f docker-compose.yaml -f docker-compose-net.yaml up"
docker-compose -f docker-compose.yaml -f docker-compose-net.yaml up
}
function start() {
# start
log purple "===> docker-compose -f docker-compose.yaml -f docker-compose-net.yaml start"
docker-compose -f docker-compose.yaml -f docker-compose-net.yaml start
}
function stop() {
# start
log purple "===> docker-compose -f docker-compose.yaml -f docker-compose-net.yaml stop"
docker-compose -f docker-compose.yaml -f docker-compose-net.yaml stop
}
function log() {
# 字颜色:30—–37
# 字背景颜色范围:40—–47
case $1 in
"red")
echo -e "\033[31m$2\033[0m" # 红色字
;;
"yellow")
echo -e "\033[33m$2\033[0m" # 黄色字
;;
"green")
echo -e "\033[32m$2\033[0m" # 绿色字
;;
"blue")
echo -e "\033[34m$2\033[0m" # 蓝色字
;;
"purple")
echo -e "\033[35m$2\033[0m" # 紫色字
;;
"sky_blue")
echo -e "\033[36m$2\033[0m" # 天蓝字
;;
"white")
echo -e "\033[37m$2\033[0m" # 白色字
;;
"_black")
echo -e "\033[40;37m $2 \033[0m" # 黑底白字
;;
"_red")
echo -e "\033[41;30m $2 \033[0m" # 红底黑字
;;
*)
echo "$2"
;;
esac
}
for opt in "$@"; do
case "$opt" in
package)
package
;;
upload)
upload
;;
publish)
package
log blue "package Done!"
upload
log blue "upload Done!"
;;
install)
install
;;
start)
start
;;
stop)
stop
;;
reup)
docker-compose -f docker-compose.yaml -f docker-compose-net.yaml down
log blue "down Done!"
up
log blue "up Done!"
;;
restart)
stop
log blue "stop Done!"
start
log blue "start Done!"
;;
restore)
install
log blue "install Done!"
up
log blue "up Done!"
;;
*)
echo $"Usage: $0 {package|upload|publish|install|start|stop|reup|restart|restore}"
exit 1
;;
esac
done