-
Notifications
You must be signed in to change notification settings - Fork 388
/
build.sh
executable file
·186 lines (155 loc) · 5.12 KB
/
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
update_submodules()
{
# 拉取所有子模块代码更新
git submodule update --remote
echo "update submodules done"
}
build_image()
{
if [ -z "$version" ];then
echo "invalid version($version)"
exit 0
else
echo "Docker Image Version = nabula:$version"
docker build -t nebula:$version .
fi
}
build_apps()
{
cd src/
echo "======install threathunter_common_java v1.0.1 ======"
cd java_lib/threathunter_common_java/1.0.1/ && mvn clean install -Dmaven.test.skip=true && cd ../../../
echo "======install threathunter_common_java v1.0.2 ======"
cd java_lib/threathunter_common_java/1.0.2/ && mvn clean install -Dmaven.test.skip=true && cd ../../../
echo "======install threathunter_common_java v1.0.3 ======"
cd java_lib/threathunter_common_java/1.0.3/ && mvn clean install -Dmaven.test.skip=true && cd ../../../
echo "======install threathunter_common_java v1.1.0 ======"
cd java_lib/threathunter_common_java/1.1.0/ && mvn clean install -Dmaven.test.skip=true && cd ../../../
echo "====== install babel_java v1.1.0======"
cd java_lib/babel_java && mvn clean install -Dmaven.test.skip=true && cd ../../
echo "====== install threathunter_basictools_java v1.1.0 ======"
cd java_lib/threathunter_basictools_java/ && mvn clean install -Dmaven.test.skip=true && cd ../../
echo "====== install greatdant ======"
cd greatdant && mvn clean install -Dmaven.test.skip=true && cd ../
echo "====== install labrador ======"
cd labrador && mvn clean install -Dmaven.test.skip=true && cd ../
echo "====== install apiserver ======"
cd apiserver && mvn clean install -Dmaven.test.skip=true && cd ../
echo "====== offline ======"
cd offline && mvn clean install -Dmaven.test.skip=true -P prod && cd ../
echo "====== install greyhound ======"
cd greyhound && mvn clean install -Dmaven.test.skip=true && cd ../
echo "====== install online ======"
cd online && mvn clean install -Dmaven.test.skip=true && cd ../
cd BChart
echo "====== package BChart ======"
mv .git .git.bak
npm install
npm run install && npm pack
rm -rf ./.git && mv .git.bak .git
cd ../
echo "====== package nebula_fe ======"
cp BChart/BChart-1.1.16.tgz nebula_fe && cd nebula_fe
mv .git .git.bak
npm install
npm install BChart-1.1.16.tgz
cd scripts && sh build.sh
cd ../
rm -rf ./.git && mv .git.bak .git
cd ../
echo "====== module copying ======"
# copy java模块
echo "copy java module"
cp offline/target/nebula_offline_slot-prod.tar.gz ../nebula_apps/
cp online/nebula-onlineserver/target/nebula-onlineserver.tar.gz ../nebula_apps/
cp apiserver/web-manager/target/java-web-release.tar.gz ../nebula_apps/
cp labrador/application/target/labrador-release.tar.gz ../nebula_apps/
# copy python模块
echo "copy python module"
cp -r python_lib ../nebula_apps/
cp -r nebula_db_writer ../nebula_apps/
cp -r nebula_query_web ../nebula_apps/
cp -r nebula_web ../nebula_apps/
# copy 前端展示模块
echo "copy javascript module"
cp nebula_fe/build/nebula_fe.tar.gz ../nebula_apps/
cd ../nebula_apps/
echo "====== uncompress ======"
echo "uncompress java-web"
is_exist "java-web"
tar -zxf java-web-release.tar.gz
rm -rf ./java-web-release.tar.gz
echo "uncompress labrador"
is_exist "labrador"
tar -zxf labrador-release.tar.gz
rm -rf ./labrador-release.tar.gz
echo "uncompress nebula-onlineserver"
is_exist "nebula-onlineserver"
tar -zxf nebula-onlineserver.tar.gz
rm -rf ./nebula-onlineserver.tar.gz
echo "uncompress nebula_offline_slot"
is_exist "nebula_offline_slot"
tar -zxf nebula_offline_slot-prod.tar.gz
rm -rf ./nebula_offline_slot-prod.tar.gz
echo "uncompress nebula_fe"
is_exist "nebula_fe"
tar -zxf ./nebula_fe.tar.gz -C ./nebula_fe
rm -rf ./nebula_fe.tar.gz
cd ..
}
is_exist(){
if [ ! -d "$1/" ];then
mkdir $1
else
rm -rf $1 && mkdir $1
fi
}
build_help()
{
echo "Usage:"
echo "-u|--update: update submodules"
echo "-v|--version: version"
echo "--apps: build all apps"
echo "--image: build docker imageps"
echo "--all: build apps and docker image"
}
# first round for config
OLDINPUT=("$*")
while [ -n "$1" ]
do
case "$1" in
-h|--help) build_help; exit 0;;
-u|--update)
update_submodules; shift 1;;
-v|--version)
version=$2; shift 2;;
--apps)
shift 1;;
--image)
shift 1;;
--all)
shift 1;;
*)
echo "invalid options $1"; build_help; exit ;;
esac
done
# second round for commands
set -- $OLDINPUT
while [ -n "$1" ]
do
case "$1" in
-h|--help) build_help; exit 0;;
-u|--update)
shift 1;;
-v|--version)
shift 2;;
--apps)
build_apps; shift 1;;
--image)
build_image; shift 1;;
--all)
build_apps;build_image; shift 1;;
*)
echo "invalid options $1"; build_help; exit ;;
esac
done