#!/bin/sh /etc/rc.common
# Copyright (C) 2006 OpenWrt.org
START=50
 
CRONTABS=/tmp/etc/crontabs
CRON_SPOOL=/var/spool/cron

CRON_ROOT_FILE=${CRONTABS}/root

start () {	
	mkdir -p $CRON_SPOOL
	[ -d $CRONTABS ] && rm -fr $CRONTABS
	mkdir -p $CRONTABS
	[ -L ${CRON_SPOOL}/crontabs ] || ln -s $CRONTABS ${CRON_SPOOL}/crontabs

	# Generate `Block Sites` && `Block Services` && `E-mail Notification`
	# for scheduling.
	/sbin/cmdsched
	/www/cgi-bin/firewall_function.sh blk_sched restart

	# Start NTP when `time_zone` is reset.
	export TZ=`/bin/config get time_zone`
    
	PID="$(pidof crond)"
	if [ -z $PID ]; then
	    crond -c $CRONTABS
	fi 
}

stop() {
	killall -9 crond
}

restart() {
	stop
	start
}
