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

START=97

CRON_FILE=/etc/crontabs/root

add_cron(){
 
	local enabled
	
	config_get_bool enabled $1 enabled
 
	if	[ $enabled = 1 ] ; then 
		local minute
		local hour
		
		config_get minute $1 minute
		config_get hour $1 hour
		
		echo "$minute $hour * * * /usr/bin/cloudflarespeedtest/cloudflarespeedtest.sh start" >> $CRON_FILE
		crontab $CRON_FILE	 
	fi
}

del_cron()
{
	sed -i '/cloudflarespeedtest/d' $CRON_FILE
	/etc/init.d/cron restart
}

start()
{	
	stop 
	config_load cloudflarespeedtest
  	config_foreach add_cron global
}

stop()
{
	del_cron
}
