Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 522226 | Differences between
and this patch

Collapse All | Expand All

(-)old/net-analyzer/vnstat/files/vnstatd-r1.confd (+18 lines)
Line 0 Link Here
1
# /etc/conf.d/vnstatd: config file for /etc/init.d/vnstatd
2
3
# Configuration file
4
VNSTATD_CONFIGFILE="/etc/vnstat.conf"
5
6
# PID file
7
VNSTATD_PIDFILE="/run/vnstat/vnstatd.pid"
8
9
# Options to vnstatd
10
# See vnstatd(8) for more details
11
# Notes:
12
#  * Do not specify another PIDFILE but use the variable above to change the location
13
#  * Do not specify another CONFIGFILE but use the variable above to change the location
14
VNSTATD_OPTS=""
15
16
# Wait x milliseconds after starting and check that daemon is still running.
17
# See start-stop-daemon(8) for more details
18
SSD_STARTWAIT=500
(-)old/net-analyzer/vnstat/files/vnstatd-r1.initd (+31 lines)
Line 0 Link Here
1
#!/sbin/openrc-run
2
# Copyright 1999-2014 Gentoo Foundation
3
# Distributed under the terms of the GNU General Public License v2
4
# $Header: $
5
6
extra_started_commands="reload"
7
8
depend() {
9
	use net
10
}
11
12
pidfile="${VNSTATD_PIDFILE:-/run/vnstat/vnstatd.pid}"
13
command="/usr/bin/vnstatd"
14
command_args="${VNSTATD_OPTS} --daemon --config ${VNSTATD_CONFIGFILE} --pidfile ${pidfile}"
15
start_stop_daemon_args="--wait ${SSD_STARTWAIT:-500}"
16
name="vnStat daemon"
17
18
description="vnstatd is a flexible and robust way to update vnStat databases."
19
description_reload="Reload ${name}'s configuration"
20
21
required_files="${VNSTATD_CONFIGFILE}"
22
23
start_pre() {
24
	checkpath --directory --mode 0775 --owner vnstat:vnstat $(dirname "${pidfile}")
25
}
26
27
reload() {
28
	ebegin "Reloading ${name} configuration"
29
	start-stop-daemon --signal HUP --pidfile "${pidfile}"
30
	eend $?
31
}
(-)old/net-analyzer/vnstat/files/vnstatd.systemd (+11 lines)
Line 0 Link Here
1
[Unit]
2
Description=vnstatd is a flexible and robust way to update vnStat databases
3
4
[Service]
5
After=network-online.target
6
User=vnstat
7
ExecStart=/usr/bin/vnstatd --nodaemon
8
ExecReload=/bin/kill -HUP $MAINPID
9
10
[Install]
11
WantedBy=multi-user.target
(-)old/net-analyzer/vnstat/files/vnstatd.tmpfile (+1 lines)
Line 0 Link Here
1
d /run/vnstat 0775 vnstat vnstat
(-)old/net-analyzer/vnstat/files/vnstat-r1.cron (+7 lines)
Line 0 Link Here
1
#!/bin/bash
2
3
# run vnstat if installed and at least one database exists
4
5
if [ -x /usr/bin/vnstat ] && [ `ls /var/lib/vnstat/ | wc -l` -ge 1 ] ; then
6
	exec /usr/bin/vnstat -u
7
fi
(-)old/net-analyzer/vnstat/vnstat-1.12-r1.ebuild (+94 lines)
Line 0 Link Here
1
# Copyright 1999-2014 Gentoo Foundation
2
# Distributed under the terms of the GNU General Public License v2
3
# $Header: $
4
5
EAPI=5
6
inherit toolchain-funcs user systemd
7
8
DESCRIPTION="Console-based network traffic monitor that keeps statistics of network usage"
9
HOMEPAGE="http://humdi.net/vnstat/"
10
SRC_URI="http://humdi.net/vnstat/${P}.tar.gz"
11
12
LICENSE="GPL-2"
13
SLOT="0"
14
KEYWORDS="~amd64 ~arm ~hppa ~ppc ~ppc64 ~sparc ~x86"
15
IUSE="gd"
16
17
DEPEND="gd? ( media-libs/gd[png] )"
18
RDEPEND="
19
	${DEPEND}
20
	!<sys-apps/openrc-0.13
21
"
22
23
pkg_setup() {
24
	enewgroup vnstat
25
	enewuser vnstat -1 -1 /dev/null vnstat
26
}
27
28
src_prepare() {
29
	tc-export CC
30
31
	sed -i 's:^DaemonUser.*:DaemonUser "vnstat":' cfg/vnstat.conf || die "Failed to set DaemonUser!"
32
	sed -i 's:^DaemonGroup.*:DaemonGroup "vnstat":' cfg/vnstat.conf || die "Failed to set DaemonGroup!"
33
	sed -i 's:^MaxBWethnone.*:# &:' cfg/vnstat.conf || die "Failed to comment out example!"
34
	sed -i 's:vnstat[.]log:vnstatd.log:' cfg/vnstat.conf || die "Failed to adjust LogFile name!"
35
	sed -i 's:^PidFile.*:PidFile "/run/vnstat/vnstatd.pid":' cfg/vnstat.conf || die "Failed to adjust PidFile directive!"
36
}
37
38
src_compile() {
39
	emake CFLAGS="${CFLAGS}" $(usex gd all '')
40
}
41
42
src_install() {
43
	use gd && dobin src/vnstati
44
	dobin src/vnstat src/vnstatd
45
46
	exeinto /usr/share/${PN}
47
	newexe "${FILESDIR}"/vnstat-r1.cron vnstat.cron
48
49
	insinto /etc
50
	doins cfg/vnstat.conf
51
	fowners root:vnstat /etc/vnstat.conf
52
53
	newconfd "${FILESDIR}"/vnstatd-r1.confd vnstatd
54
	newinitd "${FILESDIR}"/vnstatd-r1.initd vnstatd
55
56
	systemd_newunit "${FILESDIR}"/vnstatd.systemd vnstatd.service
57
	systemd_newtmpfilesd "${FILESDIR}"/vnstatd.tmpfile vnstatd.conf
58
59
	keepdir /var/lib/vnstat
60
	fowners vnstat:vnstat /var/lib/vnstat
61
62
	use gd && doman man/vnstati.1
63
	doman man/vnstat.1 man/vnstatd.1
64
65
	newdoc INSTALL README.setup
66
	dodoc CHANGES README UPGRADE FAQ examples/vnstat.cgi
67
}
68
69
pkg_postinst() {
70
	# Workaround feature/bug #141619
71
	chown -R vnstat:vnstat "${ROOT}"/var/lib/vnstat
72
	chown vnstat:vnstat "${ROOT}"/var/run/vnstatd
73
	ewarn "vnStat db files owning user and group has been changed to \"vnstat\"."
74
75
	elog
76
	elog "Repeat the following command for every interface you"
77
	elog "wish to monitor (replace eth0):"
78
	elog "   vnstat -u -i eth0"
79
	elog "and set correct permissions after that, e.g."
80
	elog "   chown -R vnstat:vnstat /var/lib/vnstat"
81
	elog
82
	elog "It is highly recommended to use the included vnstatd to update your"
83
	elog "vnStat databases."
84
	elog
85
	elog "If you want to use the old cron way to update your vnStat databases,"
86
	elog "you have to install the cronjob manually:"
87
	elog ""
88
	elog "   cp /usr/share/${PN}/vnstat.cron /etc/cron.hourly/vnstat"
89
	elog ""
90
	elog "Note: if an interface transfers more than ~4GB in"
91
	elog "the time between cron runs, you may miss traffic."
92
	elog "That's why using vnstatd instead of the cronjob is"
93
	elog "the recommended way to update your vnStat databases."
94
}

Return to bug 522226