[mrtg] Ship systemd files

vcrhonek vcrhonek at fedoraproject.org
Wed Aug 24 15:14:19 UTC 2011


commit e180dcc784a010f9a27b5d3bbaad0ec498ba9c25
Author: Vitezslav Crhonek <vcrhonek at redhat.com>
Date:   Wed Aug 24 17:13:58 2011 +0200

    Ship systemd files

 mrtg.service |   36 ++++++++++++++++++++++++++++++++++++
 mrtg.spec    |   15 ++++++++++++++-
 mrtg.timer   |   20 ++++++++++++++++++++
 3 files changed, 70 insertions(+), 1 deletions(-)
---
diff --git a/mrtg.service b/mrtg.service
new file mode 100644
index 0000000..e480970
--- /dev/null
+++ b/mrtg.service
@@ -0,0 +1,36 @@
+# To customize, copy this file to /etc/systemd/system and edit there
+#
+# This unit facilitates starting of MRTG.  There are 2 options of
+# how to run MRTG:
+# - as a daemon (preferred); in this case please put
+#   RunAsDaemon: yes in mrtg.conf (or use --daemon switch)
+# - periodically - please see and enable mrtg.timer
+#   Periodic settings need Type=oneshot set here
+#
+# Other recommended settings in mrtg.cfg for daemon mode:
+# NoDetach: yes 
+# If you set this, change below Type=simple
+#
+# Please disable /etc/crond.d/mrtg job when using this unit!
+#
+# do not enable both mrtg-as-a-daemon and timer at the same time
+
+[Unit]
+Description=Multi-router Traffic Grapher
+After=syslog.target
+
+[Service]
+Environment=LANG=C
+ExecStart=/usr/bin/mrtg /etc/mrtg/mrtg.cfg --lock-file /var/lock/mrtg/mrtg_l --confcache-file /var/lib/mrtg/mrtg.ok
+# Type= settings cheatsheet:
+# - RunAsDaemon: yes; NoDetach: yes :
+#Type=simple
+# - RunAsDaemon: yes; NoDetach: no :
+#Type=forking
+# - RunAsDaemon: no; (periodic invocation) :
+#Type=oneshot
+Type=simple
+StandardOutput=syslog
+
+[Install]
+WantedBy=multi-user.target
diff --git a/mrtg.spec b/mrtg.spec
index ff9bd5e..3701300 100644
--- a/mrtg.spec
+++ b/mrtg.spec
@@ -6,7 +6,7 @@
 Summary:   Multi Router Traffic Grapher
 Name:      mrtg
 Version:   2.17.2
-Release:   2%{?dist}
+Release:   3%{?dist}
 URL:       http://oss.oetiker.ch/mrtg/
 Source0:   http://oss.oetiker.ch/mrtg/pub/mrtg-%{version}.tar.gz
 Source1:   http://oss.oetiker.ch/mrtg/pub/mrtg-%{version}.tar.gz.md5
@@ -16,6 +16,8 @@ Source4:   mrtg.crond.in
 Source5:   mrtg-httpd.conf
 Source6:   filter-provides-mrtg.sh
 Source7:   mrtg.tmpfiles
+Source8:   mrtg.service
+Source9:   mrtg.timer
 Patch0:    mrtg-2.15.0-lib64.patch
 License:   GPLv2+
 Group:     Applications/Internet
@@ -80,6 +82,11 @@ install -m 644 %{SOURCE5} $RPM_BUILD_ROOT%{_sysconfdir}/httpd/conf.d/mrtg.conf
     install -p -D -m 644 %{SOURCE7} $RPM_BUILD_ROOT/%{_sysconfdir}/tmpfiles.d/mrtg.conf
 %endif
 
+# install systemd files
+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 %{SOURCE9} $RPM_BUILD_ROOT/lib/systemd/system/mrtg.timer
+
 # Add mrtg-traffic-sum here when upstream decides to install it
 for i in mrtg cfgmaker indexmaker mrtg-traffic-sum; do
     sed -i 's;@@lib@@;%{_lib};g' "$RPM_BUILD_ROOT"%{_bindir}/"$i"
@@ -122,8 +129,14 @@ rm -rf $RPM_BUILD_ROOT
     %config(noreplace) %{_sysconfdir}/tmpfiles.d/mrtg.conf
 %endif
 %ghost /var/lock/mrtg
+/lib/systemd/system/mrtg.service
+/lib/systemd/system/mrtg.timer
 
 %changelog
+* Wed Aug 24 2011 Vitezslav Crhonek <vcrhonek at redhat.com> - 2.17.2-3
+- Ship systemd files
+  Resolves: #696147
+
 * Thu Mar 24 2011 Vitezslav Crhonek <vcrhonek at redhat.com> - 2.17.2-2
 - Use %%ghost for /var/lock/mrtg
   Resolves: #656629
diff --git a/mrtg.timer b/mrtg.timer
new file mode 100644
index 0000000..814627c
--- /dev/null
+++ b/mrtg.timer
@@ -0,0 +1,20 @@
+# To customize, copy this file to /etc/systemd/system and edit there
+#
+# You can use this unit to periodically run mrtg.service.
+# Only enable if you do not want to run mrtg as a daemon.
+# Starting mrtg.timer while mrtg.service is running as a daemon has no point.
+#
+# Please disable /etc/crond.d/mrtg job when using this unit!
+#
+# Default is to run mrtg.service every 5 minutes, starting
+# 1 minute after system boot.
+
+[Unit]
+Description=periodic invocation of MRTG
+
+[Timer]
+OnBootSec=1m
+OnUnitActiveSec=5m
+
+[Install]
+WantedBy=multi-user.target


More information about the scm-commits mailing list