[backfire] merge r28187
authorJo-Philipp Wich <jow@openwrt.org>
Tue, 6 Sep 2011 22:05:27 +0000 (22:05 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Tue, 6 Sep 2011 22:05:27 +0000 (22:05 +0000)
SVN-Revision: 28188

net/vnstat/Makefile
net/vnstat/files/vnstat.defaults [new file with mode: 0644]

index e13c64e..efabd17 100644 (file)
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=vnstat
 PKG_VERSION:=1.11
-PKG_RELEASE:=1
+PKG_RELEASE:=2
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
 PKG_SOURCE_URL:=http://humdi.net/vnstat
@@ -89,6 +89,8 @@ define Package/vnstat/install
        $(INSTALL_CONF) ./files/vnstat-uci.conf $(1)/etc/config/vnstat
        $(INSTALL_DIR) $(1)/etc/init.d
        $(INSTALL_BIN) ./files/vnstat.init $(1)/etc/init.d/vnstat
+       $(INSTALL_DIR) $(1)/etc/uci-defaults
+       $(INSTALL_BIN) ./files/vnstat.defaults $(1)/etc/uci-defaults/vnstat
 endef
 
 define Package/vnstati/install
@@ -98,13 +100,7 @@ endef
 
 define Package/vnstat/postinst
 #!/bin/sh
-local wan="$$(uci -P/var/state get network.wan.ifname)"
-if [ -n "$$wan" ]; then
-       uci -q batch <<-EOF >/dev/null
-               add_list vnstat.@vnstat[-1].interface=$$wan
-               commit vnstat
-       EOF
-fi
+[ -n "$${IPKG_INSTROOT}" ] || (. /etc/uci-defaults/vnstat) && rm -f /etc/uci-defaults/vnstat
 exit 0
 endef
 
diff --git a/net/vnstat/files/vnstat.defaults b/net/vnstat/files/vnstat.defaults
new file mode 100644 (file)
index 0000000..a2d353f
--- /dev/null
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+wan="$(uci -P/var/state get network.wan.ifname)"
+
+if [ -n "$wan" ]; then
+       uci -q batch <<-EOF >/dev/null
+               add_list vnstat.@vnstat[-1].interface=$wan
+               commit vnstat
+       EOF
+fi
+
+exit 0