[packages] vnstat: readd download and symlink functionality
git-svn-id: svn://svn.openwrt.org/openwrt/packages@25001 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
parent
1ba7498ad0
commit
2f3ba14377
@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=vnstat
|
||||
PKG_VERSION:=1.10
|
||||
PKG_RELEASE:=2
|
||||
PKG_RELEASE:=3
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=http://humdi.net/vnstat
|
||||
|
@ -1,3 +1,5 @@
|
||||
config vnstat
|
||||
list interface br-lan
|
||||
# list interface eth0.1
|
||||
# option remote http://example.org/vnstat/
|
||||
# option symlink /www/vnstat
|
||||
|
@ -26,8 +26,39 @@ start() {
|
||||
|
||||
init_ifaces() {
|
||||
local cfg="$1"
|
||||
init_iface() { /usr/bin/vnstat -u -i "$1" >/dev/null; }
|
||||
local url lnk
|
||||
|
||||
init_iface() {
|
||||
local ifn="$1"
|
||||
|
||||
[ -n "$url" ] && {
|
||||
local try=0
|
||||
local max=3
|
||||
local hostname="$(cat /proc/sys/kernel/hostname)"
|
||||
|
||||
while [ $((++try)) -le $max ]; do
|
||||
if wget -q -O "$lib/$ifn" "$url/${hostname}_$ifn" 2>/dev/null && [ -e "$lib/$ifn" ]; then
|
||||
logger -t "vnstat" "Downloaded backup for database $ifn"
|
||||
break
|
||||
else
|
||||
logger -t "vnstat" "Download try $try/$max for database $ifn failed"
|
||||
sleep 30
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
/usr/bin/vnstat -u -i "$ifn" >/dev/null
|
||||
|
||||
[ -n "$lnk" ] && {
|
||||
mkdir -p "$lnk"
|
||||
[ -L "$lnk/$ifn" ] || ln -s "$lib/$ifn" "$lnk/$ifn"
|
||||
}
|
||||
}
|
||||
|
||||
config_get url "$cfg" remote
|
||||
config_get lnk "$cfg" symlink
|
||||
config_list_foreach "$cfg" interface init_iface
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user