#!/bin/sh /etc/rc.common

START=99

start()
{
        if [ "`ps |grep "dnsmasq_route -d" |grep -v -e dnsmasq_route.sh -e grep -e init.d`" ] ;then
		echo "dnsmasq_route has already started."
        else
                dnsmasq_route.sh &
                echo "dnsmasq_route has started."
        fi
}

stop(){
        ps |grep -e dnsmasq_route.sh -e "dnsmasq_route -d" -e "logread -l" |grep -v -e grep -e rc.common -e "opkg " -e $$ |while read pid a
        do
                kill $pid
        done

        # 29021:	from all to 52.36.200.214 lookup 107
        #清理所有分流路由
        ip ru list |grep ^290 |while read prefix from sip to dip lookup
        do
                ip rule del from $sip to $dip
        done
	echo "dnsmasq_route has stopped."
}

restart(){
	stop
	sleep 1
	start
	echo "dnsmasq_route has restarted."
}

