🐶 Sync 2025-11-02 14:26:26
This commit is contained in:
22
openwrt-bandix/files/bandix.config
Normal file
22
openwrt-bandix/files/bandix.config
Normal file
@@ -0,0 +1,22 @@
|
||||
|
||||
config bandix 'general'
|
||||
option iface 'br-lan'
|
||||
option port '8686'
|
||||
option data_dir '/usr/share/bandix'
|
||||
|
||||
option language 'auto'
|
||||
option theme 'auto'
|
||||
|
||||
|
||||
config bandix 'traffic'
|
||||
option enabled '0'
|
||||
option speed_unit 'bytes'
|
||||
option offline_timeout '600'
|
||||
option traffic_retention_seconds '600'
|
||||
option traffic_flush_interval_seconds '600'
|
||||
option traffic_persist_history '0'
|
||||
|
||||
|
||||
config bandix 'connections'
|
||||
option enabled '0'
|
||||
|
||||
66
openwrt-bandix/files/bandix.init
Normal file
66
openwrt-bandix/files/bandix.init
Normal file
@@ -0,0 +1,66 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
|
||||
START=99
|
||||
USE_PROCD=1
|
||||
PROG=/usr/bin/bandix
|
||||
|
||||
service_triggers() {
|
||||
procd_add_reload_trigger "bandix"
|
||||
}
|
||||
|
||||
reload_service() {
|
||||
restart
|
||||
}
|
||||
|
||||
start_service() {
|
||||
local iface
|
||||
local port
|
||||
local data_dir
|
||||
local traffic_enabled
|
||||
local traffic_retention_seconds
|
||||
local traffic_flush_interval_seconds
|
||||
local traffic_persist_history
|
||||
local connections_enabled
|
||||
|
||||
config_load 'bandix'
|
||||
config_get iface 'general' 'iface'
|
||||
config_get port 'general' 'port'
|
||||
config_get data_dir 'general' 'data_dir'
|
||||
config_get_bool traffic_enabled 'traffic' 'enabled'
|
||||
config_get traffic_retention_seconds 'traffic' 'traffic_retention_seconds'
|
||||
config_get traffic_flush_interval_seconds 'traffic' 'traffic_flush_interval_seconds'
|
||||
config_get_bool traffic_persist_history 'traffic' 'traffic_persist_history'
|
||||
config_get_bool connections_enabled 'connections' 'enabled'
|
||||
|
||||
[ "$connections_enabled" != 1 ] && [ "$traffic_enabled" != 1 ] && return 1
|
||||
|
||||
# 构建基础命令行参数
|
||||
local args="--iface $iface --port $port --data-dir $data_dir"
|
||||
|
||||
# 添加流量监控相关参数
|
||||
if [ "$traffic_enabled" -eq 1 ]; then
|
||||
args="$args --enable-traffic"
|
||||
fi
|
||||
if [ -n "$traffic_retention_seconds" ]; then
|
||||
args="$args --traffic-retention-seconds $traffic_retention_seconds"
|
||||
fi
|
||||
if [ -n "$traffic_flush_interval_seconds" ]; then
|
||||
args="$args --traffic-flush-interval-seconds $traffic_flush_interval_seconds"
|
||||
fi
|
||||
if [ "$traffic_persist_history" -eq 1 ]; then
|
||||
args="$args --traffic-persist-history"
|
||||
fi
|
||||
|
||||
# 添加连接统计监控参数
|
||||
if [ "$connections_enabled" -eq 1 ]; then
|
||||
args="$args --enable-connection"
|
||||
fi
|
||||
|
||||
procd_open_instance bandix
|
||||
procd_set_param command $PROG $args
|
||||
procd_set_param respawn ${respawn_threshold:-3600} ${respawn_timeout:-5} ${respawn_retry:-5}
|
||||
procd_set_param stderr 1
|
||||
procd_set_param stdout 1
|
||||
procd_set_param pidfile /var/run/bandix.pid
|
||||
procd_close_instance
|
||||
}
|
||||
Reference in New Issue
Block a user