forked from ConSol-Monitoring/omd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
omd.spec.in
168 lines (150 loc) · 5.48 KB
/
omd.spec.in
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
Summary: OMD Labs Edition - OpenSource Monitoring Distribution (Labs Edition)
Name: omd-%{version}
Version: SET BY MAKEFILE
Release: SET BY MAKEFILE
License: GPL
URL: http://labs.consol.de/omd/
Group: Application/System
Source: %{name}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
AutoReq: off
AutoProv: off
Provides: omd
Requires:
#%define _missing_doc_files_terminate_build 0
#%define _unpackaged_files_terminate_build 0
# disable binary striping
%global __os_install_post %{nil}
# disable creating debug packages
%global debug_package %{nil}
%description
Open Source Monitoring Distribution (Labs Edition),
containing Nagios3 and Naemon, Icinga1 and Icinga 2, Shinken,
Thruk, Mod-Gearman, Nagvis, PNP4Nagios and many more...
Maintained by http://labs.consol.de/omd/.
%prep
%setup -q -n omd-%{version}
%build
make -j 4
make pack
%install
mkdir -p $RPM_BUILD_ROOT
tar xzf omd-bin-%{version}.tar.gz -C $RPM_BUILD_ROOT
# Remove all global symbolic links from package. They are shared
# among all versions and must be handled in %post und %postun
# in order to avoid RPM conflicts
rm -f $RPM_BUILD_ROOT/opt/omd/versions/default
rm -f $RPM_BUILD_ROOT/omd
rm -f $RPM_BUILD_ROOT/usr/bin/omd
rm -f $RPM_BUILD_ROOT/usr/share/man/man8/omd.8.gz
rm -f $RPM_BUILD_ROOT/@APACHE_CONFDIR@/*
rm -f $RPM_BUILD_ROOT/etc/init.d/omd
%files
%defattr(-,root,root)
/opt/omd
%attr(4750,root,omd) /opt/omd/versions/%{version}/lib/nagios/plugins/check_icmp
%attr(4750,root,omd) /opt/omd/versions/%{version}/lib/nagios/plugins/check_dhcp
%attr(4750,root,omd) /opt/omd/versions/%{version}/bin/mkeventd_open514
%pre
groupadd -r omd 2>/dev/null || true
# create symlink if not exists
if [ ! -e /omd ]
then
ln -sfn /opt/omd /omd
fi
%post
# Activate init script for OMD, but only the first
# time an OMD package is being installed. The admin
# might have deactivated the script himself and does
# not want to make it implicitely active again.
ACTIVATE_INIT=0
if [ ! -e /omd/versions/default ] ; then
echo "Activating init script /etc/init.d/omd"
ACTIVATE_INIT=1
fi
echo "New default version is %{version}."
ln -sfn "%{version}" /omd/versions/default
ln -sfn /omd/versions/default/bin/omd /usr/bin/omd
ln -sfn /omd/versions/default/share/man/man8/omd.8.gz /usr/share/man/man8/omd.8.gz
ln -sfn /omd/versions/default/share/omd/omd.init /etc/init.d/omd
ln -sfn /omd/versions/default/share/omd/apache.conf @APACHE_CONFDIR@/zzz_omd.conf
# If the init script has been marked as to be activated
# really activate the init script now
if [ $ACTIVATE_INIT -eq 1 ]; then
chkconfig --add omd
chkconfig omd on
fi
# SLES: make sure apache modules are activated
if which a2enmod >/dev/null 2>&1
then
echo "Makeing sure that Apache modules proxy, http_proxy and rewrite are activated."
a2enmod proxy 2>/dev/null || true
a2enmod proxy_http 2>/dev/null || true
a2enmod rewrite 2>/dev/null || true
%if 0%{?suse_version} > 1200
# Only relevant for SLES12 or newer (having apache 2.4)
# This still allows old permission configs like "Order: ..."
a2enmod mod_access_compat 2>/dev/null || true
a2enmod ssl 2>/dev/null || true
a2enmod socache_shmcb 2>/dev/null || true
a2enflag SSL 2>/dev/null || true
# prepare ssl webserver
if ! test -f /etc/apache2/vhosts.d/vhost-ssl.conf && ! test -f /etc/apache2/ssl.key/server.key; then
cp /etc/apache2/vhosts.d/vhost-ssl.template /etc/apache2/vhosts.d/vhost-ssl.conf
openssl req -new -config /omd/versions/%{version}/share/omd/openssl.cnf -keyout /etc/apache2/privkey.pem -batch > /etc/apache2/ssl.csr/omd.csr 2>/dev/null
openssl rsa -in /etc/apache2/privkey.pem -out /etc/apache2/ssl.key/server.key -passin pass:selfsigned 2> /dev/null
openssl x509 -in /etc/apache2/ssl.csr/omd.csr -out /etc/apache2/ssl.crt/server.crt -req -signkey /etc/apache2/ssl.key/server.key -days 3650 2> /dev/null
fi
%endif
fi
# SLES: make sure that the following file exists:
if [ -d /etc/apache2/sysconfig.d ]
then
touch /etc/apache2/sysconfig.d/include.conf
fi
# Make sure, global apache startscript is activated
chkconfig --add @APACHE_NAME@ >/dev/null 2>&1
chkconfig @APACHE_NAME@ on >/dev/null 2>&1
# ensure apache is running
service @APACHE_NAME@ start >/dev/null 2>&1
exit 0
%preun
# ON UNINSTALL: Make sure no sites use that version
# Do not check this on new release of the same OMD version
# (I know this has not happend yet in official releases, but might
# happen in future? At least I had such a case with my own builds now.)
if [ $1 = 0 ] ; then
for link in /omd/sites/*/version
do
target=$(readlink $link 2>/dev/null) || continue
version=${target##*/}
if [ "$version" = %{version} ]
then
site=${link#/omd/sites/}
site=${site%/version}
echo "Site $site is still using this version!" >&2
exit 1
fi
done
fi
%postun
rm -f /omd/versions/default
v=$(ls -A /omd/versions 2>/dev/null| sort -n | tail -n 1)
if [ -n "$v" ]
then
echo "New default version is $v"
ln -sfn "$v" /omd/versions/default
else
echo "Removing system group 'omd'"
groupdel omd
echo "Removing global symbolic links"
rm -f /usr/bin/omd
rm -f /usr/share/man/man8/omd.8.gz
rm -f /etc/init.d/omd
rmdir /opt/omd/versions
rm -f @APACHE_CONFDIR@/zzz_omd.conf
rm -f /omd
# Try to remove empty directories
rmdir /opt/omd/sites 2>/dev/null || true
rmdir /opt/omd 2>/dev/null || true
fi