From 1fcf746108e4d6e3a0c57189ac6f747e0715dde1 Mon Sep 17 00:00:00 2001 From: Tim Hardeck Date: Fri, 4 Jul 2014 11:49:51 +0200 Subject: [PATCH] Activate systemd on SUSE distributions refs #5818 --- icinga2.spec | 51 +++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 45 insertions(+), 6 deletions(-) diff --git a/icinga2.spec b/icinga2.spec index db7f913dc..e5e23918e 100644 --- a/icinga2.spec +++ b/icinga2.spec @@ -36,10 +36,11 @@ %endif %if "%{_vendor}" == "suse" -# opensuse 13 %if 0%{?suse_version} >= 1310 +%define use_systemd 1 %define opensuse_boost_version 1_53_0 %else +%define use_systemd 0 %define opensuse_boost_version 1_49_0 %endif %define sles_boost_version 1_54_0 @@ -47,7 +48,6 @@ %define apacheconfdir %{_sysconfdir}/apache2/conf.d %define apacheuser wwwrun %define apachegroup www -%define use_systemd 0 %endif %define icinga_user icinga @@ -288,6 +288,18 @@ install -D -m 0644 etc/icinga/icinga-classic-apache.conf %{buildroot}%{apachecon # remove features-enabled symlinks rm -f %{buildroot}/%{_sysconfdir}/%{name}/features-enabled/*.conf +# enable suse rc links +%if "%{_vendor}" == "suse" +%if 0%{?use_systemd} + ln -sf /usr/sbin/service %{buildroot}%{_sbindir}/rc%{name} +%else + ln -sf ../../%{_initrddir}/%{name} "%{buildroot}%{_sbindir}/rc%{name}" +%endif +mkdir -p "%{buildroot}%{_localstatedir}/adm/fillup-templates/" +mv "%{buildroot}%{_sysconfdir}/sysconfig/%{name}" "%{buildroot}%{_localstatedir}/adm/fillup-templates/sysconfig.%{name}" +%endif + + %clean [ "%{buildroot}" != "/" ] && [ -d "%{buildroot}" ] && rm -rf %{buildroot} @@ -297,12 +309,26 @@ getent group %{icingacmd_group} >/dev/null || %{_sbindir}/groupadd -r %{icingacm getent passwd %{icinga_user} >/dev/null || %{_sbindir}/useradd -c "icinga" -s /sbin/nologin -r -d %{_localstatedir}/spool/%{name} -G %{icingacmd_group} -g %{icinga_group} %{icinga_user} exit 0 + +%if "%{_vendor}" == "suse" +%if 0%{?use_systemd} +%pre bin + %service_add_pre %{name}.service +%endif +%endif + + # all restart/feature actions belong to icinga2-bin %post bin # suse %if 0%{?suse_version} +%if 0%{?use_systemd} +%fillup_only %{name} +%service_add_post %{name}.service +%else %fillup_and_insserv %{name} +%endif # initial installation, enable default features %{_sbindir}/icinga2-enable-feature checker notification mainlog @@ -332,9 +358,12 @@ exit 0 %postun bin # suse %if 0%{?suse_version} - -%restart_on_update %{name} -%insserv_cleanup +%if 0%{?using_systemd} + %service_del_postun %{name}.service +%else + %restart_on_update %{name} + %insserv_cleanup +%endif if [ "$1" = "0" ]; then # deinstallation of the package - remove enabled features @@ -367,6 +396,11 @@ exit 0 # suse %if 0%{?suse_version} +%if 0%{?use_systemd} + %service_del_preun %{name}.service +%else + %stop_on_removal %{name} +%endif if [ "$1" = "0" ]; then %stop_on_removal %{name} fi @@ -453,6 +487,12 @@ exit 0 %else %attr(755,-,-) %{_sysconfdir}/init.d/%{name} %endif +%if "%{_vendor}" == "suse" +%{_sbindir}/rc%{name} +%{_localstatedir}/adm/fillup-templates/sysconfig.%{name} +%else +%config(noreplace) %{_sysconfdir}/sysconfig/%{name} +%endif %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name} %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/conf.d %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/conf.d/hosts @@ -470,7 +510,6 @@ exit 0 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/features-available/*.conf %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/zones.d/* %config(noreplace) %{_sysconfdir}/%{name}/scripts/* -%config(noreplace) %{_sysconfdir}/sysconfig/%{name} %{_sbindir}/%{name} %{_bindir}/%{name}-build-ca %{_bindir}/%{name}-build-key