bumps vnstat to 1.6 and add uci files

git-svn-id: svn://svn.openwrt.org/openwrt/packages@11976 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
blogic 2008-07-28 19:34:31 +00:00
parent ef2614a0a7
commit 447f613886
3 changed files with 86 additions and 2 deletions

View File

@ -9,12 +9,12 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=vnstat
PKG_VERSION:=1.4
PKG_VERSION:=1.6
PKG_RELEASE:=1
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=http://humdi.net/vnstat
PKG_MD5SUM:=9184f79b5e60499bc059f670032291e5
PKG_MD5SUM:=ccaffe8e70d47e0cf2f25e52daa25712
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
@ -34,6 +34,10 @@ define Package/vnstat/description
so vnStat can be used without root permissions.
endef
define Package/vnstat/conffiles
/etc/config/vnstat
endef
define Build/Compile
$(MAKE) -C $(PKG_BUILD_DIR) \
$(TARGET_CONFIGURE_OPTS) \
@ -43,6 +47,26 @@ endef
define Package/vnstat/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/src/vnstat $(1)/usr/bin/
$(INSTALL_DIR) $(1)/etc/config
$(INSTALL_DATA) ./files/vnstat.conf $(1)/etc/config/vnstat
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) ./files/vnstat.init $(1)/etc/init.d/vnstat
endef
define Package/vnstat/postinst
#!/bin/sh
BIN=$${IPKG_INSTROOT}/usr/bin/vnstat
CRONTAB=$${IPKG_INSTROOT}/etc/crontabs/root
LIB_D=$${IPKG_INSTROOT}/var/lib/vnstat
mkdir -p $${IPKG_INSTROOT}/etc/crontabs/
[ -d $$LIB_D ] || mkdir -p $$LIB_D
IFACE_WAN=$$(uci get network.wan.ifname)
if [ -n $$IFACE_WAN ]; then
[ -e $$LIB_D/$$IFACE_WAN ] || ( [ -x $$BIN ] && $$BIN -u -i $$IFACE_WAN )
fi
grep -q "$$BIN -u" $$CRONTAB 2>/dev/null
[ $$? -ne 0 ] && echo "0-55/5 * * * * root if [ -x $$BIN ] && [ \`ls $$LIB_D | wc -l\` -ge 1 ]; then $$BIN -u; fi" >> $$CRONTAB
true
endef
$(eval $(call BuildPackage,vnstat))

View File

@ -0,0 +1,4 @@
config interface wan
option enabled 0
option remote_host <webserver>
option remote_path <directory>

View File

@ -0,0 +1,56 @@
#!/bin/sh /etc/rc.common
# Copyright (C) 2008 OpenWrt.org
START=99
LIB_D=/var/lib/vnstat
WWW_D=/www/vnstat
system_config() {
local cfg="$1"
config_get hostname "$cfg" hostname
hostname="${hostname:-OpenWrt}"
}
do_download() {
include /lib/network
scan_interfaces
local cfg="$1"
config_get ifname "$cfg" "ifname"
[ -n "$ifname" ] || return 0
[ -e $LIB_D/$ifname ] && return 0
config_get_bool enabled "$cfg" "enabled" "1"
if [ "$enabled" -gt 0 ]; then
config_get remote_path "$cfg" "remote_path"
[ -n "$remote_path" ] || return 0
config_get remote_host "$cfg" "remote_host"
[ -n "$remote_host" ] || return 0
[ -x /usr/bin/wget ] && download_command="wget http://$remote_host/$remote_path/${hostname}_$ifname -O $LIB_D/$ifname"
[ -n "$download_command" ] || return 0
while [ ! -e $LIB_D/$ifname ]; do
$download_command 2>/dev/null
[ -e $LIB_D/$ifname ] && {
logger -s -t "vnstat" "Successfully downloaded ${ifname}'s vnStat database backup"
[ -x /bin/ln ] && ln -sf $LIB_D/$ifname $WWW_D/$ifname
return 0
}
sleep 30
done
fi
}
start() {
[ -d $LIB_D ] || mkdir -p $LIB_D
[ -d $WWW_D ] || mkdir -p $WWW_D
config_load system
config_foreach system_config system
config_load vnstat
config_foreach do_download interface
}