#!/bin/sh
# ####################################################################
# Exceed Connection Server 13.7
# Copyright (c) 1997-2009 Open Text Corporation. All Rights Reserved.
# ####################################################################
# ecsinstall
# $Revision: 14922 $
# ####################################################################
 

# bash script to create the file node.cfg.
# tries to make intelligent guesses about options and
# offers the user the option to change these guesses

# the name of the log file to append information into is the 
# only argument

. ./sys/msg.txt

logfile=$1

cd ..
rootdir=`pwd`"/"
sysdir=${rootdir}bin/sys/

pre="    "

infoscript="./ecsinfo"

sslmark="bin/openssl.cnf"
sslable="0"
sshcommand=
dspwd=
dshash=

usage()
{
	if [ "${logfile}xxxx" = "xxxx" ]; then
		${ECHO} ${pre}${USAGE}: $0 $LOGFILE_ARG
		exit 1
	fi
}

update_config_file_server_section()
{
	cat >> $config_file << EOF
[SERVER]
EoDSSHCommand=$sshcommand
ECSSSLLibPath=$ssl_lib_path_name
ECSCryptoLibPath=$crypto_lib_path_name

EOF
}


update_config_file_common_section()
{
	cat >> $config_file << EOF
[COMMON]
EoDHomeDir=$rootdir
EoDSSLAvailable=$sslable
EoDDataStoreDir=
EoDDataStorePassword=$dspwd

EOF
}

update_cluster_file()
{
	cat >> "$cluster_file" << EOF
[CLUSTER]
EoDCMPassword=$dshash
EoDCMSSL=0
EoDCMLog=html
EoDCMDefXconfig=Passive.cfg
EoDCMAuth=native
EoDCMAuthPAMPwdPrompt=Password:
EoDCMPreferredPCM=
EoDLoadBalancing=cpu
EoDCMLogLevel=1
EoDCMLogRollSize=0
EoDCMLogRollTime=0
EodShowShareConfirmDialog=0
ECSUseKerberos=0 
ECSUseUserCredentials=1
ECSldapHost=
ECSldapSSL=0
ECSldapProxyUserName=
ECSldapProxyPassWord=
ECSldapBase=
UseLicenseServer=0
LicenseServerHost=
LicenseServerAuthKey=

EOF
}

update_logfile()
{
	cat >> $logfile << EOF
$INFO $TTXPM_CREATING_FILE "node.cfg":
$INFO EoDServerLog=html
$INFO EoDHomeDir=$rootdir
$INFO EoDSSLAvailable=$sslable
$INFO EoDDataStoreDir=
$INFO EoDDataStorePassword=$dspwd

EOF
}

updateConfigClusterLogFiles()
{
	update_config_file_common_section
	update_config_file_server_section

	update_cluster_file
	update_logfile
}

usage

. ./bin/sys/getsslinfo.sh

cd bin

updateConfigClusterLogFiles

# exit with success
exit 0
