packages/net/adblock/files/adblock.init
Dirk Brenken 9500430231 adblock: release 2.3.0
* automatically selects dnsmasq or unbound as dns backend
* add the new 'adguard' source, a combined/quite effective block list
* remove needless dns backend restarts
* optimize adblock restart behavior
* optimize block list processing on inotify enabled filesystems
* better return code checking on block list download
* fix boot function/startup on Chaos Calmer
* fix a bug in blocklist removal function
* add more (optional) debug output
* move backup options to global config
* documentation update

Signed-off-by: Dirk Brenken <dev@brenken.org>
2017-02-05 07:07:10 +01:00

95 lines
1.8 KiB
Bash
Executable file

#!/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_script="/usr/bin/adblock.sh"
boot()
{
local wanif4 wanif6 cnt=0
. "/lib/functions/network.sh"
while [ ${cnt} -le 30 ]
do
network_find_wan wanif4
network_find_wan6 wanif6
if [ -n "${wanif4}" ] || [ -n "${wanif6}" ] || [ ${cnt} -eq 30 ]
then
rc_procd start_service
return 0
else
sleep 1
cnt=$((cnt+1))
network_flush_cache
fi
done
}
start_service()
{
if [ $(/etc/init.d/adblock enabled; printf ${?}) -eq 0 ]
then
procd_open_instance "adblock"
procd_set_param env adb_procd="true"
procd_set_param command "${adb_script}" "${@}"
procd_set_param stdout 1
procd_set_param stderr 1
procd_close_instance
fi
}
reload_service()
{
rc_procd start_service reload
}
stop_service()
{
export adb_procd="true"
rc_procd "${adb_script}" stop
}
restart()
{
rc_procd start_service restart
}
suspend()
{
rc_procd start_service suspend
}
resume()
{
rc_procd start_service resume
}
query()
{
export adb_procd="true"
rc_procd "${adb_script}" query "${1}"
}
service_triggers()
{
local iface="$(uci -q get adblock.global.adb_iface)"
if [ -z "${iface}" ]
then
procd_add_raw_trigger "interface.*.up" 1000 /etc/init.d/adblock start
else
for name in ${iface}
do
procd_add_interface_trigger "interface.*.up" "${name}" /etc/init.d/adblock start
done
fi
procd_add_config_trigger "config.change" "adblock" /etc/init.d/adblock start
}