packages/net/adblock/files/adblock.init
Dirk Brenken 7eedce0a58 adblock: release 2.0.0
* changed complete dnsmasq handling
  - no longer redirect ad requests to internal web server via firewall 
    rules etc., in fact send back a simple NXDOMAIN for all
    ad related (sub-)domains
  - smaller memory footprint for block lists
  - removed needless uhttpd instances
  - removed needless firewall rules/redirects
* init/hotplug system migrated to procd
  - removed hotplug.d script, now using procd interface trigger
* reduced code size/complexity
  - removed needless internal pre-checks & function blocks,
    no longer rely on a separate helper library
  - removed flash writes to adblock config
* support different download tools like wget (default), aria2c,
uclient-fetch, curl (see online doc)
* adblock status/statistics via ubus call (see online doc)
* various bug fixes
* documentation update
* changed makefile copyright notice

Signed-off-by: Dirk Brenken <dev@brenken.org>
2016-12-20 12:17:08 +01:00

82 lines
1.6 KiB
Bash
Executable file

#!/bin/sh /etc/rc.common
#
START=90
USE_PROCD=1
EXTRA_COMMANDS="suspend resume"
EXTRA_HELP=" suspend Suspend adblock processing
resume Resume adblock processing"
adb_script="/usr/bin/adblock.sh"
adb_iface="$(uci -q get adblock.global.adb_iface)"
boot()
{
local wanif4 wanif6
ubus -t 30 wait_for network.interface
if [ ${?} -eq 0 ]
then
. "/lib/functions/network.sh"
network_find_wan wanif4
network_find_wan6 wanif6
if [ -n "${wanif4}" ] || [ -n "${wanif6}" ]
then
rc_procd start_service
else
rc_procd service_triggers
fi
fi
}
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
}
suspend()
{
rc_procd start_service suspend
}
resume()
{
rc_procd start_service resume
}
service_triggers()
{
local iface
procd_add_config_trigger "config.change" "adblock" /etc/init.d/adblock start
if [ -z "${adb_iface}" ]
then
procd_add_raw_trigger "interface.*.up" 1000 /etc/init.d/adblock start
else
for iface in ${adb_iface}
do
procd_add_interface_trigger "interface.*.up" "${iface}" /etc/init.d/adblock start
done
fi
}