#!/bin/sh /etc/rc.common . /usr/share/libubox/jshn.sh . /lib/functions.sh START=96 USE_PROCD=1 OAFD_BIN="/usr/bin/oafd" config_apply() { test -z "$1" && return 1 if [ -e "/dev/appfilter" ];then echo "config json str=$1" echo "$1" >/dev/appfilter fi } clean_rule() { json_init echo "clean appfilter rule..." json_add_int "op" 3 json_add_object "data" json_str=`json_dump` config_apply "$json_str" json_cleanup } load_rule() { json_init json_add_int "op" 1 json_add_object "data" json_add_array "apps" for file in `ls /tmp/appfilter/*.class` do class_name=`echo "$file" | awk -F/ '{print $4}'| awk -F. '{print $1}'` config_get appid_list "appfilter" "${class_name}apps" echo "appid_list=$appid_list" if ! test -z "$appid_list";then for appid in $appid_list: do json_add_int "" $appid done fi done json_str=`json_dump` config_apply "$json_str" json_cleanup } load_mac_list() { json_init config_load appfilter json_add_int "op" 4 json_add_object "data" json_add_array "mac_list" config_get appid_list "user" "users" echo "appid list=$appid_list" for appid in $appid_list: do echo "appid=$appid" json_add_string "" $appid done json_str=`json_dump` config_apply "$json_str" echo "json str=$json_str" json_cleanup } service_triggers() { procd_add_reload_trigger "appfilter" } stop_service(){ clean_rule } start_service(){ gen_class.sh /etc/appfilter/feature.cfg config_load appfilter config_get enable "global" enable echo "enable = $enable" if [ x"$enable" != x"1" ];then echo "appfilter is disabled" echo 0 >/proc/sys/oaf/enable>/dev/null return 0 else insmod oaf >/dev/null echo 1 >/proc/sys/oaf/enable fi load_rule load_mac_list procd_open_instance procd_set_param respawn 60 5 5 procd_set_param stderr 1 procd_set_param command "$OAFD_BIN" procd_close_instance }