1 |
commit: 9bedfaa050827b35da830925cfd8a2e1469b3411 |
2 |
Author: Thomas Deutschmann <whissi <AT> gentoo <DOT> org> |
3 |
AuthorDate: Tue Jun 27 16:24:27 2017 +0000 |
4 |
Commit: Thomas Deutschmann <whissi <AT> gentoo <DOT> org> |
5 |
CommitDate: Tue Jun 27 16:25:56 2017 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=9bedfaa0 |
7 |
|
8 |
net-analyzer/vnstat: Rev bump to improve runscript and to add systemd support (bug #522226) |
9 |
|
10 |
Package-Manager: Portage-2.3.5, Repoman-2.3.2 |
11 |
|
12 |
net-analyzer/vnstat/files/vnstat.cron-r1 | 7 ++ |
13 |
net-analyzer/vnstat/files/vnstatd.confd-r1 | 18 +++++ |
14 |
net-analyzer/vnstat/files/vnstatd.initd-r2 | 29 +++++++ |
15 |
net-analyzer/vnstat/files/vnstatd.systemd | 11 +++ |
16 |
net-analyzer/vnstat/files/vnstatd.tmpfile | 1 + |
17 |
net-analyzer/vnstat/vnstat-1.17-r1.ebuild | 123 +++++++++++++++++++++++++++++ |
18 |
6 files changed, 189 insertions(+) |
19 |
|
20 |
diff --git a/net-analyzer/vnstat/files/vnstat.cron-r1 b/net-analyzer/vnstat/files/vnstat.cron-r1 |
21 |
new file mode 100644 |
22 |
index 00000000000..178133675c6 |
23 |
--- /dev/null |
24 |
+++ b/net-analyzer/vnstat/files/vnstat.cron-r1 |
25 |
@@ -0,0 +1,7 @@ |
26 |
+#!/bin/bash |
27 |
+ |
28 |
+# run vnstat if installed and at least one database exists |
29 |
+ |
30 |
+if [ -x /usr/bin/vnstat ] && [ `ls /var/lib/vnstat/ | wc -l` -ge 1 ] ; then |
31 |
+ exec /usr/bin/vnstat -u |
32 |
+fi |
33 |
|
34 |
diff --git a/net-analyzer/vnstat/files/vnstatd.confd-r1 b/net-analyzer/vnstat/files/vnstatd.confd-r1 |
35 |
new file mode 100644 |
36 |
index 00000000000..33edf3560ee |
37 |
--- /dev/null |
38 |
+++ b/net-analyzer/vnstat/files/vnstatd.confd-r1 |
39 |
@@ -0,0 +1,18 @@ |
40 |
+# /etc/conf.d/vnstatd: config file for /etc/init.d/vnstatd |
41 |
+ |
42 |
+# Configuration file |
43 |
+VNSTATD_CONFIGFILE="/etc/vnstat.conf" |
44 |
+ |
45 |
+# PID file |
46 |
+VNSTATD_PIDFILE="/run/vnstat/vnstatd.pid" |
47 |
+ |
48 |
+# Options to vnstatd |
49 |
+# See vnstatd(8) for more details |
50 |
+# Notes: |
51 |
+# * Do not specify another PIDFILE but use the variable above to change the location |
52 |
+# * Do not specify another CONFIGFILE but use the variable above to change the location |
53 |
+VNSTATD_OPTS="" |
54 |
+ |
55 |
+# Wait x milliseconds after starting and check that daemon is still running. |
56 |
+# See start-stop-daemon(8) for more details |
57 |
+SSD_STARTWAIT=500 |
58 |
|
59 |
diff --git a/net-analyzer/vnstat/files/vnstatd.initd-r2 b/net-analyzer/vnstat/files/vnstatd.initd-r2 |
60 |
new file mode 100644 |
61 |
index 00000000000..2b4a9336c2a |
62 |
--- /dev/null |
63 |
+++ b/net-analyzer/vnstat/files/vnstatd.initd-r2 |
64 |
@@ -0,0 +1,29 @@ |
65 |
+#!/sbin/openrc-run |
66 |
+# Copyright 1999-2017 Gentoo Foundation |
67 |
+# Distributed under the terms of the GNU General Public License v2 |
68 |
+ |
69 |
+extra_started_commands="reload" |
70 |
+ |
71 |
+VNSTATD_CONFIGFILE=${VNSTATD_CONFIGFILE:-"/etc/vnstat.conf"} |
72 |
+VNSTATD_PIDFILE=${VNSTATD_PIDFILE:-"/run/vnstat/vnstatd.pid"} |
73 |
+ |
74 |
+pidfile="${VNSTATD_PIDFILE}" |
75 |
+command="/usr/bin/vnstatd" |
76 |
+command_args="${VNSTATD_OPTS} --daemon --config \"${VNSTATD_CONFIGFILE}\" --pidfile \"${pidfile}\"" |
77 |
+start_stop_daemon_args="--wait ${SSD_STARTWAIT:-500}" |
78 |
+name="vnStat daemon" |
79 |
+ |
80 |
+description="vnstatd updates vnStat databases." |
81 |
+description_reload="Reload ${name}'s configuration" |
82 |
+ |
83 |
+required_files="${VNSTATD_CONFIGFILE}" |
84 |
+ |
85 |
+start_pre() { |
86 |
+ checkpath --directory --mode 0775 --owner vnstat:vnstat $(dirname "${pidfile}") |
87 |
+} |
88 |
+ |
89 |
+reload() { |
90 |
+ ebegin "Reloading ${name} configuration" |
91 |
+ start-stop-daemon --signal HUP --pidfile "${pidfile}" |
92 |
+ eend $? |
93 |
+} |
94 |
|
95 |
diff --git a/net-analyzer/vnstat/files/vnstatd.systemd b/net-analyzer/vnstat/files/vnstatd.systemd |
96 |
new file mode 100644 |
97 |
index 00000000000..51b079c5a9f |
98 |
--- /dev/null |
99 |
+++ b/net-analyzer/vnstat/files/vnstatd.systemd |
100 |
@@ -0,0 +1,11 @@ |
101 |
+[Unit] |
102 |
+Description=vnStat network traffic monitor |
103 |
+Documentation=man:vnstatd(1) man:vnstat(1) man:vnstat.conf(5) |
104 |
+After=network-online.target |
105 |
+ |
106 |
+[Service] |
107 |
+ExecStart=/usr/bin/vnstatd --nodaemon |
108 |
+ExecReload=/bin/kill -HUP $MAINPID |
109 |
+ |
110 |
+[Install] |
111 |
+WantedBy=multi-user.target |
112 |
|
113 |
diff --git a/net-analyzer/vnstat/files/vnstatd.tmpfile b/net-analyzer/vnstat/files/vnstatd.tmpfile |
114 |
new file mode 100644 |
115 |
index 00000000000..36ecf225949 |
116 |
--- /dev/null |
117 |
+++ b/net-analyzer/vnstat/files/vnstatd.tmpfile |
118 |
@@ -0,0 +1 @@ |
119 |
+d /run/vnstat 0775 vnstat vnstat - |
120 |
|
121 |
diff --git a/net-analyzer/vnstat/vnstat-1.17-r1.ebuild b/net-analyzer/vnstat/vnstat-1.17-r1.ebuild |
122 |
new file mode 100644 |
123 |
index 00000000000..0c24c6dc601 |
124 |
--- /dev/null |
125 |
+++ b/net-analyzer/vnstat/vnstat-1.17-r1.ebuild |
126 |
@@ -0,0 +1,123 @@ |
127 |
+# Copyright 1999-2017 Gentoo Foundation |
128 |
+# Distributed under the terms of the GNU General Public License v2 |
129 |
+ |
130 |
+EAPI="6" |
131 |
+inherit systemd toolchain-funcs user versionator |
132 |
+ |
133 |
+DESCRIPTION="Console-based network traffic monitor that keeps statistics of network usage" |
134 |
+HOMEPAGE="http://humdi.net/vnstat/" |
135 |
+SRC_URI="http://humdi.net/vnstat/${P}.tar.gz" |
136 |
+ |
137 |
+LICENSE="GPL-2" |
138 |
+SLOT="0" |
139 |
+KEYWORDS="~amd64 ~arm ~hppa ~ppc ~ppc64 ~sparc ~x86" |
140 |
+IUSE="gd selinux test" |
141 |
+ |
142 |
+COMMON_DEPEND=" |
143 |
+ gd? ( media-libs/gd[png] ) |
144 |
+" |
145 |
+DEPEND=" |
146 |
+ ${COMMON_DEPEND} |
147 |
+ test? ( dev-libs/check ) |
148 |
+" |
149 |
+RDEPEND=" |
150 |
+ ${COMMON_DEPEND} |
151 |
+ selinux? ( sec-policy/selinux-vnstatd ) |
152 |
+" |
153 |
+ |
154 |
+pkg_setup() { |
155 |
+ enewgroup vnstat |
156 |
+ enewuser vnstat -1 -1 /var/lib/vnstat vnstat |
157 |
+} |
158 |
+ |
159 |
+src_prepare() { |
160 |
+ default |
161 |
+ |
162 |
+ tc-export CC |
163 |
+ |
164 |
+ sed -i \ |
165 |
+ -e 's|^\(MaxBWethnone.*\)$|#\1|' \ |
166 |
+ -e 's|^Daemon\(.*\) ""$|Daemon\1 "vnstat"|' \ |
167 |
+ -e 's|vnstat[.]log|vnstatd.log|' \ |
168 |
+ -e 's|vnstat[.]pid|vnstatd.pid|' \ |
169 |
+ -e 's|/var/run|/run|' \ |
170 |
+ cfg/${PN}.conf || die |
171 |
+ sed -i \ |
172 |
+ -e '/PIDFILE/s|/var/run|/run|' \ |
173 |
+ src/common.h || die |
174 |
+} |
175 |
+ |
176 |
+src_compile() { |
177 |
+ emake ${PN} ${PN}d $(usex gd ${PN}i '') |
178 |
+} |
179 |
+ |
180 |
+src_install() { |
181 |
+ use gd && dobin vnstati |
182 |
+ dobin vnstat vnstatd |
183 |
+ |
184 |
+ exeinto /usr/share/${PN} |
185 |
+ newexe "${FILESDIR}"/vnstat.cron-r1 vnstat.cron |
186 |
+ |
187 |
+ insinto /etc |
188 |
+ doins cfg/vnstat.conf |
189 |
+ fowners root:vnstat /etc/vnstat.conf |
190 |
+ |
191 |
+ keepdir /var/lib/vnstat |
192 |
+ fowners vnstat:vnstat /var/lib/vnstat |
193 |
+ |
194 |
+ newconfd "${FILESDIR}"/vnstatd.confd-r1 vnstatd |
195 |
+ newinitd "${FILESDIR}"/vnstatd.initd-r2 vnstatd |
196 |
+ |
197 |
+ systemd_newunit "${FILESDIR}"/vnstatd.systemd vnstatd.service |
198 |
+ systemd_newtmpfilesd "${FILESDIR}"/vnstatd.tmpfile vnstatd.conf |
199 |
+ |
200 |
+ use gd && doman man/vnstati.1 |
201 |
+ doman man/vnstat.1 man/vnstatd.1 |
202 |
+ |
203 |
+ newdoc INSTALL README.setup |
204 |
+ dodoc CHANGES README UPGRADE FAQ examples/vnstat.cgi |
205 |
+} |
206 |
+ |
207 |
+pkg_postinst() { |
208 |
+ local _v |
209 |
+ for _v in ${REPLACING_VERSIONS}; do |
210 |
+ if ! version_is_at_least 1.17-r1 ${_v}; then |
211 |
+ # This is an upgrade |
212 |
+ elog "" |
213 |
+ elog "Beginning with ${PN}-1.17-r1, we no longer install and use the cron job" |
214 |
+ elog "per default to update vnStat databases because you will lose some traffic" |
215 |
+ elog "if your interface transfers more than ~4GB in the time between two cron" |
216 |
+ elog "runs". |
217 |
+ elog "" |
218 |
+ elog "Please make sure that the vnstatd service is enabled if you want to" |
219 |
+ elog "continue monitoring your traffic." |
220 |
+ |
221 |
+ # Show this elog only once |
222 |
+ break |
223 |
+ fi |
224 |
+ done |
225 |
+ |
226 |
+ if [[ -z "${REPLACING_VERSIONS}" ]]; then |
227 |
+ # This is a new installation |
228 |
+ |
229 |
+ elog |
230 |
+ elog "Repeat the following command for every interface you" |
231 |
+ elog "wish to monitor (replace eth0):" |
232 |
+ elog " vnstat -u -i eth0" |
233 |
+ elog "and set correct permissions after that, e.g." |
234 |
+ elog " chown -R vnstat:vnstat /var/lib/vnstat" |
235 |
+ elog |
236 |
+ elog "It is highly recommended to use the included vnstatd to update your" |
237 |
+ elog "vnStat databases." |
238 |
+ elog |
239 |
+ elog "If you want to use the old cron way to update your vnStat databases," |
240 |
+ elog "you have to install the cron job manually:" |
241 |
+ elog "" |
242 |
+ elog " cp /usr/share/${PN}/vnstat.cron /etc/cron.hourly/vnstat" |
243 |
+ elog "" |
244 |
+ elog "Note: if an interface transfers more than ~4GB in" |
245 |
+ elog "the time between cron runs, you may miss traffic." |
246 |
+ elog "That's why using vnstatd instead of the cronjob is" |
247 |
+ elog "the recommended way to update your vnStat databases." |
248 |
+ fi |
249 |
+} |