-
Notifications
You must be signed in to change notification settings - Fork 54
Expand file tree
/
Copy pathcontrol
More file actions
executable file
·42 lines (37 loc) · 868 Bytes
/
Copy pathcontrol
File metadata and controls
executable file
·42 lines (37 loc) · 868 Bytes
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
#!/bin/bash
# 版本号自动从 Git 标签获取
# 使用方法:git tag v2.2.0 && git push --tags
version=$(git describe --tags --always --dirty 2>/dev/null || echo "dev")
CWD=$(cd $(dirname $0)/; pwd)
cd $CWD
usage()
{
echo $"Usage: $0 {build|pack}"
exit 0
}
build()
{
export CGO_ENABLED=0
go generate
go build -v -ldflags "-X main.version=${version} -X main.buildTime=`date -u '+%Y-%m-%d_%H:%M:%S'` -X main.gitHash=`git rev-parse --short HEAD`" -o zbxtable main.go
}
pack()
{
mkdir -p zbxtable-${version}/conf
cp zbxtable zbxtable-${version}/
cp zbxtable.service zbxtable-${version}/
cp nginx.conf zbxtable-${version}/
cp zbxtable.init zbxtable-${version}/
cp config/app.conf zbxtable-${version}/conf
tar zcvf zbxtable-${version}.tar.gz zbxtable-${version}/
}
case "$1" in
build)
build $2
;;
pack)
pack $2
;;
*)
usage
esac