mirror of
https://github.com/openwrt/packages.git
synced 2025-02-12 02:21:14 +00:00
This version includes several new features that allow to simplify the package significantly: The noexit patch and hotplug script are no longer needed, and the init script doesn't have to check for legacy databases anymore. Signed-off-by: Jan Hoffmann <jan@3e8.eu>
49 lines
791 B
Bash
49 lines
791 B
Bash
#!/bin/sh /etc/rc.common
|
|
|
|
START=60
|
|
STOP=50
|
|
|
|
USE_PROCD=1
|
|
|
|
init_database() {
|
|
/usr/sbin/vnstatd --initdb >/dev/null
|
|
}
|
|
|
|
init_ifaces() {
|
|
local cfg="$1"
|
|
|
|
init_iface() {
|
|
local ifn="$1"
|
|
|
|
/usr/bin/vnstat --add --force -i "$ifn" >/dev/null
|
|
}
|
|
|
|
config_list_foreach "$cfg" interface init_iface
|
|
}
|
|
|
|
start_service() {
|
|
init_database
|
|
|
|
config_load vnstat
|
|
config_foreach init_ifaces vnstat
|
|
|
|
procd_open_instance
|
|
procd_set_param stdout 1
|
|
procd_set_param stderr 1
|
|
procd_set_param command /usr/sbin/vnstatd --nodaemon --noadd --startempty --noremove
|
|
procd_set_param file /etc/vnstat.conf
|
|
procd_set_param respawn
|
|
procd_close_instance
|
|
}
|
|
|
|
reload_service() {
|
|
config_load vnstat
|
|
config_foreach init_ifaces vnstat
|
|
|
|
procd_send_signal vnstat
|
|
}
|
|
|
|
service_triggers() {
|
|
procd_add_reload_trigger vnstat
|
|
}
|