forked from ixre/go2o
-
Notifications
You must be signed in to change notification settings - Fork 0
/
go2o-publish.sh
executable file
·98 lines (88 loc) · 2.76 KB
/
go2o-publish.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
#!/bin/bash
### ### ### ###
# # ## # # ##
# # # # # #
# # # # ## # #
# # # # # # #
### ### ### ###
goos=linux
arch=amd64
server="127.0.0.1"
ssh_port=22
user=root
root_user=root
app_dir="/data/www/go2o/"
package_name="go2o-update.tar.gz"
zip_bin="go2o-serve go2o-tcpserve master-serve go2o-rpc"
zip_res="public mobile conf/query uploads/res go2o.sh"
boot_sh="sudo ./go2o.sh -s restart"
echo "--------------------------------"
echo "*** GO2O PUBLISH SCRIPT ***"
echo "--------------------------------"
echo " Select publish target environment:"
echo " 1): Development"
echo " 2): Nightly & Beta"
echo " 3): Release"
echo "--------------------"
# select publish environment
while true
do
echo -n "select : " && read env
case ${env} in
1) echo "Selected : Development"
### init development env
break;;
2) echo "Selected : Nightly & Beta"
### init beta env
break;;
3) echo "Selected : Release"
### init release env
break;;
\?)
echo "Please retype correct index:";;
esac
done
echo ""
echo "[ Setup 1 ]: compile program..."
echo -n "Please confirm compile [Y/N]: "
read compile
if [[ ${compile} = "Y" ]] || [[ ${compile} = "y" ]];then
echo "compiling ..."
CGO_ENABLED=0 GOOS=${goos} GOARCH=${arch} go build -ldflags "-w" go2o-serve.go
CGO_ENABLED=0 GOOS=${goos} GOARCH=${arch} go build -ldflags "-w" go2o-tcpserve.go
CGO_ENABLED=0 GOOS=${goos} GOARCH=${arch} go build -ldflags "-w" master-serve.go
CGO_ENABLED=0 GOOS=${goos} GOARCH=${arch} go build -ldflags "-w" go2o-rpc.go
#CGO_ENABLED=0 GOOS=${goos} GOARCH=${arch} go build -ldflags "-w" merchant-serve.go
#CGO_ENABLED=0 GOOS=${goos} GOARCH=${arch} go build -ldflags "-w" pub-serve.go
else
echo " skipping compile" && echo ""
fi
echo "[ Setup 2 ]: zipping tar package ..." && sleep 1
# include config folder
echo -n "Include ""conf"" folder [Y/N]: "
read zipConf
if [[ ${zipConf} = "Y" ]] || [[ ${zipConf} = "y" ]];then
zip_res=${zip_res}" conf/core"
else
echo " skipping conf folder" && echo ""
fi
# include static folder
echo -n "Include ""static"" folder [Y/N]: "
read zipStatic
if [[ ${zipStatic} = "Y" ]] || [[ ${zipStatic} = "y" ]];then
zip_res=${zip_res}" static"
else
echo " skipping static folder" && echo ""
fi
# zip files
zip_res=${zip_bin}" "${zip_res}
tar cvzf ../${package_name} ${zip_res}
echo "[ Setup 3 ]: upload tar package to server ..."
scp ../${package_name} ${user}@${server}:${app_dir}
echo "[ Setup 4 ]: restart server"
ssh -t -p ${ssh_port} ${root_user}@${server} \
"cd ${app_dir} && tar xvzf ${package_name} && ${boot_sh}"
echo "[ Setup 5 ]: cleaning ..."
rm ${zip_bin} ../${package_name}
echo "Configurations, publish successfully!"
exit 0