[packages] vnstat: Update to v1.8 (closes #5664)
[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
8 include $(TOPDIR)/rules.mk
9
10 PKG_NAME:=vnstat
11 PKG_VERSION:=1.8
12 PKG_RELEASE:=1
13
14 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
15 PKG_SOURCE_URL:=http://humdi.net/vnstat
16 PKG_MD5SUM:=99a30716b5013e7e249e500ee6ee2985
17
18 include $(INCLUDE_DIR)/package.mk
19
20 define Package/vnstat/Default
21 SECTION:=net
22 CATEGORY:=Network
23 URL:=http://humdi.net/vnstat/
24 endef
25
26 define Package/vnstat
27 $(call Package/vnstat/Default)
28 TITLE:=Console-based network traffic monitor
29 endef
30
31 define Package/vnstat/description
32 vnStat is a network traffic monitor for Linux that keeps a log of daily
33 network traffic for the selected interface(s). vnStat isn't a packet
34 sniffer. The traffic information is analyzed from the /proc -filesystem,
35 so vnStat can be used without root permissions.
36 endef
37
38 define Package/vnstati
39 $(call Package/vnstat/Default)
40 DEPENDS+=vnstat +libgd
41 TITLE:=PNG image output support for vnStat
42 endef
43
44 define Package/vnstati/description
45 The purpose of vnstati is to provide image output support for statistics
46 collected using vnstat(1). However, the image file format is limited to
47 png. All basic outputs of vnStat are supported excluding live traffic
48 features. The image can be outputted either to a file or to standard
49 output.
50 endef
51
52 define Package/vnstat/conffiles
53 /etc/vnstat.conf
54 /etc/config/vnstat
55 endef
56
57 define Build/Compile/vnstat
58 $(MAKE) -C $(PKG_BUILD_DIR) \
59 $(TARGET_CONFIGURE_OPTS) \
60 CFLAGS="$(TARGET_CFLAGS)"
61 endef
62
63 define Build/Compile/vnstati
64 $(MAKE) -C $(PKG_BUILD_DIR) \
65 $(TARGET_CONFIGURE_OPTS) \
66 CFLAGS="$(TARGET_CPPFLAGS)" \
67 LDFLAGS="$(TARGET_LDFLAGS) -Wl,-rpath-link,$(STAGING_DIR)/usr/lib" \
68 all
69 endef
70
71 define Build/Compile
72 $(call Build/Compile/vnstat)
73 $(call Build/Compile/vnstati)
74 endef
75
76 define Package/vnstat/install
77 $(INSTALL_DIR) $(1)/usr/bin
78 $(INSTALL_BIN) $(PKG_BUILD_DIR)/src/vnstat $(1)/usr/bin/
79 $(INSTALL_DIR) $(1)/usr/sbin
80 $(INSTALL_BIN) $(PKG_BUILD_DIR)/src/vnstatd $(1)/usr/sbin/
81 $(INSTALL_DIR) $(1)/etc
82 $(INSTALL_CONF) $(PKG_BUILD_DIR)/cfg/vnstat.conf $(1)/etc/
83 $(INSTALL_DIR) $(1)/etc/config
84 $(INSTALL_CONF) ./files/vnstat-uci.conf $(1)/etc/config/vnstat
85 $(INSTALL_DIR) $(1)/etc/init.d
86 $(INSTALL_BIN) ./files/vnstat.init $(1)/etc/init.d/vnstat
87 endef
88
89 define Package/vnstati/install
90 $(INSTALL_DIR) $(1)/usr/bin
91 $(INSTALL_BIN) $(PKG_BUILD_DIR)/src/vnstati $(1)/usr/bin/
92 endef
93
94 define Package/vnstat/postinst
95 #!/bin/sh
96 BIN_REL=/usr/bin/vnstat
97 BIN=$${IPKG_INSTROOT}$${BIN_REL}
98 CRONTAB=$${IPKG_INSTROOT}/etc/crontabs/root
99 LIB_D_REL=/var/lib/vnstat
100 LIB_D=$${IPKG_INSTROOT}$${LIB_D_REL}
101 mkdir -p $${IPKG_INSTROOT}/etc/crontabs/
102 [ -d $$LIB_D ] || mkdir -p $$LIB_D
103 IFACE_WAN=$$(uci get network.wan.ifname)
104 if [ -n $$IFACE_WAN ]; then
105 [ -e $$LIB_D/$$IFACE_WAN ] || ( [ -x $$BIN ] && $$BIN -u -i $$IFACE_WAN )
106 fi
107 grep -q "$$BIN_REL -u" $$CRONTAB 2>/dev/null
108 [ $$? -eq 0 ] && sed -i -e "/\/usr\/bin\/vnstat -u/d" $$CRONTAB
109 true
110 endef
111
112 $(eval $(call BuildPackage,vnstat))
113 $(eval $(call BuildPackage,vnstati))