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

START=64

RULE_LIBDIR=/lib/freeStrategy

rule(){
	. ${RULE_LIBDIR}/core_rule.sh
	rule_$1
}

cron_start(){
	# start cron to update ip of url
	[ ! -f /etc/crontabs/root ] && touch /etc/crontabs/root
	echo "*/5 * * * * /bin/sh /lib/freeStrategy/add_delete.sh url" > /tmp/freeStrategy_save
	crontab -l | grep -v "freeStrategy" | cat - /tmp/freeStrategy_save | crontab -
	/etc/init.d/cron start
	rm -f /tmp/freeStrategy_save
}

cron_stop(){
	[ ! -f /etc/crontabs/root ] && touch /etc/crontabs/root
	crontab -l | grep -v "freeStrategy" || {
		#/etc/init.d/cron stop
		crontab -l | sed "/freeStrategy/d" | crontab -	
		/etc/init.d/cron restart
	}
}

start(){
	cron_start

	rule start
}

stop(){
	cron_stop

	rule stop
}

restart(){
	cron_start

	rule restart
}

reload(){
	cron_start

	rule reload
}
boot(){
	start
	lua /usr/lib/lua/omada_server/freePolicy.lua load
}
