Merge branch 'master' of mathias-kettner.de:omd
[omd.git] / omd.spec.in
blob2339b7b2cc3fdeb229947d8e5ac9859f1c4cdddb
1 Summary: OMD - OpenSource Monitoring Distribution
2 Name: omd-%{version}
3 Version: SET BY MAKEFILE
4 Release: SET BY MAKEFILE
5 License: GPL
6 URL: http://omdistro.org/
7 Group: Application/System
8 Source: %{name}.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}
20 %description
21 Open Source Monitoring Distribution, containing Nagios,
22 the Nagios plugins, Check_MK, Livestatus, Multisite,
23 PNP4Nagios, NagVis, and other addons. Please visit
24 http://omdistro.org/.
26 %prep
27 %setup -q -n omd-%{version}
29 %build
30 make -j 4
31 make pack
33 %install
34 mkdir -p $RPM_BUILD_ROOT
35 tar xzf omd-bin-%{version}.tar.gz -C $RPM_BUILD_ROOT
36 # Remove all global symbolic links from package. They are shared
37 # among all versions and must be handled in %post und %postun
38 # in order to avoid RPM conflicts
39 rm -f $RPM_BUILD_ROOT/opt/omd/versions/default
40 rm -f $RPM_BUILD_ROOT/omd
41 rm -f $RPM_BUILD_ROOT/usr/bin/omd
42 rm -f $RPM_BUILD_ROOT/usr/share/man/man8/omd.8.gz
43 rm -f $RPM_BUILD_ROOT/@APACHE_CONFDIR@/*
44 rm -f $RPM_BUILD_ROOT/etc/init.d/omd
46 %files
47 %defattr(-,root,root)
48 /opt/omd
49 %attr(4750,root,omd) /opt/omd/versions/%{version}/lib/nagios/plugins/check_icmp
50 %attr(4750,root,omd) /opt/omd/versions/%{version}/lib/nagios/plugins/check_dhcp
51 %attr(4750,root,omd) /opt/omd/versions/%{version}/bin/mkeventd_open514
53 %pre
54 groupadd -r omd 2>/dev/null || true
55 # create symlink if not exists
56 if [ ! -e /omd ]
57 then
58 ln -sfn /opt/omd /omd
61 %post
62 # Activate init script for OMD, but only the first
63 # time an OMD package is being installed. The admin
64 # might have deactivated the script himself and does
65 # not want to make it implicitely active again.
66 ACTIVATE_INIT=0
67 if [ ! -e /omd/versions/default ] ; then
68 echo "Activating init script /etc/init.d/omd"
69 ACTIVATE_INIT=1
72 echo "New default version is %{version}."
73 ln -sfn "%{version}" /omd/versions/default
74 ln -sfn /omd/versions/default/bin/omd /usr/bin/omd
75 ln -sfn /omd/versions/default/share/man/man8/omd.8.gz /usr/share/man/man8/omd.8.gz
76 ln -sfn /omd/versions/default/share/omd/omd.init /etc/init.d/omd
77 ln -sfn /omd/versions/default/share/omd/apache.conf @APACHE_CONFDIR@/zzz_omd.conf
79 # If the init script has been marked as to be activated
80 # really activate the init script now
81 if [ $ACTIVATE_INIT -eq 1 ]; then
82 chkconfig --add omd
83 chkconfig omd on
86 # SLES: make sure apache modules are activated
87 if which a2enmod >/dev/null 2>&1
88 then
89 echo "Makeing sure that Apache modules proxy, http_proxy and rewrite are activated."
90 a2enmod proxy 2>/dev/null || true
91 a2enmod proxy_http 2>/dev/null || true
92 a2enmod rewrite 2>/dev/null || true
95 # SLES: make sure that the following file exists:
96 if [ -d /etc/apache2/sysconfig.d ]
97 then
98 touch /etc/apache2/sysconfig.d/include.conf
101 # Make sure, global apache startscript is activated
102 chkconfig --add @APACHE_NAME@
103 chkconfig @APACHE_NAME@ on
105 # ensure apache is running
106 service @APACHE_NAME@ start >/dev/null 2>&1
107 exit 0
109 %preun
110 # ON UNINSTALL: Make sure no sites use that version
111 # Do not check this on new release of the same OMD version
112 # (I know this has not happend yet in official releases, but might
113 # happen in future? At least I had such a case with my own builds now.)
114 if [ $1 = 0 ] ; then
115 for link in /omd/sites/*/version
117 target=$(readlink $link 2>/dev/null) || continue
118 version=${target##*/}
119 if [ "$version" = %{version} ]
120 then
121 site=${link#/omd/sites/}
122 site=${site%/version}
123 echo "Site $site is still using this version!" >&2
124 exit 1
126 done
130 %postun
131 rm -f /omd/versions/default
132 v=$(ls -A /omd/versions 2>/dev/null| sort -n | tail -n 1)
133 if [ -n "$v" ]
134 then
135 echo "New default version is $v"
136 ln -sfn "$v" /omd/versions/default
137 else
138 echo "Removing system group 'omd'"
139 groupdel omd
140 echo "Removing global symbolic links"
141 rm -f /usr/bin/omd
142 rm -f /usr/share/man/man8/omd.8.gz
143 rm -f /etc/init.d/omd
144 rmdir /opt/omd/versions
145 rm -f @APACHE_CONFDIR@/zzz_omd.conf
146 rm -f /omd
147 # Try to remove empty directories
148 rmdir /opt/omd/sites 2>/dev/null || true
149 rmdir /opt/omd 2>/dev/null || true