forked from tbartelmess/NRPE-OSX
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_package.sh
executable file
·110 lines (87 loc) · 2.37 KB
/
build_package.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
#!/usr/bin/env zsh
NRPE_DOWNLOAD_URL=http://softlayer-ams.dl.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.15/nrpe-2.15.tar.gz
PLUGINS_DOWNLOAD_URL=https://www.nagios-plugins.org/download/nagios-plugins-1.5.tar.gz
WORKING_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
BUILD_DIR="${WORKING_DIR}/build"
PACKAGE_MAKER=""
echo "\n"
function find_packages() {
echo -n "Looking for Packages... "
which packagesbuild > /dev/null
if [[ $? == 0 ]]; then
echo "OK"
else
echo "Did not find Packages."
echo "Please download Packages from http://s.sudre.free.fr/Software/Packages/ and install it"
exit 1
fi
}
function check_preconditions() {
echo "Checking Preconditions"
echo "======================"
find_packages
if [ -d "$BUILD_DIR" ]; then
echo -n "Cleaning build directory... "
rm -rf "$BUILD_DIR"
print_status
fi
echo -n "Create Build directory... "
print_status
mkdir -p "$BUILD_DIR"
echo "\n\n"
}
function print_status () {
STATUS=$?
if [[ $STATUS != 0 ]]; then
echo "ERROR"
else
echo "OK"
fi
}
function build_nrpe() {
echo "Building NRPE"
echo "================"
cd "$BUILD_DIR"
echo -n "Downloading... "
curl -L $NRPE_DOWNLOAD_URL > nrpe.tar.gz 2> nrpe-download-err.log
print_status
tar xfvz nrpe.tar.gz 2> nrpe-unpack.log
mv nrpe-2.15 nrpe
cd "$BUILD_DIR/nrpe"
echo -n "Configuring NRPE... "
./configure --enable-command-args > "../configure.log" 2>&1
print_status
echo -n "Build NRPE... "
make > "../build.log" 2>&1
print_status
echo "\n\n"
}
function build_nagios_plugins() {
echo "Building Nagios Plugins"
echo "=========================="
cd "$BUILD_DIR"
echo -n "Downloading... "
curl $PLUGINS_DOWNLOAD_URL > plugins.tar.gz 2> plugins-download-err.log
print_status
echo -n "Unpacking... "
tar xfvz plugins.tar.gz 2> plugins-unpack.log
print_status
mv nagios-plugins-1.5 nagios-plugins
cd nagios-plugins
echo -n "Configuring Nagios Plugins... "
./configure > "../plugins-configure.log" 2>&1
print_status
echo -n "Build Nagios Plugins... "
make > "../plugins-build.log" 2>&1
print_status
echo
}
function build_package() {
echo "Building Package"
echo "================"
packagesbuild "${WORKING_DIR}/NRPE.pkgproj"
}
check_preconditions
build_nagios_plugins
build_nrpe
build_package