add systemd support

This commit is contained in:
Tom "spot" Callaway 2011-09-08 14:57:50 -04:00
parent e180dcc784
commit 7d6e9c0bd6

View File

@ -6,13 +6,12 @@
Summary: Multi Router Traffic Grapher Summary: Multi Router Traffic Grapher
Name: mrtg Name: mrtg
Version: 2.17.2 Version: 2.17.2
Release: 3%{?dist} Release: 4%{?dist}
URL: http://oss.oetiker.ch/mrtg/ URL: http://oss.oetiker.ch/mrtg/
Source0: http://oss.oetiker.ch/mrtg/pub/mrtg-%{version}.tar.gz Source0: http://oss.oetiker.ch/mrtg/pub/mrtg-%{version}.tar.gz
Source1: http://oss.oetiker.ch/mrtg/pub/mrtg-%{version}.tar.gz.md5 Source1: http://oss.oetiker.ch/mrtg/pub/mrtg-%{version}.tar.gz.md5
Source2: mrtg.cfg Source2: mrtg.cfg
Source3: filter-requires-mrtg.sh Source3: filter-requires-mrtg.sh
Source4: mrtg.crond.in
Source5: mrtg-httpd.conf Source5: mrtg-httpd.conf
Source6: filter-provides-mrtg.sh Source6: filter-provides-mrtg.sh
Source7: mrtg.tmpfiles Source7: mrtg.tmpfiles
@ -21,13 +20,13 @@ Source9: mrtg.timer
Patch0: mrtg-2.15.0-lib64.patch Patch0: mrtg-2.15.0-lib64.patch
License: GPLv2+ License: GPLv2+
Group: Applications/Internet Group: Applications/Internet
Requires: vixie-cron Requires(post): systemd-units
Requires(post): /sbin/service Requires(preun): systemd-units
Requires(postun): /sbin/service Requires(postun): systemd-units
Requires: perl-Socket6 perl-IO-Socket-INET6 Requires: perl-Socket6 perl-IO-Socket-INET6
Requires: gd Requires: gd
Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: gd-devel, libpng-devel BuildRequires: gd-devel, libpng-devel
BuildRequires: systemd-units
%global __find_requires %{SOURCE3} %global __find_requires %{SOURCE3}
%global __find_provides %{SOURCE6} %global __find_provides %{SOURCE6}
@ -61,7 +60,6 @@ rm -rf $RPM_BUILD_ROOT
make install DESTDIR=$RPM_BUILD_ROOT make install DESTDIR=$RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/mrtg mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/mrtg
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/cron.d
mkdir -p $RPM_BUILD_ROOT%{_localstatedir}/lib/mrtg mkdir -p $RPM_BUILD_ROOT%{_localstatedir}/lib/mrtg
mkdir -p $RPM_BUILD_ROOT%{_localstatedir}/lock/mrtg mkdir -p $RPM_BUILD_ROOT%{_localstatedir}/lock/mrtg
mkdir -p $RPM_BUILD_ROOT%{contentdir} mkdir -p $RPM_BUILD_ROOT%{contentdir}
@ -71,10 +69,6 @@ install -m 644 images/* $RPM_BUILD_ROOT%{contentdir}/
sed 's,@CONTENTDIR@,%{contentdir},g; s,@LIBDIR@,%{_localstatedir}/lib/mrtg,g' \ sed 's,@CONTENTDIR@,%{contentdir},g; s,@LIBDIR@,%{_localstatedir}/lib/mrtg,g' \
%{SOURCE2} > $RPM_BUILD_ROOT%{_sysconfdir}/mrtg/mrtg.cfg %{SOURCE2} > $RPM_BUILD_ROOT%{_sysconfdir}/mrtg/mrtg.cfg
chmod 644 $RPM_BUILD_ROOT%{_sysconfdir}/mrtg/mrtg.cfg chmod 644 $RPM_BUILD_ROOT%{_sysconfdir}/mrtg/mrtg.cfg
sed -e 's,@bindir@,%{_bindir},g; s,@sysconfdir@,%{_sysconfdir},g;' \
-e 's,@localstatedir@,%{_localstatedir},g' %{SOURCE4} \
> $RPM_BUILD_ROOT%{_sysconfdir}/cron.d/mrtg
chmod 644 $RPM_BUILD_ROOT%{_sysconfdir}/cron.d/mrtg
install -m 644 %{SOURCE5} $RPM_BUILD_ROOT%{_sysconfdir}/httpd/conf.d/mrtg.conf install -m 644 %{SOURCE5} $RPM_BUILD_ROOT%{_sysconfdir}/httpd/conf.d/mrtg.conf
@ -84,8 +78,8 @@ install -m 644 %{SOURCE5} $RPM_BUILD_ROOT%{_sysconfdir}/httpd/conf.d/mrtg.conf
# install systemd files # install systemd files
mkdir -p $RPM_BUILD_ROOT/lib/systemd/system mkdir -p $RPM_BUILD_ROOT/lib/systemd/system
install -p -m 644 %{SOURCE8} $RPM_BUILD_ROOT/lib/systemd/system/mrtg.service install -p -m 644 %{SOURCE8} $RPM_BUILD_ROOT%{_unitdir}/mrtg.service
install -p -m 644 %{SOURCE9} $RPM_BUILD_ROOT/lib/systemd/system/mrtg.timer install -p -m 644 %{SOURCE9} $RPM_BUILD_ROOT%{_unitdir}/mrtg.timer
# Add mrtg-traffic-sum here when upstream decides to install it # Add mrtg-traffic-sum here when upstream decides to install it
for i in mrtg cfgmaker indexmaker mrtg-traffic-sum; do for i in mrtg cfgmaker indexmaker mrtg-traffic-sum; do
@ -94,28 +88,32 @@ done
sed -i 's;@@lib@@;%{_lib};g' "$RPM_BUILD_ROOT"%{_mandir}/man1/*.1 sed -i 's;@@lib@@;%{_lib};g' "$RPM_BUILD_ROOT"%{_mandir}/man1/*.1
# Tell crond to reload its configuration.
%post %post
install -d -m 0755 -o root -g root /var/lock/mrtg install -d -m 0755 -o root -g root /var/lock/mrtg
/sbin/service crond condrestart 2>&1 > /dev/null || : if [ $1 -eq 1 ] ; then
# Initial installation
/bin/systemctl daemon-reload >/dev/null 2>&1 || :
fi
%preun %preun
if [ $1 -eq 0 ]; then if [ $1 -eq 0 ]; then
rm -rf /var/lock/mrtg rm -rf /var/lock/mrtg
# Package removal, not upgrade
/bin/systemctl --no-reload disable mrtg.service > /dev/null 2>&1 || :
/bin/systemctl stop mrtg.service > /dev/null 2>&1 || :
fi fi
%postun %postun
/sbin/service crond condrestart 2>&1 > /dev/null || : /bin/systemctl daemon-reload >/dev/null 2>&1 || :
if [ $1 -ge 1 ] ; then
%clean # Package upgrade, not uninstall
rm -rf $RPM_BUILD_ROOT /bin/systemctl try-restart mrtg.service >/dev/null 2>&1 || :
fi
%files %files
%defattr(-,root,root,-)
%doc contrib CHANGES COPYING COPYRIGHT README THANKS %doc contrib CHANGES COPYING COPYRIGHT README THANKS
%dir %{_sysconfdir}/mrtg %dir %{_sysconfdir}/mrtg
%config(noreplace) %{_sysconfdir}/mrtg/mrtg.cfg %config(noreplace) %{_sysconfdir}/mrtg/mrtg.cfg
%config(noreplace) %{_sysconfdir}/cron.d/mrtg
%config(noreplace) %{_sysconfdir}/httpd/conf.d/mrtg.conf %config(noreplace) %{_sysconfdir}/httpd/conf.d/mrtg.conf
%{contentdir} %{contentdir}
%{_bindir}/* %{_bindir}/*
@ -129,10 +127,14 @@ rm -rf $RPM_BUILD_ROOT
%config(noreplace) %{_sysconfdir}/tmpfiles.d/mrtg.conf %config(noreplace) %{_sysconfdir}/tmpfiles.d/mrtg.conf
%endif %endif
%ghost /var/lock/mrtg %ghost /var/lock/mrtg
/lib/systemd/system/mrtg.service %{_unitdir}/mrtg.service
/lib/systemd/system/mrtg.timer %{_unitdir}/mrtg.timer
%changelog %changelog
* Thu Sep 8 2011 Tom Callaway <spot@fedoraproject.org> - 2.17.2-4
- add missing systemd scriptlets
- drop cron.d config (systemd handles it now)
* Wed Aug 24 2011 Vitezslav Crhonek <vcrhonek@redhat.com> - 2.17.2-3 * Wed Aug 24 2011 Vitezslav Crhonek <vcrhonek@redhat.com> - 2.17.2-3
- Ship systemd files - Ship systemd files
Resolves: #696147 Resolves: #696147