packages/net/adblock/files/adblock.init
Dirk Brenken 7609da872d adblock: update to 0.70.0
* openwrt init system support, see /etc/init.d/adblock
* support for two new adblock sources: openphish and ruadlist/easylist
* partial block list restore, i.e. if a single list download failed
* fix performance regression on sites with links to https ad servers
* removed no longer used samples dir
* updated documentation

Signed-off-by: Dirk Brenken <openwrt@brenken.org>
2016-02-15 12:25:21 +01:00

59 lines
1.1 KiB
Bash
Executable file

#!/bin/sh /etc/rc.common
#
START=99
adb_pid="${$}"
adb_script="/usr/bin/adblock-update.sh"
adb_pidfile="/var/run/adblock.pid"
adb_logger="/usr/bin/logger"
if [ -t 1 ]
then
log_term="-s"
fi
if [ -r "${adb_pidfile}" ]
then
"${adb_logger}" ${log_term} -t "adblock[${adb_pid}] error" "adblock service already running ($(cat ${adb_pidfile} 2>/dev/null))"
exit 255
fi
start()
{
"${adb_script}"
}
restart()
{
start
}
reload()
{
stop
start
}
stop()
{
rm_done="$(find "/tmp/dnsmasq.d" -maxdepth 1 -type f -name "adb_list.*" -print -exec rm -f "{}" \; 2>/dev/null)"
rc=${?}
if [ $((rc)) -eq 0 ] && [ -n "${rm_done}" ]
then
/etc/init.d/dnsmasq restart >/dev/null 2>&1
/etc/init.d/firewall restart >/dev/null 2>&1
fi
uhttpd_pid="$(ps 2>/dev/null | grep "[u]httpd.*\-h /www/adblock" 2>/dev/null | awk '{print $1}' 2>/dev/null)"
if [ -n "${uhttpd_pid}" ]
then
kill -9 "${uhttpd_pid}" >/dev/null 2>&1
fi
if [ -n "${rm_done}" ] || [ -n "${uhttpd_pid}" ]
then
"${adb_logger}" ${log_term} -t "adblock[${adb_pid}] info " "all adblock related services stopped"
fi
return 0
}