#!/bin/ksh
#
# Component: cd
#
# Description:
#  Control script of component cd
#
# 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
		CD_VAR=$VAR/cd

	EndOfInlineData

} #do_shell_()


do_start_()
{

	[ ! -d "$CD_VAR" ] && mkdir $CD_VAR
	
	if [ ! -f "$CD_VAR/cdwriter.cfg" ] ; then
		cat <<-ENDOFWRITERCONFIG > $CD_VAR/cdwriter.cfg
			WRITER_DEV="0,0,0"
			WRITER_OPTS="speed=4 driveropts=burnproof"
		ENDOFWRITERCONFIG
	fi

} #do_start

do_backup_()
{
	BackupType="full"
	[ -n "$1" ] && BackupType=$1

	if [ "cd" = "$BackupType" -o "full" = "$BackupType" -o "config" = "$BackupType" ] ; then
		echo ${CD_VAR#$HOME/}
	else
		exit 0
	fi
} #do_backup_()


#
# 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 ${CD_VAR#$HOME/}
	EOFLISTBACKUP
}

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

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

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

fi
