#!/bin/sh
# COPYRIGHT (C) NEC CORPORATION 2009, 2010
# Rev.6

# Source function library.
. /opt/nec/hasdrtc/drtc_functions
[ -f /etc/hasdrtc.conf ] && . /etc/hasdrtc.conf
#. ./drtc_functions;			#debug

NR_CRETRY=${NR_CRETRY=50}
SLEEP_CRETRY=${SLEEP_CRETRY=10}
DELAY_REBOOT=${DELAY_REBOOT=900}
MESSAGE1=correctdrtc

function need_adjust () {
	if [ $(($CYEAR  % 2)) -ne 0 -o $(($CYEAR / 10 % 2)) -ne 1 ]
	then
		return 1
	fi
	if [ "$CMONTH" = "02" -a "$CDATE" = "29" ]
	then
		return 0
	fi
	if [ "$CMONTH" = "03" -a "$CDATE" = "01" ]
	then
		return 0
	fi

	return 1
}


get_systime
get_param NR_CRETRY -PLUS
get_param SLEEP_CRETRY -PLUS
if [ `/bin/date +%w` -eq 0 ]
then
	check_config cron
	log_chkresult $?
fi

need_adjust && drtc_exe -WRITE $NR_CRETRY $SLEEP_CRETRY


