bumps vnstat to 1.6 and add uci files
[openwrt/svn-archive/archive.git] / net / vnstat / Makefile
1 #
2 # Copyright (C) 2006 OpenWrt.org
3 #
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
6 #
7 # $Id$
8
9 include $(TOPDIR)/rules.mk
10
11 PKG_NAME:=vnstat
12 PKG_VERSION:=1.6
13 PKG_RELEASE:=1
14
15 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
16 PKG_SOURCE_URL:=http://humdi.net/vnstat
17 PKG_MD5SUM:=ccaffe8e70d47e0cf2f25e52daa25712
18
19 PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
20
21 include $(INCLUDE_DIR)/package.mk
22
23 define Package/vnstat
24 SECTION:=net
25 CATEGORY:=Network
26 TITLE:=Console-based network traffic monitor
27 URL:=http://humdi.net/vnstat/
28 endef
29
30 define Package/vnstat/description
31 vnStat is a network traffic monitor for Linux that keeps a log of daily
32 network traffic for the selected interface(s). vnStat isn't a packet
33 sniffer. The traffic information is analyzed from the /proc -filesystem,
34 so vnStat can be used without root permissions.
35 endef
36
37 define Package/vnstat/conffiles
38 /etc/config/vnstat
39 endef
40
41 define Build/Compile
42 $(MAKE) -C $(PKG_BUILD_DIR) \
43 $(TARGET_CONFIGURE_OPTS) \
44 CFLAGS="$(TARGET_CFLAGS)"
45 endef
46
47 define Package/vnstat/install
48 $(INSTALL_DIR) $(1)/usr/bin
49 $(INSTALL_BIN) $(PKG_BUILD_DIR)/src/vnstat $(1)/usr/bin/
50 $(INSTALL_DIR) $(1)/etc/config
51 $(INSTALL_DATA) ./files/vnstat.conf $(1)/etc/config/vnstat
52 $(INSTALL_DIR) $(1)/etc/init.d
53 $(INSTALL_BIN) ./files/vnstat.init $(1)/etc/init.d/vnstat
54 endef
55
56 define Package/vnstat/postinst
57 #!/bin/sh
58 BIN=$${IPKG_INSTROOT}/usr/bin/vnstat
59 CRONTAB=$${IPKG_INSTROOT}/etc/crontabs/root
60 LIB_D=$${IPKG_INSTROOT}/var/lib/vnstat
61 mkdir -p $${IPKG_INSTROOT}/etc/crontabs/
62 [ -d $$LIB_D ] || mkdir -p $$LIB_D
63 IFACE_WAN=$$(uci get network.wan.ifname)
64 if [ -n $$IFACE_WAN ]; then
65 [ -e $$LIB_D/$$IFACE_WAN ] || ( [ -x $$BIN ] && $$BIN -u -i $$IFACE_WAN )
66 fi
67 grep -q "$$BIN -u" $$CRONTAB 2>/dev/null
68 [ $$? -ne 0 ] && echo "0-55/5 * * * * root if [ -x $$BIN ] && [ \`ls $$LIB_D | wc -l\` -ge 1 ]; then $$BIN -u; fi" >> $$CRONTAB
69 true
70 endef
71
72 $(eval $(call BuildPackage,vnstat))