forked from inuits/monitoring-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·73 lines (61 loc) · 2.94 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
#!/bin/bash
## Script: build.sh
## Version: 0.1.4
## Date: 2014-01-31
## Author: Tom De Vylder <tomdv@inuits.eu>
## Contrib:
set -e -x
rm -rf *.deb
rm -rf *.rpm
if [ -z "${GIT_PREVIOUS_COMMIT}" ] && [ -e last_success ]
then
GIT_PREVIOUS_COMMIT=$(cat last_success)
fi
for PLUGIN in $(grep -viE '^#|^$' build.txt | awk {'print $1'} | sort | uniq )
do
PLUGIN_NAME_DEBIAN=$(echo ${PLUGIN} | sed -e 's/check_/check-/g' | cut -d '.' -f 1)
PLUGIN_NAME_RHEL=$(echo ${PLUGIN} | sed -e 's/check_//g' | cut -d '.' -f 1)
PLUGIN_VERSION=$(grep -E "^${PLUGIN}\s" build.txt | awk {'print $2'})
PLUGIN_ITERATION=$(git rev-list HEAD -- "${PLUGIN}" | wc -l)
PLUGIN_EPOCH=1
echo -e "\e[1;34m[\e[00m --- \e[00;32mBuild package: ${PLUGIN}\e[00m --- \e[1;34m]\e[00m"
# Enforce permissions
chmod 755 ${PLUGIN}
# Build Debian 5/6 package
fpm -s dir -t deb --architecture all \
-n nagios-plugin-${PLUGIN_NAME_DEBIAN} \
-v ${PLUGIN_VERSION} --iteration ${PLUGIN_ITERATION} --epoch $PLUGIN_EPOCH \
--prefix /usr/lib/nagios/plugins \
--description "Nagios Plugin - ${PLUGIN_NAME_DEBIAN}" \
${PLUGIN} &>/dev/null
cp nagios-plugin-${PLUGIN_NAME_DEBIAN}_${PLUGIN_VERSION}-${PLUGIN_ITERATION}_all.deb packages/debian/5/
mv nagios-plugin-${PLUGIN_NAME_DEBIAN}_${PLUGIN_VERSION}-${PLUGIN_ITERATION}_all.deb packages/debian/6/
# Build RHEL 5/6 i386 package
setarch i386 fpm -s dir -t rpm --architecture i386 \
-n nagios-plugins-${PLUGIN_NAME_RHEL} \
-v ${PLUGIN_VERSION} --iteration ${PLUGIN_ITERATION} --epoch $PLUGIN_EPOCH \
--prefix /usr/lib64/nagios/plugins \
--description "Nagios Plugin - ${PLUGIN}" \
${PLUGIN} &>/dev/null
cp nagios-plugins-${PLUGIN_NAME_RHEL}-${PLUGIN_VERSION}-${PLUGIN_ITERATION}.i386.rpm packages/rhel/5/
mv nagios-plugins-${PLUGIN_NAME_RHEL}-${PLUGIN_VERSION}-${PLUGIN_ITERATION}.i386.rpm packages/rhel/6/
# Build RHEL 5/6 i686 package
setarch i686 fpm -s dir -t rpm --architecture i686 \
-n nagios-plugins-${PLUGIN_NAME_RHEL} \
-v ${PLUGIN_VERSION} --iteration ${PLUGIN_ITERATION} --epoch $PLUGIN_EPOCH \
--prefix /usr/lib64/nagios/plugins \
--description "Nagios Plugin - ${PLUGIN}" \
${PLUGIN} &>/dev/null
cp nagios-plugins-${PLUGIN_NAME_RHEL}-${PLUGIN_VERSION}-${PLUGIN_ITERATION}.i686.rpm packages/rhel/5/
mv nagios-plugins-${PLUGIN_NAME_RHEL}-${PLUGIN_VERSION}-${PLUGIN_ITERATION}.i686.rpm packages/rhel/6/
# Build RHEL 5/6 x86_64 package
setarch x86_64 fpm -s dir -t rpm --architecture x86_64 \
-n nagios-plugins-${PLUGIN_NAME_RHEL} \
-v ${PLUGIN_VERSION} --iteration ${PLUGIN_ITERATION} --epoch $PLUGIN_EPOCH \
--prefix /usr/lib64/nagios/plugins \
--description "Nagios Plugin - ${PLUGIN}" \
${PLUGIN} &>/dev/null
cp nagios-plugins-${PLUGIN_NAME_RHEL}-${PLUGIN_VERSION}-${PLUGIN_ITERATION}.x86_64.rpm packages/rhel/5/
mv nagios-plugins-${PLUGIN_NAME_RHEL}-${PLUGIN_VERSION}-${PLUGIN_ITERATION}.x86_64.rpm packages/rhel/6/
done
git rev-parse HEAD > last_success