diff --git a/net/vnstat/Makefile b/net/vnstat/Makefile index 29995fc6a..86d6fc590 100644 --- a/net/vnstat/Makefile +++ b/net/vnstat/Makefile @@ -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 diff --git a/net/vnstat/files/vnstat-uci.conf b/net/vnstat/files/vnstat-uci.conf index 339fda48a..9da71ed7f 100644 --- a/net/vnstat/files/vnstat-uci.conf +++ b/net/vnstat/files/vnstat-uci.conf @@ -1,3 +1,5 @@ config vnstat list interface br-lan # list interface eth0.1 +# option remote http://example.org/vnstat/ +# option symlink /www/vnstat diff --git a/net/vnstat/files/vnstat.init b/net/vnstat/files/vnstat.init index 2febdfae3..fab1f341a 100644 --- a/net/vnstat/files/vnstat.init +++ b/net/vnstat/files/vnstat.init @@ -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 }