echo off

call %~dp0\serviceInit.bat

call %CATALINA_HOME%\bin\service.bat install %SERVICE_NAME%

set EXECUTABLE=%CATALINA_HOME%\bin\%TOMCAT_EXE%

"%EXECUTABLE%" //US//%SERVICE_NAME% --DisplayName="%SERVICE_NAME%"

"%EXECUTABLE%" //US//%SERVICE_NAME% ++JvmOptions ^
	"-Djava.security.auth.login.config=%JOSSO_CONF%;"

"%EXECUTABLE%" //US//%SERVICE_NAME% --JvmMs %JvmMs% --JvmMx %JvmMx% --JvmSs %JvmSs%

"%EXECUTABLE%" //US//%SERVICE_NAME% ++JvmOptions ^
	"-DshutdownPort=%SHUTDOWN_PORT%;-DconnectorPort=%CONNECTOR_PORT%;-DajpPort=%AJP_PORT%;"

"%EXECUTABLE%" //US//%SERVICE_NAME% ++JvmOptions ^
	"-DengineName=%ENGINE_NAME%;-DconnectionDriver=%REALM_DRIVER%;-DconnectionUrl=%REALM_URL%;-DconnectionName=%REALM_NAME%;"

"%EXECUTABLE%" //US//%SERVICE_NAME% ++JvmOptions ^
	"-DconnectionPassword=%REALM_PASSWORD%;-DappBase=%APP_BASE%;-DworkDir=%WORK_DIR%;-DlogsDir=%LOGS_DIR%;-DSYS_LOG_URL=%SYS_LOG_URL%;"

"%EXECUTABLE%" //US//%SERVICE_NAME% ++JvmOptions ^
	"-Xloggc:%CATALINA_HOME%\logs\%COMPUTERNAME%\%ENGINE_NAME%\gc.log;-XX:+PrintGCDetails;-XX:+PrintClassHistogram;"

"%EXECUTABLE%" //US//%SERVICE_NAME% ++JvmOptions ^
	"-XX:PermSize=128M;-XX:MaxPermSize=128M;"

"%EXECUTABLE%" //US//%SERVICE_NAME% --Environment ^
	"REALM_DRIVER=%REALM_DRIVER%;REALM_URL=%REALM_URL%;REALM_NAME=%REALM_NAME%;REALM_PASSWORD=%REALM_PASSWORD%;"

"%EXECUTABLE%" //US//%SERVICE_NAME% ++Environment ^
	"OFFICE_HOME=%OFFICE_HOME%;CONNECTOR_PORT=%CONNECTOR_PORT%;PATH='%PATH%;';"

sc config %SERVICE_NAME% start= auto

sc config %SERVICE_NAME% obj= %SERVICE_USER% password= %SERVICE_PASSWORD%

sc start %SERVICE_NAME%

pause