@echo off rem ******************************************************************************* rem Licensed Materials - Property of IBM rem (c) Copyright IBM Corporation 2015, 2020. All Rights Reserved. rem rem Note to U.S. Government Users Restricted Rights: rem Use, duplication or disclosure restricted by GSA ADP Schedule rem Contract with IBM Corp. rem ******************************************************************************* setlocal enabledelayedexpansion if not defined START_DIR ( echo Execute the server.startup.bat or server.shutdown.bat script instead of executing this script directly exit/b 1 ) rem cannot invoke liberty.server.bat script with full pathname containing spaces pushd "%START_DIR%" if "%1"=="" ( echo No action specified exit/b 1 ) set ACTION=%1 set CLM_LIBERTY_SERVER_NAME=clm rem serverName value to pass to Liberty/bin/server invocation if "%2"=="" ( set CLM_SERVICE_NAME=%CLM_LIBERTY_SERVER_NAME% ) else ( set CLM_SERVICE_NAME=%2 ) rem location of the WAS Liberty installation set CLM_LIBERTY_HOME=liberty\wlp rem Display name of Windows service, when running as a service set CLM_SERVICE_DISPLAYNAME=Engineering Lifecycle Management rem Description of Windows service, when running as a service set CLM_SERVICE_DESCRIPTION=IBM Engineering Lifecycle Management on WebSphere Liberty Profile rem server folder location - must be relative for xcopy set CLM_LIBERTY_SERVER_DIR=liberty\servers\%CLM_LIBERTY_SERVER_NAME% rem location Liberty uses to find CLM app WARs, server.xml, etc. - must be absolute set WLP_USER_DIR=%cd%\liberty rem server template location, contents will be copied into Liberty server area - must be relative for xcopy set CLM_LIBERTY_SERVER_TEMPLATE=liberty\clmServerTemplate set JVM_ARGS=%JAVA_OPTS% set WLP_DEBUG_ADDRESS=8000 rem if the server hasn't been created yet, create it first if not exist "%WLP_USER_DIR%"\servers\%CLM_LIBERTY_SERVER_NAME% ( call "%CLM_LIBERTY_HOME%"\bin\server.bat create %CLM_LIBERTY_SERVER_NAME% if ERRORLEVEL 1 ( goto :FINISH ) xcopy "%CLM_LIBERTY_SERVER_TEMPLATE%" "%CLM_LIBERTY_SERVER_DIR%" /y /e /q if ERRORLEVEL 1 ( goto :FINISH ) ) else ( rem copy any additional applications installed since the server was created for /d %%d in ("%CLM_LIBERTY_SERVER_TEMPLATE%"\apps\*) do ( if not exist "%CLM_LIBERTY_SERVER_DIR%"\apps\%%~nxd ( xcopy "%%d" "%CLM_LIBERTY_SERVER_DIR%"\apps\%%~nxd /i /e /q if ERRORLEVEL 1 ( goto :FINISH ) ) ) ) rem try to create "logs" directory link, if it doesn't exist if not "%1"=="stop" ( if not exist "%CLM_LIBERTY_SERVER_DIR%\logs" ( mkdir "%CLM_LIBERTY_SERVER_DIR%\logs" ) if not exist logs ( mklink /d logs "%CLM_LIBERTY_SERVER_DIR%\logs" 1>nul 2>nul if ERRORLEVEL 1 ( echo Server logs are in %CLM_LIBERTY_SERVER_DIR%\logs echo Execute this script in a command shell run as administrator to create a link to the logs in this directory. ) ) ) if "%ACTION%"=="registerWinService" ( "%CLM_LIBERTY_HOME%\bin\tools\win\prunsrv.exe" //IS//%CLM_SERVICE_NAME% ^ --Startup=manual ^ --DisplayName="%CLM_SERVICE_DISPLAYNAME% (%CLM_SERVICE_NAME%)" ^ --Description="%CLM_SERVICE_DESCRIPTION%" ^ ++DependsOn=Tcpip ^ --LogPath="%CLM_LIBERTY_SERVER_DIR%\logs" ^ --StdOutput=auto ^ --StdError=auto ^ --StartMode=exe ^ --StartPath="%START_DIR%" ^ --StartImage="%START_DIR%\server.startup.bat" ^ --StopMode=exe ^ --StopPath="%START_DIR%" ^ --StopImage="%START_DIR%\server.shutdown.bat" ) else if "%ACTION%"=="unregisterWinService" ( "%CLM_LIBERTY_HOME%\bin\tools\win\prunsrv.exe" //DS//%CLM_SERVICE_NAME% ) else if "%ACTION%"=="startWinService" ( "%CLM_LIBERTY_HOME%\bin\tools\win\prunsrv.exe" //ES//%CLM_SERVICE_NAME% ) else if "%ACTION%"=="stopWinService" ( "%CLM_LIBERTY_HOME%\bin\tools\win\prunsrv.exe" //SS//%CLM_SERVICE_NAME% ) else if not "%ACTION%"=="create" ( if "%CLEAN%"=="true" set ACTION_ARG=--clean call "%CLM_LIBERTY_HOME%"\bin\server.bat %ACTION% %CLM_LIBERTY_SERVER_NAME% !ACTION_ARG! ) :FINISH popd endlocal