[packages] vnstat: readd download and symlink functionality
[openwrt/svn-archive/archive.git] / net / vnstat / Makefile
1 #
2 # Copyright (C) 2006-2010 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.10
12 PKG_RELEASE:=3
13
14 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
15 PKG_SOURCE_URL:=http://humdi.net/vnstat
16 PKG_MD5SUM:=95421d968689130590348ceb80ff74a8
17
18 PKG_INSTALL:=1
19
20 PKG_BUILD_DEPENDS:=libgd
21 PKG_BUILD_PARALLEL:=1
22
23 include $(INCLUDE_DIR)/package.mk
24
25 define Package/vnstat/Default
26 SECTION:=net
27 CATEGORY:=Network
28 URL:=http://humdi.net/vnstat/
29 endef
30
31 define Package/vnstat
32 $(call Package/vnstat/Default)
33 TITLE:=Console-based network traffic monitor
34 endef
35
36 define Package/vnstat/description
37 vnStat is a network traffic monitor for Linux that keeps a log of daily
38 network traffic for the selected interface(s). vnStat isn't a packet
39 sniffer. The traffic information is analyzed from the /proc -filesystem,
40 so vnStat can be used without root permissions.
41 endef
42
43 define Package/vnstati
44 $(call Package/vnstat/Default)
45 DEPENDS+=vnstat +libgd
46 TITLE:=PNG image output support for vnStat
47 endef
48
49 define Package/vnstati/description
50 The purpose of vnstati is to provide image output support for statistics
51 collected using vnstat(1). However, the image file format is limited to
52 png. All basic outputs of vnStat are supported excluding live traffic
53 features. The image can be outputted either to a file or to standard
54 output.
55 endef
56
57 define Package/vnstat/conffiles
58 /etc/vnstat.conf
59 /etc/config/vnstat
60 endef
61
62 define Build/Compile/vnstat
63 $(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
64 $(TARGET_CONFIGURE_OPTS) \
65 CFLAGS="$(TARGET_CFLAGS)"
66 endef
67
68 define Build/Compile/vnstati
69 $(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
70 $(TARGET_CONFIGURE_OPTS) \
71 CFLAGS="$(TARGET_CFLAGS) -I$(STAGING_DIR)/usr/include" \
72 LDFLAGS="$(TARGET_LDFLAGS) -Wl,-rpath-link,$(STAGING_DIR)/usr/lib" \
73 all
74 endef
75
76 define Build/Compile
77 $(call Build/Compile/vnstat)
78 $(call Build/Compile/vnstati)
79 endef
80
81 define Package/vnstat/install
82 $(INSTALL_DIR) $(1)/usr/bin
83 $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/vnstat $(1)/usr/bin/
84 $(INSTALL_DIR) $(1)/usr/sbin
85 $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/vnstatd $(1)/usr/sbin/
86 $(INSTALL_DIR) $(1)/etc
87 $(INSTALL_CONF) $(PKG_INSTALL_DIR)/etc/vnstat.conf $(1)/etc/
88 $(INSTALL_DIR) $(1)/etc/config
89 $(INSTALL_CONF) ./files/vnstat-uci.conf $(1)/etc/config/vnstat
90 $(INSTALL_DIR) $(1)/etc/init.d
91 $(INSTALL_BIN) ./files/vnstat.init $(1)/etc/init.d/vnstat
92 endef
93
94 define Package/vnstati/install
95 $(INSTALL_DIR) $(1)/usr/bin
96 $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/vnstati $(1)/usr/bin/
97 endef
98
99 define Package/vnstat/postinst
100 #!/bin/sh
101 local wan="$$(uci -P/var/state get network.wan.ifname)"
102 if [ -n "$$wan" ]; then
103 uci -q batch <<-EOF >/dev/null
104 add_list vnstat.@vnstat[-1].interface=$$wan
105 commit vnstat
106 EOF
107 fi
108 exit 0
109 endef
110
111 $(eval $(call BuildPackage,vnstat))
112 $(eval $(call BuildPackage,vnstati))