1@echo off 2set SERVICE_NAME=MidPoint 3set "BIN_DIR=%~dp0%~2" 4 5if not "%MIDPOINT_HOME%" == "" goto gotHome 6cd "%BIN_DIR%.." 7mkdir var 8cd var 9mkdir log 10cd "%BIN_DIR%.." 11set "MIDPOINT_HOME=%cd%\var" 12:gotHome 13 14REM if script for service exists 15if exist "%BIN_DIR%\service.bat" goto okBoot 16echo The service.bat file is not in \bin directory or is no accessible 17goto end 18:okBoot 19 20if exist "%BIN_DIR%\midpoint.exe" goto okHome 21echo The midpoint.exe was not found… 22goto end 23:okHome 24rem Make sure prerequisite environment variables are set 25if not "%JAVA_HOME%" == "" goto gotJdkHome 26if not "%JRE_HOME%" == "" goto gotJreHome 27echo Neither the JAVA_HOME nor the JRE_HOME environment variable is defined 28echo Service will try to guess them from the registry. 29goto okJavaHome 30:gotJreHome 31 32if not exist "%JRE_HOME%\bin\java.exe" goto noJavaHome 33if not exist "%JRE_HOME%\bin\javaw.exe" goto noJavaHome 34goto okJavaHome 35:gotJdkHome 36 37if not exist "%JAVA_HOME%\bin\javac.exe" goto noJavaHome 38rem Java 9 has a different directory structure 39if exist "%JAVA_HOME%\jre\bin\java.exe" goto preJava9Layout 40if not exist "%JAVA_HOME%\bin\java.exe" goto noJavaHome 41if not exist "%JAVA_HOME%\bin\javaw.exe" goto noJavaHome 42if not "%JRE_HOME%" == "" goto okJavaHome 43set "JRE_HOME=%JAVA_HOME%" 44goto okJavaHome 45:preJava9Layout 46 47if not exist "%JAVA_HOME%\jre\bin\javaw.exe" goto noJavaHome 48if not "%JRE_HOME%" == "" goto okJavaHome 49set "JRE_HOME=%JAVA_HOME%\jre" 50goto okJavaHome 51:noJavaHome 52 53echo The JAVA_HOME environment variable is not defined correctly 54echo This environment variable is needed to run this program 55echo NB: JAVA_HOME should point to a JDK not a JRE 56goto end 57:okJavaHome 58 59REM MIDPOINT_WAR if not defined 60if exist "%cd%\lib\midpoint.war" goto gotWar 61echo The midpoint.war is not in \lib directory 62echo Can not start midPoint 63goto end 64:gotWar 65 66if "%MIDPOINT_HOME%" == "%MIDPOINT_HOME:;=%" goto homeNoSemicolon 67echo Using MIDPOINT_HOME: "%MIDPOINT_HOME%" 68echo Unable to start as MIDPOINT_HOME contains a semicolon (;) character 69goto end 70:homeNoSemicolon 71 72REM ----- Execute The Requested Command --------------------------------------- 73 74set EXECUTABLE=%BIN_DIR%\midpoint.exe 75set PR_INSTALL=%EXECUTABLE% 76set MIDPOINT_START_CLASS=com.evolveum.midpoint.tools.layout.MidPointWarLauncher 77 78REM Service log configuration 79set PR_LOGPREFIX=%SERVICE_NAME% 80set PR_LOGPATH=%MIDPOINT_HOME%\log 81set PR_STDOUTPUT=auto 82set PR_STDERROR=auto 83set PR_LOGLEVEL=Error 84 85REM Path to java installation 86REM Try to use the server jvm 87set "PR_JVM=%JRE_HOME%\bin\server\jvm.dll" 88if exist "%PR_JVM%" goto foundJvm 89REM Try to use the client jvm 90set "PR_JVM=%JRE_HOME%\bin\client\jvm.dll" 91if exist "%PR_JVM%" goto foundJvm 92echo Warning: Neither 'server' nor 'client' jvm.dll was found at JRE_HOME. 93set PR_JVM=auto 94:foundJvm 95 96set PR_CLASSPATH=%cd%\lib\midpoint.war 97 98REM Statup configuration 99set PR_STARTUP=auto 100set PR_STARTMODE=jvm 101set PR_STARTMETHOD=main 102set PR_STARTPARAMS=start 103set PR_STARTCLASS=%MIDPOINT_START_CLASS% 104 105REM Shutdown configuration 106set PR_STOPMODE=jvm 107set PR_STOPMETHOD=%PR_STARTMETHOD% 108set PR_STOPPARAMS=stop 109set PR_STOPCLASS=%MIDPOINT_START_CLASS% 110 111REM JVM configuration 112set PR_JVMMS=1024 113set PR_JVMMX=1024 114 115if %1 == install goto doInstall 116if %1 == remove goto doRemove 117if %1 == uninstall goto doRemove 118echo Unknown parameter "%1" 119 120:doRemove 121rem Remove the service 122"%EXECUTABLE%" //DS//%SERVICE_NAME% 123echo The service '%SERVICE_NAME%' has been removed 124goto end 125 126:doInstall 127REM Install the service 128echo Installing the service '%SERVICE_NAME%' ... 129echo Using MIDPOINT_HOME: "%MIDPOINT_HOME%" 130echo Using JAVA_HOME: "%JAVA_HOME%" 131echo Using JRE_HOME: "%JRE_HOME%" 132 133REM Install service 134"%PR_INSTALL%" //IS//%SERVICE_NAME% ^ 135--StartMode="%PR_STARTMODE%" ^ 136--StartClass="%PR_STARTCLASS%" ^ 137--StartMethod="%PR_STARTMETHOD%" ^ 138--StopMode="%PR_STOPMODE%" ^ 139--StopClass="%PR_STOPCLASS%" ^ 140--StopMethod="%PR_STOPMETHOD%" ^ 141--StartParams="%PR_STARTPARAMS%" ^ 142--StopParams="%PR_STOPPARAMS%" ^ 143--Jvm="%PR_JVM%" ^ 144--JvmMs="%PR_JVMMS%" ^ 145--JvmMx="%PR_JVMMX%" ^ 146--Startup="%PR_STARTUP%" ^ 147--LogPath="%PR_LOGPATH%" ^ 148--LogPrefix="%SERVICE_NAME%" ^ 149--LogLevel="%PR_LOGLEVEL%" ^ 150--StdOutput="%PR_STDOUTPUT%" ^ 151--StdError="%PR_STDERROR%" ^ 152--JvmOptions -Dmidpoint.home="%MIDPOINT_HOME%";-Dpython.cachedir="%MIDPOINT_HOME%\tmp";-Djavax.net.ssl.trustStore="%MIDPOINT_HOME%\keystore.jceks";-Djavax.net.ssl.trustStoreType=jceks ^ 153--Classpath="%PR_CLASSPATH%" 154 155if not errorlevel 1 goto installed 156echo Failed installing '%SERVICE_NAME%' service 157goto end 158:installed 159 160:end 161cd %CURRENT_DIR% 162