2022-04-06 12:09:34 +00:00
|
|
|
#!/bin/sh /etc/rc.common
|
|
|
|
# Copyright (c) 2021 OpenWrt.org
|
|
|
|
|
|
|
|
START=19
|
|
|
|
|
|
|
|
USE_PROCD=1
|
|
|
|
PROG=/usr/sbin/bridger
|
|
|
|
|
2024-04-15 09:19:44 +00:00
|
|
|
get_defaults() {
|
2022-04-06 12:09:34 +00:00
|
|
|
cfg="$1"
|
|
|
|
|
|
|
|
config_get blacklist "$cfg" blacklist
|
2024-04-15 09:19:44 +00:00
|
|
|
json_add_array blacklist
|
2022-04-06 12:09:34 +00:00
|
|
|
for i in $blacklist; do
|
|
|
|
json_add_string "" "$i"
|
|
|
|
done
|
2024-04-15 09:19:44 +00:00
|
|
|
json_close_array
|
|
|
|
|
2024-04-22 08:59:19 +00:00
|
|
|
config_get_bool bridge_local_tx "$cfg" bridge_local_tx 1
|
|
|
|
json_add_boolean bridge_local_tx "$bridge_local_tx"
|
|
|
|
|
|
|
|
config_get_bool bridge_local_rx "$cfg" bridge_local_rx 0
|
|
|
|
json_add_boolean bridge_local_rx "$bridge_local_rx"
|
2022-04-06 12:09:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
reload_service() {
|
|
|
|
config_load bridger
|
|
|
|
|
|
|
|
json_init
|
2024-04-15 09:19:44 +00:00
|
|
|
config_foreach get_defaults defaults
|
2022-04-06 12:09:34 +00:00
|
|
|
|
2024-04-15 09:19:44 +00:00
|
|
|
ubus call bridger set_config "$(json_dump)"
|
2022-04-06 12:09:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
service_triggers() {
|
|
|
|
procd_add_reload_trigger bridger
|
|
|
|
}
|
|
|
|
|
|
|
|
start_service() {
|
|
|
|
procd_open_instance
|
|
|
|
procd_set_param command "$PROG"
|
|
|
|
procd_set_param respawn
|
|
|
|
procd_close_instance
|
|
|
|
}
|
|
|
|
|
|
|
|
service_started() {
|
|
|
|
ubus -t 10 wait_for bridger
|
|
|
|
[ $? = 0 ] && reload_service
|
|
|
|
}
|