#!/bin/ksh

# Component: prior
#
# Description:
#  Control script of component prior
#
# 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
		PRIOR_HOME=$HOME/component/prior
		PRIOR_VAR=\$VAR/prior
		PRIOR_ORDER_CFG=\$PRIOR_VAR/order.cfg

	EndOfInlineData

} #do_shell_()

do_start_()
{
	# Creating data directories
	[ ! -d "$PRIOR_VAR" ] && mkdir $PRIOR_VAR 2>/dev/null

	# prior config
	[ ! -f "$PRIOR_VAR/prior.cfg" ] && cp $PRIOR_HOME/prior.cfg $PRIOR_VAR/

	# prior retrieve config
	[ ! -f "$PRIOR_VAR/priorretrieve.cfg" ] && cp $PRIOR_HOME/priorretrieve.cfg $PRIOR_VAR/

	# make prior.cfg and priorretrieve.cfg writeable
	chmod +w $PRIOR_VAR/prior.cfg $PRIOR_HOME/priorretrieve.cfg

} #do_start_()


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

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

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

fi
