<?xml version="1.0"?>
<project name="Data server install"  default=""  >

	<taskdef name="createDBPasswordStash" classname="org.eclipse.aperi.install.CreateDBPasswordStash" />
	
	<target name="configureDataServer" depends="" >
		<echo message="Configuring the Data server" level="info" />

		<!-- Update Data Server Configuration -->
		<antcall target="updateDataServerConfig" />
		
		<!-- Update Data Server Launch Script -->
		<echo message="Updating the file: ${basedir}/../datasvr/datasvr.${extension}" level="info" />
		<copy tofile="${basedir}/../datasvr/datasvr.${extension}" file="${basedir}/templates/datasvr/datasvr.${extension}" overwrite="true" />
		<replace file="${basedir}/../datasvr/datasvr.${extension}" token="@base_dir@" value="${basedir}" />
		<replace file="${basedir}/../datasvr/datasvr.${extension}" token="@java_home@" value="${java.home}" />
		<replace file="${basedir}/../datasvr/datasvr.${extension}" token="@max_heap@" value="${server.data.heap}" />
		<replace file="${basedir}/../datasvr/datasvr.${extension}" token="@server_port@" value="${server.data.port}" />

		<chmod perm="ugo+x" file="${basedir}/../${scriptPath}.${extension}" />
		
		<!-- Create the DB Password Stash File used by the Data Server -->
		<createDBPasswordStash password="${db.password}" fileName="${basedir}/../datasvr/configuration/repository.config" /> 
	</target>
	
	<target name="updateDataServerConfig" depends="" >
		<echo message="Updating the properties file: ${basedir}/../datasvr/configuration/server.config" level="info" />
		<copy tofile="${basedir}/../datasvr/configuration/server.config" file="${basedir}/templates/datasvr/configuration/server.config" overwrite="true" />
		<replace file="${basedir}/../datasvr/configuration/server.config" token="@hostname@" value="${server.hostname}" />
		<replace file="${basedir}/../datasvr/configuration/server.config" token="@port@" value="${server.data.port}" />
		<replace file="${basedir}/../datasvr/configuration/server.config" token="@admin_group@" value="${server.data.adminGroup}" />
		<replace file="${basedir}/../datasvr/configuration/server.config" token="@jdbc_driver@" value="${db.driver}" />
		<replace file="${basedir}/../datasvr/configuration/server.config" token="@jdbc_url@" value="jdbc:${db.type}://${db.hostname}:${db.port}/${db.schema}" />
		<replace file="${basedir}/../datasvr/configuration/server.config" token="@db_user@" value="${db.username}" />
		<replace file="${basedir}/../datasvr/configuration/server.config" token="@schema@" value="${db.schema}" />
	</target>
	
	
</project>