1
0
mirror of https://git.openwrt.org/feed/packages.git synced 2024-06-14 19:33:59 +02:00

vnstat2: add hotplug script for adding interfaces

If an interface doesn't exist yet when vnStat is started, it won't be
monitored, as only existing interfaces can be added to the database via
the vnstat command.

This adds a hotplug script which adds any configured interfaces to the
vnStat database when it goes up.

Signed-off-by: Jan Hoffmann <jan@3e8.eu>
(cherry picked from commit f9ea814260)
This commit is contained in:
Jan Hoffmann 2021-10-27 23:55:28 +02:00 committed by Josef Schlehofer
parent f8820d2aeb
commit 42f35cdda7
No known key found for this signature in database
GPG Key ID: B950216FE4329F4C
2 changed files with 25 additions and 0 deletions

View File

@ -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

View File

@ -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