16e7c7370SDerry#!/bin/sh /etc/rc.common
22489a517SDerry. /usr/share/libubox/jshn.sh
32489a517SDerry. /lib/functions.sh
46e7c7370SDerry
56e7c7370SDerrySTART=96
669ba02bdSzaiyuyishiyouduUSE_PROCD=1
72489a517SDerryOAFD_BIN="/usr/bin/oafd"
804b70135SderryFEATURE_FILE="/tmp/feature.cfg"
904b70135SderryCLASS_FILE="/tmp/app_class.txt"
102489a517SDerryservice_triggers()
112489a517SDerry{
122489a517SDerry	procd_add_reload_trigger "appfilter"
132489a517SDerry}
142489a517SDerry
152489a517SDerrystop_service(){
16e73beb8cSDerry	killall -9 oafd
17af168f6fSDerry	rmmod oaf
182489a517SDerry}
192489a517SDerry
202489a517SDerrystart_service(){
21fd21eb38Sderry	local update
22fd21eb38Sderry	rm $FEATURE_FILE
23fd21eb38Sderry	update=`uci get appfilter.feature.update`
24fd21eb38Sderry	if [ x"1" == x"$update" ];then
2504b70135Sderry		ln -s /etc/appfilter/feature.cfg $FEATURE_FILE
2604b70135Sderry	else
2711426bd1Sderry		uci get luci.languages.zh_cn >/dev/null 2>&1
28fd21eb38Sderry		if [ $? -eq 0 ];then
29fd21eb38Sderry			test -f $FEATURE_FILE && rm $FEATURE_FILE
30fd21eb38Sderry			ln -s /etc/appfilter/feature_cn.cfg $FEATURE_FILE
3104b70135Sderry		else
32fd21eb38Sderry			ln -s /etc/appfilter/feature_en.cfg $FEATURE_FILE
3304b70135Sderry		fi
3404b70135Sderry	fi
3504b70135Sderry	gen_class.sh /tmp/feature.cfg
36e1b21d21SDerry	insmod oaf
37e73beb8cSDerry	/usr/bin/oaf_rule reload
3869ba02bdSzaiyuyishiyoudu	procd_open_instance
392489a517SDerry	procd_set_param respawn 60 5 5
4069ba02bdSzaiyuyishiyoudu	procd_set_param stderr 1
412489a517SDerry	procd_set_param command "$OAFD_BIN"
4269ba02bdSzaiyuyishiyoudu	procd_close_instance
436e7c7370SDerry}
44