[packages] net/vnstat: fix crontab entry
[openwrt/svn-archive/archive.git] / net / vnstat / Makefile
1 #
2 # Copyright (C) 2006-2009 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:=3
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_REL=/usr/bin/vnstat
59 BIN=$${IPKG_INSTROOT}$${BIN_REL}
60 CRONTAB=$${IPKG_INSTROOT}/etc/crontabs/root
61 LIB_D_REL=/var/lib/vnstat
62 LIB_D=$${IPKG_INSTROOT}$${LIB_D_REL}
63 mkdir -p $${IPKG_INSTROOT}/etc/crontabs/
64 [ -d $$LIB_D ] || mkdir -p $$LIB_D
65 IFACE_WAN=$$(uci get network.wan.ifname)
66 if [ -n $$IFACE_WAN ]; then
67 [ -e $$LIB_D/$$IFACE_WAN ] || ( [ -x $$BIN ] && $$BIN -u -i $$IFACE_WAN )
68 fi
69 grep -q "$$BIN_REL -u" $$CRONTAB 2>/dev/null
70 [ $$? -ne 0 ] && echo "*/30 * * * * if [ -x $$BIN_REL ] && [ \`ls $$LIB_D_REL | wc -l\` -ge 1 ]; then $$BIN_REL -u; fi" >> $$CRONTAB
71 true
72 endef
73
74 $(eval $(call BuildPackage,vnstat))