[vnstat] added patch to check for pidfile in /run/vnstat

Adrian Reber adrian at fedoraproject.org
Thu Dec 22 21:43:08 UTC 2011


commit 973b8d36bf45494141e124e0904a53d222402274
Author: Adrian Reber <adrian at lisas.de>
Date:   Thu Dec 22 22:42:55 2011 +0100

    added patch to check for pidfile in /run/vnstat

 vnstat-run-vnstat.diff |   25 +++++++++++++++++++++++++
 vnstat.spec            |    7 ++++++-
 2 files changed, 31 insertions(+), 1 deletions(-)
---
diff --git a/vnstat-run-vnstat.diff b/vnstat-run-vnstat.diff
new file mode 100644
index 0000000..b3d464d
--- /dev/null
+++ b/vnstat-run-vnstat.diff
@@ -0,0 +1,25 @@
+--- a/src/vnstatd.c	2011-06-01 00:29:51.000000000 +0200
++++ b/src/vnstatd.c	2011-12-22 22:23:22.512967108 +0100
+@@ -482,10 +482,18 @@
+ 	/* lock / pid file */
+ 	pidfile = open(cfg.pidfile, O_RDWR|O_CREAT, 0644);
+ 	if (pidfile<0) {
+-		perror("pidfile");
+-		snprintf(errorstring, 512, "pidfile failed, exiting.");
+-		printe(PT_Error);
+-		exit(EXIT_FAILURE); /* can't open */
++		/* for Fedora's move to systemd and /run check
++		 * for /run/vnstat/vnstat.pid, so that it needs no changes
++		 * to the config file */
++		pidfile = open("/run/vnstat/vnstat.pid", O_RDWR|O_CREAT, 0644);
++		if (pidfile<0) {
++			perror("pidfile");
++			snprintf(errorstring, 512, "pidfile failed, exiting.");
++			printe(PT_Error);
++			exit(EXIT_FAILURE); /* can't open */
++		} else {
++			strncpy(cfg.pidfile, "/run/vnstat/vnstat.pid", 512);
++		}
+ 	}
+ 	if (lockf(pidfile,F_TLOCK,0)<0) {
+ 		perror("pidfile lock");
diff --git a/vnstat.spec b/vnstat.spec
index 916cf69..369fcb1 100644
--- a/vnstat.spec
+++ b/vnstat.spec
@@ -1,7 +1,7 @@
 Summary: Console-based network traffic monitor
 Name: vnstat
 Version: 1.11
-Release: 3%{?dist}
+Release: 4%{?dist}
 
 License: GPLv2
 Group: System Environment/Daemons
@@ -14,6 +14,7 @@ Requires(preun): initscripts
 Requires(postun): initscripts
 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 BuildRequires: gd-devel
+Patch0: vnstat-run-vnstat.diff
 
 %description
 vnStat is a console-based network traffic monitor that keeps a log of daily
@@ -23,6 +24,7 @@ be used without root permissions. See the webpage for few 'screenshots'.
 
 %prep
 %setup -q
+%patch0 -p1
 
 # disable maximum bandwidth setting and change pidfile location
 sed -i -e "s,/var/run/,/run/vnstat/,g; \
@@ -137,6 +139,9 @@ fi
 %attr(-,vnstat,vnstat)%{_localstatedir}/lib/%{name}
 
 %changelog
+* Thu Dec 22 2011 Adrian Reber <adrian at lisas.de> - 1.11-4
+- added patch to check for pidfile in /run/vnstat
+
 * Tue Nov 29 2011 Adrian Reber <adrian at lisas.de> - 1.11-3
 - create file in tmpfiles.d for pidfile (#750141)
 


More information about the scm-commits mailing list