This repository has been archived by the owner on Mar 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathpackaging_antilles_el7.sh
executable file
·283 lines (231 loc) · 9.17 KB
/
packaging_antilles_el7.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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
#!/bin/bash
# Copyright © 2019-present Lenovo
#
# This file is licensed under both the BSD-3 license for individual/non-commercial use and
# EPL-1.0 license for commercial use. Full text of both licenses can be found in
# COPYING.BSD and COPYING.EPL files.
BASE_PATH=$(cd `dirname $0`; pwd)
RPMBUILD_DIR='/root/rpmbuild'
RPMBUILD_RPM_DIR='/root/rpmbuild/RPMS'
ANTILLES_RPMS_DIR='/opt/antilles_dist_rpms'
###################################################################
# Install EPEL Repo
###################################################################
function install_epel_repo() {
ret=$(yum repolist | grep -P 'epel\/x86_64')
if [[ "${ret}" == "" ]];then
echo "Will install EPEL repo."
yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
else
echo "EPEL Repo already installed."
fi
}
###################################################################
# Packaging antilles-devtool: python-setuptool(39.2.0)
# Cython(0.28.1)
###################################################################
function install_antilles_devtools() {
# build and install python-setuptools
cd ~/rpmbuild/SOURCES
wget https://files.pythonhosted.org/packages/1a/04/d6f1159feaccdfc508517dba1929eb93a2854de729fa68da9d5c6b48fa00/setuptools-39.2.0.zip
cd ${BASE_PATH}/antilles-dep/devtool/CentOS/python-setuptools
rpmbuild --quiet -bb python-setuptools.spec
cd ${RPMBUILD_RPM_DIR}/noarch
yum install -y python2-setuptools-39.2.0*.noarch.rpm
cp python2-setuptools-39.2.0*.noarch.rpm ${ANTILLES_RPMS_DIR}
# build and install Cython
cd ~/rpmbuild/SOURCES
wget https://files.pythonhosted.org/packages/be/08/bb5ffd1c32a951cbc26011ecb8557e59dc7a0a4975f0ad98b2cd7446f7dd/Cython-0.28.1.tar.gz
cd ${BASE_PATH}/antilles-dep/devtool/CentOS/Cython
rpmbuild --quiet -bb Cython.spec
cd ${RPMBUILD_RPM_DIR}/x86_64
yum install -y python2-Cython-0.28.1*.x86_64.rpm
cp python2-Cython-0.28.1*.x86_64.rpm ${ANTILLES_RPMS_DIR}
}
###################################################################
# Packaging antilles-recipe: antilles-prepare
# antilles-rpm-macros
###################################################################
function install_antilles_recipe() {
cd ${BASE_PATH}/antilles-recipe
yum install -y epel-rpm-macros
python setup.py bdist_rpm -q --binary-only
yum install -y dist/antilles-prepare*.noarch.rpm dist/antilles-rpm-macros*.noarch.rpm
cp dist/antilles-prepare*.noarch.rpm dist/antilles-rpm-macros*.noarch.rpm ${ANTILLES_RPMS_DIR}
}
###################################################################
# Packaging antilles-dep: gmond-gpu-module
# nginx-https-config
# novnc
# slapd-ssl-config
###################################################################
function packaging_gmond_gpu_module() {
cd ${BASE_PATH}/antilles-dep/dep/gmond-gpu-module
cp nvidia.py nvidia.pyconf ~/rpmbuild/SOURCES
rpmbuild --quiet -bb gmond-gpu-module.spec
cd ${RPMBUILD_RPM_DIR}/noarch
cp gmond-ohpc-gpu-module*.noarch.rpm ${ANTILLES_RPMS_DIR}
}
function packaging_nginx_https_config() {
cd ${BASE_PATH}/antilles-dep/dep/nginx-https-config
cp https.rhel.conf https.suse.conf nginx-gencert ~/rpmbuild/SOURCES
rpmbuild --quiet -bb nginx-https-config.spec
cd ${RPMBUILD_RPM_DIR}/noarch
cp nginx-https-config*.noarch.rpm ${ANTILLES_RPMS_DIR}
}
function packaging_novnc() {
cd ~/rpmbuild/SOURCES
wget https://github.com/novnc/noVNC/archive/v1.0.0.tar.gz
cd ${BASE_PATH}/antilles-dep/dep/novnc
rpmbuild --quiet -bb novnc.spec
cd ${RPMBUILD_RPM_DIR}/noarch
cp novnc*.noarch.rpm ${ANTILLES_RPMS_DIR}
}
function packaging_slapd_ssl_config() {
cd ${BASE_PATH}/antilles-dep/dep/slapd-ssl-config
cp base.ldif DB_CONFIG slapd-gencert slapd.rhel.conf slapd.suse.conf ~/rpmbuild/SOURCES
rpmbuild --quiet -bb slapd-ssl-config.spec
cd ${RPMBUILD_RPM_DIR}/noarch
cp slapd-ssl-config*.noarch.rpm ${ANTILLES_RPMS_DIR}
}
function packaging_antilles_dep() {
packaging_gmond_gpu_module
packaging_nginx_https_config
packaging_novnc
packaging_slapd_ssl_config
}
###################################################################
# Packaging antilles-alarm agents: mail sms wechat
###################################################################
function packaging_antilles_mail_agent() {
cd ${BASE_PATH}/alarm/antilles-mail-agent
python setup.py bdist_rpm -q --binary-only
cp dist/antilles-mail-agent*.rpm ${ANTILLES_RPMS_DIR}
}
function packaging_antilles_sms_agent() {
cd ${BASE_PATH}/alarm/antilles-sms-agent
python setup.py bdist_rpm -q --binary-only
cp dist/antilles-sms-agent*.rpm ${ANTILLES_RPMS_DIR}
}
function packaging_antilles_wechat_agent() {
cd ${BASE_PATH}/alarm/antilles-wechat-agent
python setup.py bdist_rpm -q --binary-only
cp dist/antilles-wechat-agent*.rpm ${ANTILLES_RPMS_DIR}
}
function packaging_antilles_alarm() {
packaging_antilles_mail_agent
packaging_antilles_sms_agent
packaging_antilles_wechat_agent
}
###################################################################
# Packaging antilles-tools
# antilles-core
# antilles-portal
# antilles-confluent-proxy
# antilles-env
###################################################################
function packaging_antilles_main_module() {
# nodejs for antilles-portal
yum install -y nodejs
for antilles_module in antilles-tools antilles-core antilles-portal antilles-confluent-proxy antilles-env
do
cd ${BASE_PATH}/${antilles_module}
python setup.py bdist_rpm -q --binary-only
cp dist/${antilles_module}*.rpm ${ANTILLES_RPMS_DIR}
done
}
###################################################################
# Packaging antilles-monitor
###################################################################
function packaging_antilles_monitor() {
# For suse
# yum install -y nagios-rpm-macros
for monitor_module in antilles-confluent-mond antilles-ganglia-mond antilles-icinga-mond antilles-icinga-plugin antilles-vnc-mond antilles-vnc-proxy
do
cd ${BASE_PATH}/monitor/${monitor_module}
python setup.py bdist_rpm -q --binary-only
cp dist/${monitor_module}*.rpm ${ANTILLES_RPMS_DIR}
done
}
###################################################################
# Create antilles-repo
###################################################################
function config_nginx_for_antilles_repo() {
## install nginx for intranet yum repo
yum install -y nginx
systemctl start nginx
cat << EOF > /etc/nginx/conf.d/antilles_repo_server.conf
server {
listen 8090;
server_name ${sms_ip};
root ${ANTILLES_RPMS_DIR};
location / {
autoindex on;
autoindex_exact_size off;
autoindex_localtime on;
}
}
EOF
systemctl stop nginx
nginx -s stop
nginx
}
function create_antilles_repo() {
## create antilles repo
yum install -y createrepo
cd ${ANTILLES_RPMS_DIR}
createrepo ./
cat << EOF > /etc/yum.repos.d/antilles_base.repo
[antilles-base]
name=antilles-base(el7)
baseurl=http://${sms_ip}:8090/
gpgcheck=0
enabled=1
EOF
yum clean all
yum makecache
}
###################################################################
# Packaging Antilles Main Function
###################################################################
# Clear Packaging directories
echo "WARNING: The following directories will be removed permanently."
echo "${RPMBUILD_DIR} ${ANTILLES_RPMS_DIR}"
read -p "Do you want to Continue[Y/N]?" answer
if [[ "${answer}" != "Y" ]] && [[ "${answer}" != "y" ]];then
exit 0
fi
rm -rf ${RPMBUILD_DIR} ${ANTILLES_RPMS_DIR}
yum install -y rpmdevtools wget gcc gcc-c++ python2-devel fdupes
mkdir -p ${ANTILLES_RPMS_DIR}
# setup rpmbuild directories
rpmdev-setuptree
install_epel_repo
#
# devtools and recipe are required by other antilles modules
#
install_antilles_devtools # Include: python-setuptool Cython
install_antilles_recipe # Include: antilles-prepare antilles-rpm-macros
packaging_antilles_dep # Include: gmond-gpu-module nginx-https-config novnc slapd_ssl_config
packaging_antilles_alarm # Include: mail-agent sms-agent wechat-agent
packaging_antilles_main_module # Include: antilles-tools antilles-core antilles-portal antilles-confluent-proxy antilles-env
packaging_antilles_monitor # Include confluent-mond ganglia-mond icinga-mond icinga-plugin vnc-mond vnc-proxy
# Get current host ip for antillse repo
confirm=0
while [[ "${confirm}" != "Y" && "${confirm}" != "y" ]]
do
read -p "Please enter the currnet host IP: " sms_ip
read -p "Confirm current host IP is ${sms_ip}? [Y/N] " confirm
echo ${confirm}
done
config_nginx_for_antilles_repo
create_antilles_repo
echo
echo "Packaging Antilles finished."
echo "
=======================================================================
You can find all Antilles RPMs packages under ${ANTILLES_RPMS_DIR}
Antilles repo file locates /etc/yum.repos.d/antilles_base.repo
You could distribute antiles repo file to other nodes in the cluster.
Then you could install antilles module by yum.
"