You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

73 lines
1.3 KiB

#!/bin/sh /etc/rc.common
#
START=90
USE_PROCD=1
EXTRA_COMMANDS="suspend resume query"
EXTRA_HELP=" suspend Suspend adblock processing
resume Resume adblock processing
query <DOMAIN> Query active blocklists for specific domain"
adb_init="/etc/init.d/adblock"
adb_script="/usr/bin/adblock.sh"
boot()
{
local list iface="$(uci -q get adblock.global.adb_iface)"
for name in ${iface}
do
list="${list} network.interface.${name}"
done
ubus -t 60 wait_for network.interface ${list} 2>/dev/null
rc_procd start_service
}
start_service()
{
if [ $("${adb_init}" enabled; printf ${?}) -eq 0 ]
then
procd_open_instance "adblock"
procd_set_param command "${adb_script}" "${@}"
procd_set_param stdout 1
procd_set_param stderr 1
procd_close_instance
fi
}
stop_service()
{
rc_procd "${adb_script}" stop
}
restart()
{
rc_procd start_service restart
}
suspend()
{
rc_procd "${adb_script}" suspend
}
resume()
{
rc_procd "${adb_script}" resume
}
query()
{
rc_procd "${adb_script}" query "${1}"
}
service_triggers()
{
local iface="$(uci -q get adblock.global.adb_iface)"
for name in ${iface}
do
procd_add_interface_trigger "interface.*.up" "${name}" "${adb_init}" start
done
procd_add_config_trigger "config.change" "adblock" "${adb_init}" start
}