firmware/src/packages/fff/fff-simple-tc/files/usr/lib/nodewatcher-json.d/71-simple-tc.sh

37 lines
802 B
Bash

#!/bin/sh
. /lib/functions.sh
SCRIPT_DATA_FILE=$(uci get nodewatcher.@script[0].data_file).json
. /usr/share/libubox/jshn.sh
json_load_file $SCRIPT_DATA_FILE
config_load simple-tc
tc_enabled="0"
tc_in="0"
tc_out="0"
parseTcInterface() {
local iface="$1"
config_get ifname "$iface" ifname
[ "wan" = "$ifname" ] || return
config_get tc_enabled "$iface" enabled "0"
config_get tc_in "$iface" limit_ingress "0"
config_get tc_out "$iface" limit_egress "0"
}
config_foreach parseTcInterface 'interface'
json_add_object "traffic_control"
json_add_object "wan"
json_add_string "enabled" "$tc_enabled"
json_add_string "in" "$tc_in"
json_add_string "out" "$tc_out"
json_close_object #wan
json_close_object #traffic_control
json_dump > $SCRIPT_DATA_FILE
#exit 0