Activate systemd on SUSE distributions

refs #5818
This commit is contained in:
Tim Hardeck 2014-07-04 11:49:51 +02:00 committed by Gunnar Beutner
parent 5a98379eb8
commit 1fcf746108
1 changed files with 45 additions and 6 deletions

View File

@ -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