Refactoring: Moved check parameters from unsorted.py to dedicated modules (CMK-1393)
[check_mk.git] / omd / omd.spec.in
blob27f2879e9a95a4d63dcc7f3ca5b57537c056b375
1 Summary: Check_MK
2 Name: check-mk-%{edition}-%{pkg_version}
3 Version: SET BY MAKEFILE
4 Release: SET BY MAKEFILE
5 License: GPL
6 URL: http://mathias-kettner.com
7 Group: Application/System
8 Source: check-mk-%{edition}-%{version}.tar.gz
9 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
10 AutoReq: off
11 AutoProv: off
12 Provides: omd
13 Requires:
15 #%define _missing_doc_files_terminate_build 0
16 #%define _unpackaged_files_terminate_build 0
17 # disable binary striping
18 %global __os_install_post %{nil}
19 # disable creating debug packages
20 %global debug_package %{nil}
23 %description
24 Check_MK is a full featured system monitoring
25 solution. This package ships with Check_MK, Nagios,
26 the Nagios plugins, Livestatus, Multisite,
27 PNP4Nagios, NagVis, and other addons. Please visit
28 http://mathias-kettner.com/.
30 %prep
31 %setup -q -n check-mk-%{edition}-%{version}
33 %build
34 cd omd
35 make -j 4
36 make pack
38 %install
39 mkdir -p $RPM_BUILD_ROOT
40 tar xzf omd/check-mk-%{edition}-bin-%{version}.tar.gz -C $RPM_BUILD_ROOT
41 # Remove all global symbolic links from package. They are shared
42 # among all versions and must be handled in %post und %postun
43 # in order to avoid RPM conflicts
44 rm -f $RPM_BUILD_ROOT/opt/omd/versions/default
45 rm -f $RPM_BUILD_ROOT/omd
46 rm -f $RPM_BUILD_ROOT/usr/bin/omd
47 rm -f $RPM_BUILD_ROOT/usr/share/man/man8/omd.8.gz
48 rm -f $RPM_BUILD_ROOT/@APACHE_CONFDIR@/*
49 rm -f $RPM_BUILD_ROOT/etc/init.d/omd
50 rm -f $RPM_BUILD_ROOT/etc/systemd/system/omd.service
52 %files
53 %defattr(-,root,root)
54 /opt/omd
55 %attr(4750,root,omd) /opt/omd/versions/%{version}/lib/nagios/plugins/check_icmp
56 %attr(4750,root,omd) /opt/omd/versions/%{version}/lib/nagios/plugins/check_dhcp
57 %attr(4750,root,omd) /opt/omd/versions/%{version}/bin/mkeventd_open514
58 %attr(4750,root,omd) /opt/omd/versions/%{version}/lib/cmc/icmpsender
59 %attr(4750,root,omd) /opt/omd/versions/%{version}/lib/cmc/icmpreceiver
61 %pre
62 groupadd -r omd 2>/dev/null || true
63 # create symlink if not exists
64 if [ ! -e /omd ]
65 then
66 ln -sfn /opt/omd /omd
69 %post
70 # Activate init script for OMD, but only the first
71 # time an OMD package is being installed. The admin
72 # might have deactivated the script himself and does
73 # not want to make it implicitely active again.
74 ACTIVATE_INIT=0
75 if [ ! -e /omd/versions/default ] ; then
76 ACTIVATE_INIT=1
79 echo "New default version is %{version}."
80 ln -sfn "%{version}" /omd/versions/default
81 ln -sfn /omd/versions/default/bin/omd /usr/bin/omd
82 ln -sfn /omd/versions/default/share/man/man8/omd.8.gz /usr/share/man/man8/omd.8.gz
83 ln -sfn /omd/versions/default/share/omd/apache.conf @APACHE_CONFDIR@/zzz_omd.conf
84 if [ ! -d /etc/bash_completion.d ]; then
85 mkdir /etc/bash_completion.d
87 ln -sfn /omd/versions/default/lib/omd/bash_completion /etc/bash_completion.d/omd.sh
89 IS_SYSTEMD=0
90 if [ -d /usr/lib/systemd ] && which systemctl >/dev/null 2>&1; then
91 IS_SYSTEMD=1
94 # Detect whether or not manage startup through systemd or SysV
95 if [ $IS_SYSTEMD -eq 1 ]; then
96 echo "Installing systemd service: omd.init"
98 # Cleanup eventually existing SysV entry
99 if [ -e /etc/init.d/omd ]; then
100 # Check whether or not startup was enabled before and enable it
101 # with systemd again later
102 if chkconfig omd >/dev/null 2>&1; then
103 ACTIVATE_INIT=1
106 rm -f /etc/init.d/omd
109 cp /omd/versions/default/share/omd/omd.service /etc/systemd/system/omd.service
110 systemctl daemon-reload
112 else
113 echo "Installing SysV init script: omd"
114 ln -sfn /omd/versions/default/share/omd/omd.init /etc/init.d/omd
117 # If the init script has been marked as to be activated
118 # really activate the init script now
119 if [ $ACTIVATE_INIT -eq 1 ]; then
120 echo "Activating startup during system boot"
121 if [ $IS_SYSTEMD -eq 1 ]; then
122 systemctl enable omd
123 else
124 chkconfig --add omd
125 chkconfig omd on
129 # SLES: make sure apache modules are activated
130 if which a2enmod >/dev/null 2>&1
131 then
132 echo "Makeing sure that Apache modules proxy, http_proxy and rewrite are activated."
133 a2enmod proxy 2>/dev/null || true
134 a2enmod proxy_http 2>/dev/null || true
135 a2enmod rewrite 2>/dev/null || true
136 %if 0%{?suse_version} > 1200
137 # Only relevant for SLES12 or newer (having apache 2.4)
138 # This still allows old permission configs like "Order: ..."
139 a2enmod mod_access_compat 2>/dev/null || true
140 %endif
143 # SLES: make sure that the following file exists:
144 if [ -d /etc/apache2/sysconfig.d ]
145 then
146 touch /etc/apache2/sysconfig.d/include.conf
149 # Make sure, global apache startscript is activated
150 chkconfig --add @APACHE_NAME@ >/dev/null 2>&1
151 chkconfig @APACHE_NAME@ on >/dev/null 2>&1
153 # RHEL / CENTOS >= 6.4, remove symlinks from existing sites in /etc/fstab
154 if [ -e /etc/fstab ]; then
155 sed -i "s/^tmpfs \/omd\/sites/tmpfs \/opt\/omd\/sites/" /etc/fstab
158 # ensure apache is running
159 service @APACHE_NAME@ start >/dev/null 2>&1
160 exit 0
162 %preun
163 # ON UNINSTALL: Make sure no sites use that version
164 # Do not check this on new release of the same OMD version
165 # (I know this has not happend yet in official releases, but might
166 # happen in future? At least I had such a case with my own builds now.)
167 if [ $1 = 0 ] ; then
168 for link in /omd/sites/*/version
170 target=$(readlink $link 2>/dev/null) || continue
171 version=${target##*/}
172 if [ "$version" = %{version} ]
173 then
174 site=${link#/omd/sites/}
175 site=${site%/version}
176 echo "Site $site is still using this version!" >&2
177 exit 1
179 done
183 %postun
184 v=$(ls -A /omd/versions 2>/dev/null| sort -n | tail -n 1)
185 if [ -n "$v" ]
186 then
187 # Test for broken default version symlink and replace with available version
188 if [ ! -e /omd/versions/default ]; then
189 echo "New default version is $v"
190 ln -sfn "$v" /omd/versions/default
191 else
192 DEFAULT_VERSION=$(readlink /omd/versions/default 2>/dev/null)
193 DEFAULT_VERSION=${DEFAULT_VERSION##*/}
194 echo "Leaving default version $DEFAULT_VERSION"
196 else
197 rm -f /omd/versions/default
198 echo "Removing system group 'omd'"
199 groupdel omd
200 echo "Removing global symbolic links"
201 rm -f /usr/bin/omd
202 rm -f /usr/share/man/man8/omd.8.gz
203 rm -f /etc/bash_completion.d/omd
204 rm -f /etc/bash_completion.d/omd.sh
206 # Can be either the symlink /etc/init.d/omd or the regular
207 # file /etc/systemd/system/omd.service.
208 if [ -e /etc/init.d/omd ]; then
209 rm -f /etc/init.d/omd
210 elif [ -f /etc/systemd/system/omd.service ]; then
211 rm -f /etc/systemd/system/omd.service
214 rmdir /opt/omd/versions
215 rm -f @APACHE_CONFDIR@/zzz_omd.conf
216 rm -f /omd
217 # Try to remove empty directories
218 rmdir /opt/omd/sites 2>/dev/null || true
219 rmdir /opt/omd 2>/dev/null || true