Skip to content

Commit

Permalink
Activate systemd on SUSE distributions
Browse files Browse the repository at this point in the history
refs #5818
  • Loading branch information
thardeck authored and gunnarbeutner committed Jul 30, 2014
1 parent 5a98379 commit 3b50356
Showing 1 changed file with 46 additions and 6 deletions.
52 changes: 46 additions & 6 deletions icinga2.spec
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,19 @@
%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
%endif
%define apachename apache2
%define apacheconfdir %{_sysconfdir}/apache2/conf.d
%define apacheuser wwwrun
%define apachegroup www
%define use_systemd 0
%endif

%define icinga_user icinga
Expand Down Expand Up @@ -288,6 +289,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}

Expand All @@ -297,12 +310,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
Expand Down Expand Up @@ -332,9 +359,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
Expand Down Expand Up @@ -367,6 +397,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
Expand Down Expand Up @@ -453,6 +488,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
Expand All @@ -470,7 +511,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
Expand Down

0 comments on commit 3b50356

Please sign in to comment.