#!/bin/sh /etc/rc.common
|
|
#
|
|
|
|
START=99
|
|
|
|
exec 2>/dev/null
|
|
adb_pid="${$}"
|
|
adb_script="/usr/bin/adblock-update.sh"
|
|
adb_pidfile="/var/run/adblock.pid"
|
|
adb_logger="/usr/bin/logger"
|
|
adb_uci="/sbin/uci"
|
|
|
|
if [ -t 1 ]
|
|
then
|
|
log_parm="-s"
|
|
unset bg_parm
|
|
else
|
|
unset log_parm
|
|
bg_parm="&"
|
|
fi
|
|
|
|
if [ -r "${adb_pidfile}" ]
|
|
then
|
|
"${adb_logger}" ${log_parm} -t "adblock[${adb_pid}] error" "adblock service already running ($(cat ${adb_pidfile})" 2>&1
|
|
exit 255
|
|
fi
|
|
|
|
remove_config()
|
|
{
|
|
local value opt section="${1}" options="adb_src_timestamp adb_src_count"
|
|
for opt in ${options}
|
|
do
|
|
${adb_uci} -q delete "adblock.${section}.${opt}"
|
|
done
|
|
}
|
|
|
|
boot()
|
|
{
|
|
return 0
|
|
}
|
|
|
|
start()
|
|
{
|
|
eval "${adb_script}" ${bg_parm}
|
|
return 0
|
|
}
|
|
|
|
restart()
|
|
{
|
|
stop
|
|
start
|
|
}
|
|
|
|
reload()
|
|
{
|
|
stop
|
|
start
|
|
}
|
|
|
|
stop()
|
|
{
|
|
rm_done="$(find "/tmp/dnsmasq.d" -maxdepth 1 -type f -name "adb_list.*" -print -exec rm -f "{}" \;)"
|
|
rc=${?}
|
|
if [ $((rc)) -eq 0 ] && [ -n "${rm_done}" ]
|
|
then
|
|
. "/lib/functions.sh"
|
|
config_load adblock
|
|
config_foreach remove_config source
|
|
${adb_uci} -q delete "adblock.global.adb_overall_count"
|
|
${adb_uci} -q commit "adblock"
|
|
/etc/init.d/dnsmasq restart
|
|
/etc/init.d/firewall restart
|
|
fi
|
|
|
|
uhttpd_pid="$(ps | grep "[u]httpd.*\-h /www/adblock" | awk '{print $1}')"
|
|
if [ -n "${uhttpd_pid}" ]
|
|
then
|
|
kill -9 "${uhttpd_pid}"
|
|
fi
|
|
|
|
if [ -n "${rm_done}" ] || [ -n "${uhttpd_pid}" ]
|
|
then
|
|
"${adb_logger}" ${log_parm} -t "adblock[${adb_pid}] info " "all adblock related services stopped" 2>&1
|
|
fi
|
|
return 0
|
|
}
|