mirror of https://github.com/Icinga/icinga2.git
spec: Fix user/group creation, only call i2enfeature ido-mysql on fresh install.
refs #4772 refs #4811
This commit is contained in:
parent
bb0012e7b6
commit
61602240ab
|
@ -8,9 +8,13 @@
|
|||
%endif
|
||||
%if "%{_vendor}" == "suse"
|
||||
%define opensuse_boost_version 1_49_0
|
||||
%define apacheuser www
|
||||
%define apacheuser wwwrun
|
||||
%endif
|
||||
|
||||
%define icinga_user icinga
|
||||
%define icinga_group icinga
|
||||
%define icingacmd_group icingacmd
|
||||
|
||||
%define logmsg logger -t %{name}/rpm
|
||||
|
||||
Summary: network monitoring application
|
||||
|
@ -64,12 +68,15 @@ Requires: libboost_thread%{opensuse_boost_version}
|
|||
%endif
|
||||
|
||||
Requires: %{name}-common = %{version}
|
||||
Requires: user(icinga)
|
||||
Requires(pre): user(icinga)
|
||||
Requires: group(icinga)
|
||||
Requires(pre): group(icinga)
|
||||
Requires: group(icingacmd)
|
||||
Requires(pre): group(icingacmd)
|
||||
|
||||
%if "%{_vendor}" == "redhat"
|
||||
Requires: user(%{icinga_user})
|
||||
Requires(pre): user(%{icinga_user})
|
||||
Requires: group(%{icinga_group})
|
||||
Requires(pre): group(%{icinga_group})
|
||||
Requires: group(%{icingacmd_group})
|
||||
Requires(pre): group(%{icingacmd_group})
|
||||
%endif
|
||||
|
||||
%description
|
||||
Icinga is a general-purpose network monitoring application.
|
||||
|
@ -77,11 +84,13 @@ Icinga is a general-purpose network monitoring application.
|
|||
%package common
|
||||
Summary: Common Icinga 2 configuration
|
||||
Group: Applications/System
|
||||
%if "%{_vendor}" == "redhat"
|
||||
Requires(pre): shadow-utils
|
||||
Requires(post): shadow-utils
|
||||
Provides: user(icinga)
|
||||
Provides: group(icinga)
|
||||
Provides: group(icingacmd)
|
||||
Provides: user(%{icinga_user})
|
||||
Provides: group(%{icinga_group})
|
||||
Provides: group(%{icingacmd_group})
|
||||
%endif
|
||||
|
||||
%description common
|
||||
Provides common directories, uid and gid among Icinga 2 related
|
||||
|
@ -142,36 +151,43 @@ make install \
|
|||
[ "%{buildroot}" != "/" ] && [ -d "%{buildroot}" ] && rm -rf %{buildroot}
|
||||
|
||||
%pre common
|
||||
getent group icinga >/dev/null || groupadd -r icinga
|
||||
getent group icingacmd >/dev/null || groupadd -r icingacmd
|
||||
getent passwd icinga >/dev/null || /useradd -c "icinga" -s /sbin/nologin -r -d %{_localstatedir}/spool/%{name} -G icingacmd -g icinga icinga
|
||||
getent group %{icinga_group} >/dev/null || %{_sbindir}/groupadd -r %{icinga_group}
|
||||
getent group %{icingacmd_group} >/dev/null || %{_sbindir}/groupadd -r %{icingacmd_group}
|
||||
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
|
||||
|
||||
%preun
|
||||
if [ $1 = 0 ]; then
|
||||
if [ "$1" = "0" ]; then
|
||||
/sbin/service %{name} stop &>/dev/null || :
|
||||
/sbin/chkconfig --del %{name} || :
|
||||
fi
|
||||
|
||||
%post
|
||||
%{_sbindir}/usermod -a -G icingacmd %{apacheuser} || :
|
||||
%{_sbindir}/usermod -a -G %{icingacmd_group} %{apacheuser} || :
|
||||
/sbin/chkconfig --add %{name} || :
|
||||
/sbin/service %{name} start &>/dev/null || :
|
||||
|
||||
%post ido-mysql
|
||||
ln -s %{_sysconfdir}/%{name}/features-available/ido-mysql.conf %{_sysconfdir}/%{name}/features-enabled/ido-mysql.conf
|
||||
if [ ${1:-0} -eq 1 ]
|
||||
then
|
||||
# initial installation, enable ido-mysql feature
|
||||
%{_sbindir}/i2enfeature ido-mysql
|
||||
fi
|
||||
|
||||
%postun ido-mysql
|
||||
[ -f "%{_sysconfdir}/%{name}/features-enabled/ido-mysql.conf" ] && rm -f %{_sysconfdir}/%{name}/features-enabled/ido-mysql.conf
|
||||
if [ "$1" = "0" ]; then
|
||||
# deinstallation of the package - remove feature
|
||||
test -x %{_sbindir}/i2disfeature && %{_sbindir}/i2disfeature ido-mysql
|
||||
fi
|
||||
|
||||
|
||||
%files
|
||||
%defattr(-,root,root)
|
||||
%doc README AUTHORS ChangeLog COPYING COPYING.Exceptions
|
||||
%attr(755,-,-) %{_sysconfdir}/init.d/%{name}
|
||||
%attr(0750,icinga,icinga) %dir %{_sysconfdir}/%{name}/conf.d
|
||||
%attr(0750,icinga,icinga) %dir %{_sysconfdir}/%{name}/features-available
|
||||
%attr(0750,icinga,icinga) %dir %{_sysconfdir}/%{name}/features-enabled
|
||||
%attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/conf.d
|
||||
%attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/features-available
|
||||
%attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/features-enabled
|
||||
%config(noreplace) %{_sysconfdir}/%{name}/%{name}.conf
|
||||
%config(noreplace) %{_sysconfdir}/%{name}/conf.d/*.conf
|
||||
%config(noreplace) %{_sysconfdir}/%{name}/features-available/*.conf
|
||||
|
@ -186,16 +202,16 @@ ln -s %{_sysconfdir}/%{name}/features-available/ido-mysql.conf %{_sysconfdir}/%{
|
|||
%{_mandir}/man8/%{name}.8.gz
|
||||
|
||||
%{_localstatedir}/cache/%{name}
|
||||
%attr(0750,icinga,icinga) %dir %{_localstatedir}/log/%{name}
|
||||
%attr(0750,icinga,icinga) %dir %{_localstatedir}/log/%{name}/compat
|
||||
%attr(0750,icinga,icinga) %dir %{_localstatedir}/log/%{name}/compat/archives
|
||||
%attr(0750,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/log/%{name}
|
||||
%attr(0750,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/log/%{name}/compat
|
||||
%attr(0750,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/log/%{name}/compat/archives
|
||||
%{_localstatedir}/run/%{name}
|
||||
%{_localstatedir}/lib/%{name}
|
||||
|
||||
%attr(2755,icinga,icingacmd) %{_localstatedir}/run/icinga2/cmd
|
||||
%attr(2755,%{icinga_user},%{icingacmd_group}) %{_localstatedir}/run/icinga2/cmd
|
||||
|
||||
%files common
|
||||
%attr(0750,icinga,icinga) %dir %{_localstatedir}/spool/%{name}
|
||||
%attr(0750,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/spool/%{name}
|
||||
|
||||
%files doc
|
||||
%doc README AUTHORS ChangeLog COPYING COPYING.Exceptions
|
||||
|
|
Loading…
Reference in New Issue