Skip to content

Instantly share code, notes, and snippets.

@BenMatheja
Created December 10, 2013 21:57
Show Gist options
  • Save BenMatheja/7900987 to your computer and use it in GitHub Desktop.
Save BenMatheja/7900987 to your computer and use it in GitHub Desktop.
@echo off
rem Carnot application launch script
rem (C) 2000-2011 SunGard CSA LLC
rem
rem You can affect the behaviour of this script with the following environment variables
rem described in the CARNOT documentation:
rem
rem CARNOT_HOME: The location of the carnot distribution
rem CARNOT_WORK: The location of your private settings
rem CARNOT_CLASSPATH: A fixed classpath to use if you want to prevent automatic classpath assembly
rem CARNOT_JVM_PROPERTIES: Additional JVM properties you want to set
rem CARNOT_SUPRESS_DEFAULT_EXT_DIRS: If set, the java.ext.dirs system property is not used
rem CARNOT_LAUNCHER_HOOK: If set, used as custom launcher class to start the main class
rem JAVA_HOME: The location of the JDK
rem
rem If you provide the command line parameter 'cless' as first parameter
rem the application is started without a console context. In this case the correct
rem environment is tried to be read from a setenv.bat in the current directory.s
rem
if not "%1"=="cless" goto guess
if exist setenv.bat call setenv.bat
:guess
rem Guessing CARNOT_HOME
if not "%CARNOT_HOME%"=="" (set _CARNOT_HOME="%CARNOT_HOME%" & goto get_work)
if exist build\lib\carnot-client.jar (set _CARNOT_HOME=build& goto get_work)
if exist lib\carnot-client.jar (set _CARNOT_HOME=.& goto get_work)
if exist ..\lib\carnot-client.jar (set _CARNOT_HOME=..& goto get_work)
echo Couldn't guess CARNOT_HOME, dying...
goto :eof
rem Guessing CARNOT_WORK
:get_work
if not "%CARNOT_WORK%"=="" (set _CARNOT_WORK="%CARNOT_WORK%" & goto get_java_path)
if exist etc\carnot.properties (set _CARNOT_WORK=.& goto get_java_path)
if exist ..\etc\carnot.properties (set _CARNOT_WORK=..& goto get_java_path)
if exist ..\..\etc\carnot.properties (set _CARNOT_WORK=..\..& goto get_java_path)
if exist %_CARNOT_HOME%\etc\carnot.properties (set _CARNOT_WORK=%_CARNOT_HOME%& goto get_java_path)
echo Couldn't guess carnot.properties, dying...
goto :eof
rem Figuring out the path to java.exe
:get_java_path
if not "%JAVA_HOME%"=="" (set _JAVA_PATH=%JAVA_HOME%\bin\& goto get_java)
echo JAVA_HOME is not set, trying to use a java version in the path...
set _JAVA_PATH=
rem Console context?
:get_java
if "%1"=="cless" (set _JAVA_CMD=start "CARNOT" "%_JAVA_PATH%javaw.exe"& shift& goto get_cp)
set _JAVA_CMD="%_JAVA_PATH%java.exe"
rem Assembling the classpath
:get_cp
if "%CARNOT_CLASSPATH%"=="" goto no_classpath
set CP=%CARNOT_CLASSPATH%
goto startdesktop
:no_classpath
set CP=
for %%l in ("%CARNOT_WORK%\lib\*.*") do call :appendclasspath %%l
for %%l in ("%CARNOT_HOME%\lib\*.*") do call :appendclasspath %%l
echo hah
for %%l in ("%CARNOT_HOME%\lib\spring\*.*") do call :appendclasspath %%l
echo ha
set CP=%CARNOT_WORK%\etc;%CP%;%CLASSPATH%
rem Application Start
:startdesktop
set _DEFAULT_EXT_DIRS=
if "%CARNOT_SUPRESS_DEFAULT_EXT_DIRS%"=="" (set _DEFAULT_EXT_DIRS=-Djava.ext.dirs="%CARNOT_HOME%\lib\ext")
rem Assembling default credentials
if NOT "%CARNOT_PARTITION%"=="" (set _DEFAULT_CREDENTIALS=-DSecurity.DefaultPartition="%CARNOT_PARTITION%")
if NOT "%CARNOT_DOMAIN%"=="" (set _DEFAULT_CREDENTIALS=%_DEFAULT_CREDENTIALS% -DSecurity.DefaultDomain="%CARNOT_DOMAIN%")
if NOT "%CARNOT_REALM%"=="" (set _DEFAULT_CREDENTIALS=%_DEFAULT_CREDENTIALS% -DSecurity.DefaultRealm="%CARNOT_REALM%")
if NOT "%CARNOT_USER%"=="" (set _DEFAULT_CREDENTIALS=%_DEFAULT_CREDENTIALS% -DSecurity.DefaultUser="%CARNOT_USER%")
%_JAVA_CMD% %CARNOT_JVM_PROPERTIES% %_DEFAULT_EXT_DIRS% %_DEFAULT_CREDENTIALS% -classpath "%CP%" %CARNOT_LAUNCHER_HOOK% ag.carnot.workflow.tools.sysconsole.Main %*
goto :eof
rem function to assemble the classpath
:appendclasspath
set CP=%CP%;%*

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment