1@echo off 2 3setlocal 4 5if "%1" == "start" goto doStart 6if "%1" == "stop" goto doStop 7 8echo Error: No command given. Specify either start or stop. 9goto end 10 11:doStart 12set BIN_DIR=%~dp0 13set LIB_DIR=%BIN_DIR%..\lib 14 15if "%MIDPOINT_HOME%" == "" ( 16 cd "%BIN_DIR%.." 17 if not exist var mkdir var 18 if not exist var\log mkdir var\log 19 set "MIDPOINT_HOME=%BIN_DIR%..\var" 20) 21 22if not exist "%BIN_DIR%midpoint.bat" ( 23 echo Error: The midpoint.bat file is not in bin directory or is not accessible. 24 goto end 25) 26 27set JAVA_OPTS=-Xms2048M -Xmx4096M -Dpython.cachedir="%MIDPOINT_HOME%\tmp" -Djavax.net.ssl.trustStore="%MIDPOINT_HOME%\keystore.jceks" -Djavax.net.ssl.trustStoreType=jceks %JAVA_OPTS% 28 29if not exist "%BIN_DIR%setenv.bat" goto :noSetEnv 30echo Applying %BIN_DIR%setenv.bat 31echo. 32 33call "%BIN_DIR%setenv.bat" 34 35:noSetEnv 36echo Using MIDPOINT_HOME: "%MIDPOINT_HOME%" 37 38if not exist "%LIB_DIR%\midpoint.war" ( 39 echo Error: The midpoint.war is not in the lib directory 40 goto end 41) 42 43if not "%MIDPOINT_HOME%" == "%MIDPOINT_HOME:;=%" ( 44 echo Error: MIDPOINT_HOME contains a semicolon ";" character. 45 goto end 46) 47 48if "%BOOT_OUT%" == "" set BOOT_OUT=%MIDPOINT_HOME%\log\midpoint.out 49echo Using BOOT_OUT: "%BOOT_OUT%" 50 51rem ----- Execute The Requested Start Command --------------------------------------- 52 53shift 54set RUN_JAVA=javaw 55if not "%JAVA_HOME%" == "" set RUN_JAVA=%JAVA_HOME%\bin\javaw 56 57echo Using RUN_JAVA: "%RUN_JAVA%" 58echo Using JAVA_OPTS: "%JAVA_OPTS%" 59echo Using parameters: "%*" 60echo. 61echo Starting midPoint. 62start /b "midPoint" "%RUN_JAVA%" -jar %JAVA_OPTS% -Dmidpoint.home="%MIDPOINT_HOME%" "%LIB_DIR%\midpoint.war" %* > "%BOOT_OUT%" 2>&1 63goto end 64 65:doStop 66 67set MIDPOINT_PORT=8080 68 69shift 70echo Trying to find and stop a process listening on port %MIDPOINT_PORT%... 71set MIDPOINT_FOUND= 72FOR /F "usebackq tokens=5" %%i IN (`netstat -aon ^| findstr "0.0.0.0:%MIDPOINT_PORT% "`) DO ( 73 taskkill /F /PID %%i 74 set MIDPOINT_FOUND=true 75) 76if not "%MIDPOINT_FOUND%" == "true" echo No process listening on %MIDPOINT_PORT% was found. 77goto end 78 79:end 80