#!/bin/ksh
#
# Component: ct
#
# Description:
#  Control script of component ct
#
# Last Updated     : $Author$
# Update Date Time : $Date$
# RCS File Name    : $RCSfile$
# RCS Revision     : $Revision$
# Locked by        : $Locker$
# Symbolic name    : $Name$
# State            : $State$

#--- INIT ------------------------------
#needs $HOME
. $HOME/etc/ctrl.main.shi

[ -f $HOME/etc/setenv.sh ] && . $HOME/etc/setenv.sh

#--- FUNC ------------------------------
do_shell_()
{
	cat <<-EndOfInlineData
		CT_HOME=$HOME/component/ct
		CT_FLAG_FILE=$TMP/ct.chk
		CERTIFICATE_START_WARNING=5
		CERTIFICATE_GRACE_OVER=5
		CERTIFICATE_FILE=$CONF/.ct
	EndOfInlineData

} #do_shell_()

do_start_()
{
	[ -f "$CERTIFICATE_FILE" ] && $CT_HOME/ct.sh >/dev/null 2>&1

} #do_start_()

do_crontab_()
{
	# Get time for starting ct.sh from crontabSchedule settings
	[ -f "$CONF/crontabSchedule.shi" ] && . $CONF/crontabSchedule.shi
	[ -z "$CtSh" ] && CtSh="14 05"
	
	cat <<-EOI
		$CtSh * * * $CT_HOME/ct.sh >/dev/null 2>&1
	EOI

} #do_crontab_()

#
# List files/tables to be backed up grouped by categories
#
# output lines should be in '<category> <type> <names>' format
#
do_listbackup_()
{
	cat <<-EOFLISTBACKUP
		config.license FILE ${CERTIFICATE_FILE#$HOME/}
	EOFLISTBACKUP
}

#--- MAIN ------------------------------

check_action_ $1
if [ 0 = $? ]; then
	do_$1_

else
	echo "--- Component ct [ctrl $$]: Bad command: $1" >&2
	exit 1

fi
