forked from minimum-hsu/docker-openfalcon-build
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathopenfalcon-build.sh
executable file
·202 lines (178 loc) · 3.87 KB
/
openfalcon-build.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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
#!/bin/bash
export REMOTE=origin
export BRANCH=master
export WORKDIR=Cepave
export GITHUB=$GOPATH/src/github.com
export WORKPATH=$GITHUB/$WORKDIR
#######################################
# Download Source Code
#######################################
rm -fR $GITHUB
mkdir -p $WORKPATH
git clone --quiet -b master https://github.com/Cepave/open-falcon.git $WORKPATH
cd $WORKPATH && git submodule update --quiet --remote --init \
&& git submodule foreach --quiet git checkout -f $REMOTE/$BRANCH \
&& git submodule foreach --quiet git submodule update --quiet --remote --init
#######################################
# Parse Arguments
#######################################
for arg in "$@" ; do
case $arg in
"agent")
export BUILD_AGENT=true
;;
"graph")
export BUILD_GRAPH=true
;;
"query")
export BUILD_QUERY=true
;;
"dashboard")
export BUILD_DASHBOARD=true
;;
"sender")
export BUILD_SENDER=true
;;
"link")
export BUILD_LINKS=true
;;
"links")
export BUILD_LINKS=true
;;
"portal")
export BUILD_PORTAL=true
;;
"hbs")
export BUILD_HBS=true
;;
"alarm")
export BUILD_ALARM=true
;;
"fe")
export BUILD_FE=true
;;
"judge")
export BUILD_JUDGE=true
;;
"transfer")
export BUILD_TRANSFER=true
;;
"task")
export BUILD_TASK=true
;;
"nodata")
export BUILD_NODATA=true
;;
"aggregator")
export BUILD_AGGREGATOR=true
;;
"all")
export BUILD_AGENT=true
export BUILD_GRAPH=true
export BUILD_QUERY=true
export BUILD_DASHBOARD=true
export BUILD_SENDER=true
export BUILD_LINKS=true
export BUILD_PORTAL=true
export BUILD_HBS=true
export BUILD_ALARM=true
export BUILD_FE=true
export BUILD_JUDGE=true
export BUILD_TRANSFER=true
export BUILD_TASK=true
export BUILD_NODATA=true
export BUILD_AGGREGATOR=true
;;
*)
echo -e "Specify one component to build:\nagent\ngraph\nquery\ndashboard\nsender\nlinks\nportal\nhbs\nalarm\nfe\njudge\ntransfer\ntask\nnodata\naggregator"
exit 1
;;
esac
done
#######################################
# Build, Package, Rename and Collect
#######################################
export PACKDIR=/package
export LOGFILE=$PACKDIR/filelist.txt
rm -fR $PACKDIR
mkdir -p $PACKDIR
function _build() {
cd $WORKPATH/$1
go get ./...
if [ "$2" = "do_build" ] ; then
./control build
fi
./control pack
export PACKFILE=$(find -name "*$1*.gz")
export NEWFILE="$(echo ${PACKFILE##*/} | sed -e 's/-[.[:alnum:]]*\.tar.gz/.tar.gz/')"
mv $PACKFILE $PACKDIR/$NEWFILE && \
echo "Success... $NEWFILE" && \
echo $PACKFILE >> $LOGFILE
}
function build() {
_build $1 do_build
}
function pack() {
_build $1 do_pack
}
# Agent
if [ ! -z $BUILD_AGENT ] && $BUILD_AGENT ; then
build agent
fi
# Graph
if [ ! -z $BUILD_GRAPH ] && $BUILD_GRAPH ; then
export GODEBUG=cgocheck=0
build graph
fi
# Query
if [ ! -z $BUILD_QUERY ] && $BUILD_QUERY ; then
build query
fi
# Dashboard
if [ ! -z $BUILD_DASHBOARD ] && $BUILD_DASHBOARD ; then
pack dashboard
fi
# Sender
if [ ! -z $BUILD_SENDER ] && $BUILD_SENDER ; then
build sender
fi
# Links
if [ ! -z $BUILD_LINKS ] && $BUILD_LINKS ; then
pack links
fi
# Portal
if [ ! -z $BUILD_PORTAL ] && $BUILD_PORTAL ; then
pack portal
fi
# Heartbeat Server (HBS)
if [ ! -z $BUILD_HBS ] && $BUILD_HBS ; then
build hbs
fi
# Alarm
if [ ! -z $BUILD_ALARM ] && $BUILD_ALARM ; then
build alarm
fi
# FE
if [ ! -z $BUILD_FE ] && $BUILD_FE ; then
build fe
fi
# Judge
if [ ! -z $BUILD_JUDGE ] && $BUILD_JUDGE ; then
build judge
fi
# Transfer
if [ ! -z $BUILD_TRANSFER ] && $BUILD_TRANSFER ; then
build transfer
fi
# Task
if [ ! -z $BUILD_TASK ] && $BUILD_TASK ; then
build task
fi
# Nodata
if [ ! -z $BUILD_NODATA ] && $BUILD_NODATA ; then
build nodata
fi
# Aggregator
if [ ! -z $BUILD_AGGREGATOR ] && $BUILD_AGGREGATOR ; then
build aggregator
fi