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 |
} |