#!/bin/ksh
#
# Component: viewer
#
# Description:
#  Control script of component viewer
#

#--- INIT ------------------------------
#needs $HOME

. $HOME/etc/ctrl.main.shi

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


#--- FUNC ------------------------------

do_shell_()
{
	cat <<-EndOfInlineData
		DOWNLOAD_HOME=$HOME/component/download
		DOWNLOAD_HTDOCS=$HOME/htdocs/download
	EndOfInlineData

}

do_start_()
{
    [ -h "${DOWNLOAD_HTDOCS}" ] && rm "${DOWNLOAD_HTDOCS}"
    [ ! -d "${DOWNLOAD_HTDOCS}" ] && mkdir "${DOWNLOAD_HTDOCS}"

	find "${DOWNLOAD_HTDOCS}" -xtype l -delete

	for f in "${DOWNLOAD_HOME}"/*; do
		[[ "$f" == */ctrl ]] && continue
		ln -sfn $f "${DOWNLOAD_HTDOCS}/"
	done

} #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
#		data.plugins FILE ${DATA#$HOME/}/plugins
#		data.plugins.x64 FILE ${DATA#$HOME/}/plugins/x64
#	EOFLISTBACKUP
#}

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

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

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

fi
