[packages] vnstat: defer postinstall in host installation case
authorJo-Philipp Wich <jow@openwrt.org>
Tue, 6 Sep 2011 22:04:38 +0000 (22:04 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Tue, 6 Sep 2011 22:04:38 +0000 (22:04 +0000)
SVN-Revision: 28187

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

index e13c64ea384aac65e31f753decaadb8824486240..efabd1708aed37e5f12c11012ffb602c38da0f4b 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