diff --git a/net/vnstat2/Makefile b/net/vnstat2/Makefile index eadd0c671..3f31083ec 100644 --- a/net/vnstat2/Makefile +++ b/net/vnstat2/Makefile @@ -77,6 +77,8 @@ define Package/vnstat2/install $(INSTALL_CONF) ./files/vnstat.config $(1)/etc/config/vnstat $(INSTALL_DIR) $(1)/etc/init.d $(INSTALL_BIN) ./files/vnstat.init $(1)/etc/init.d/vnstat + $(INSTALL_DIR) $(1)/etc/hotplug.d/iface + $(INSTALL_DATA) ./files/vnstat.hotplug $(1)/etc/hotplug.d/iface/50-vnstat endef define Package/vnstati2/install diff --git a/net/vnstat2/files/vnstat.hotplug b/net/vnstat2/files/vnstat.hotplug new file mode 100644 index 000000000..339c0ac82 --- /dev/null +++ b/net/vnstat2/files/vnstat.hotplug @@ -0,0 +1,23 @@ +/etc/init.d/vnstat running || exit 0 +[ "$ACTION" = "ifup" ] || exit 0 + +. /lib/functions.sh + +check_iface() { + local iface="$1" + + [ "$iface" = "$DEVICE" ] || return + + /usr/bin/vnstat --add -i "$iface" >/dev/null + + exit 0 +} + +check_ifaces() { + local cfg="$1" + + config_list_foreach "$cfg" interface check_iface +} + +config_load vnstat +config_foreach check_ifaces vnstat