From 6a520972559569fc546fc19836674250eb940bb0 Mon Sep 17 00:00:00 2001 From: Sam Kottler Date: Tue, 27 May 2014 03:26:38 -0400 Subject: [PATCH] Generate the service unit on Fedora and use the %systemd_post/_postun/_preun macros for service setup Refs #4794 --- icinga2.spec | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/icinga2.spec b/icinga2.spec index 3372fb61c..035a3f8ac 100644 --- a/icinga2.spec +++ b/icinga2.spec @@ -245,6 +245,11 @@ CMAKE_OPTS="$CMAKE_OPTS -DBOOST_LIBRARYDIR=/usr/lib/boost141 \ -DBoost_NO_SYSTEM_PATHS=TRUE \ -DBUILD_TESTING=FALSE \ -DBoost_NO_BOOST_CMAKE=TRUE" + +%if 0%{?fedora} +CMAKE_OPTS="$CMAKE_OPTS -DUSE_SYSTEMD=ON" +%endif + %endif %endif @@ -294,7 +299,11 @@ exit 0 %else # rhel +%if 0%{?el5}{?el6} /sbin/chkconfig --add %{name} +%else +%systemd_post %{name}.service +%endif if [ ${1:-0} -eq 1 ] then @@ -324,9 +333,13 @@ exit 0 %else # rhel +%if 0%{?el5}{?el6} if [ "$1" -ge "1" ]; then /sbin/service %{name} condrestart >/dev/null 2>&1 || : fi +%else +%systemd_postun_with_restart %{name}.service +%endif if [ "$1" = "0" ]; then # deinstallation of the package - remove enabled features @@ -350,10 +363,14 @@ exit 0 %else # rhel +%if 0%{?el5}{?el6} if [ "$1" = "0" ]; then /sbin/service %{name} stop > /dev/null 2>&1 || : /sbin/chkconfig --del %{name} || : fi +%else +%systemd_preun %{name}.service +%endif exit 0 -- 2.40.0