Skip to content

Commit

Permalink
adjusted the .spec file to be able to generate an RPM file to be inst…
Browse files Browse the repository at this point in the history
…alled on systemd or SysV init systems #462
  • Loading branch information
mikaku committed Feb 23, 2024
1 parent 971d263 commit 7404e43
Showing 1 changed file with 25 additions and 5 deletions.
30 changes: 25 additions & 5 deletions docs/monitorix.spec
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ simplicity and small size may also be used on embedded devices as well.

%install
rm -rf %{buildroot}
mkdir -p %{buildroot}%{_initrddir}
install -m 0755 docs/monitorix.init %{buildroot}%{_initrddir}/monitorix
mkdir -p %{buildroot}%{_sysconfdir}/logrotate.d
install -m 0644 docs/monitorix.logrotate %{buildroot}%{_sysconfdir}/logrotate.d/monitorix
mkdir -p %{buildroot}%{_sysconfdir}/sysconfig
Expand Down Expand Up @@ -73,11 +71,33 @@ install -m 0644 man/man8/monitorix.8 %{buildroot}%{_mandir}/man8
rm -rf %{buildroot}

%post
/sbin/chkconfig --add monitorix
if [ -d /var/run/systemd ] ; then
install -m 0644 %{_datadir}/doc/%{name}-%{version}/monitorix.service /usr/lib/systemd/system/%{name}.service
else
install -m 0755 %{_datadir}/doc/%{name}-%{version}/monitorix.init %{_initrddir}/%{name}
/sbin/chkconfig --add monitorix
fi

%preun
if [ -d /var/run/systemd ] ; then
/usr/bin/systemctl stop %{name}.service
else
if [ -f /var/lock/subsys/%{name} ] ; then
service monitorix stop
fi
fi

%postun
if [ -d /var/run/systemd ] ; then
/usr/bin/systemctl disable %{name}.service
rm -f /usr/lib/systemd/system/%{name}.service
else
/sbin/chkconfig --del monitorix
rm -f %{_initrddir}/%{name}
fi

%files
%defattr(-, root, root)
%{_initrddir}/monitorix
%config(noreplace) %{_sysconfdir}/logrotate.d/monitorix
%config(noreplace) %{_sysconfdir}/sysconfig/monitorix
%config(noreplace) %{_sysconfdir}/monitorix/monitorix.conf
Expand All @@ -94,7 +114,7 @@ rm -rf %{buildroot}
%{_localstatedir}/lib/monitorix/reports/*.html
%doc %{_mandir}/man5/monitorix.conf.5.gz
%doc %{_mandir}/man8/monitorix.8.gz
%doc Changes COPYING README README.nginx README.BSD docs/monitorix-alert.sh docs/monitorix-apache.conf docs/monitorix-lighttpd.conf docs/monitorix.service docs/htpasswd.pl
%doc Changes COPYING README README.nginx README.BSD docs/monitorix-alert.sh docs/monitorix-apache.conf docs/monitorix-lighttpd.conf docs/monitorix.service docs/monitorix.init docs/htpasswd.pl

%changelog
* Thu Sep 01 2005 Jordi Sanfeliu <[email protected]>
Expand Down

0 comments on commit 7404e43

Please sign in to comment.