Skip to content

Commit

Permalink
Added an argument to the scripts to define a lib directory [comixed#237]
Browse files Browse the repository at this point in the history
By default the lib directory will point to a sibling to the bin
directory. But it can be overridden by passing a "-l DIR" option
to specify a different directory.
  • Loading branch information
mcpierce committed Jun 11, 2020
1 parent 91b5901 commit 9ea2696
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 10 deletions.
17 changes: 16 additions & 1 deletion comixed-app/src/main/scripts/run.bat
Expand Up @@ -31,6 +31,7 @@ IF "%PARAM%" == "-j" GOTO set_jdbc_url
IF "%PARAM%" == "-u" GOTO set_jdbc_user
IF "%PARAM%" == "-p" GOTO set_jdbc_pwrd
IF "%PARAM%" == "-i" GOTO set_image_cache_dir
if "%PARAM%" == "-l" GOTO set_lib_dir
GOTO process_command_line

:set_jdbc_url
Expand All @@ -57,6 +58,12 @@ SHIFT
SHIFT
GOTO process_command_line

:set_lib_dir
SET LIBDIR=%ARG%
SHIFT
SHIFT
GOTO process_command_line

:show_help
ECHO Usage: run.bat [OPTIONS]
ECHO.
Expand All @@ -65,6 +72,7 @@ ECHO -j [URL] - Set the database URL
ECHO -u [USERNAME] - Set the database username
ECHO -p [PASSWORD] - Set the database password
ECHO -i [DIR] - Set the image caching directory
ECHO -l [DIR] - Set the JAR library directory
ECHO.
ECHO OTHER OPTIONS:
ECHO -d - Enable debugging (def. off)
Expand All @@ -73,6 +81,7 @@ ECHO -h - Show help (this text)
GOTO exit_script

:end_process_command_line

SET OPTIONS=

IF "%DEBUG%" == "" GOTO skip_debug
Expand All @@ -99,7 +108,13 @@ IF "%IMGCACHEDIR%" == "" GOTO skip_image_cache_dir
SET OPTIONS=%OPTIONS% --comixed.images.cache.location=%IMGCACHEDIR%
:skip_image_cache_dir

java -jar %JARFILE% %OPTIONS%
SET JVMOPTIONS=

IF "%LIBDIR%" == "" GOTO skip_lib_dir
SET JVMOPTIONS=%JVMOPTIONS% -classpath %LIBDIR%
:skip_lib_dir

java %JVMOPTIONS% -jar %JARFILE% %OPTIONS%

:exit_script
ENDLOCAL
28 changes: 19 additions & 9 deletions comixed-app/src/main/scripts/run.sh
Expand Up @@ -18,9 +18,11 @@

ME=$(realpath -s $0)
BINDIR=$(dirname ${ME})
LIBDIR=$(realpath -s ${BINDIR}/../lib)

JAVA=$(which java)
OPTIONS=''
JAROPTIONS=''
JVMOPTIONS=''
COMIXED_JAR_FILE=${BINDIR}/comixed-app-*.jar
DEBUG=false
FULL_DEBUG=false
Expand All @@ -38,6 +40,7 @@ usage() {
echo " -u [USERNAME]\t\t- Set the database username"
echo " -p [PASSWORD]\t\t- Set the database password"
echo " -i [DIR]\t\t- Set the image caching directory"
echo " -l [DIR]\t\t-Set the JAR library directory"
echo ""
echo "Other options:"
echo " -d\t\t\t- Debug mode (def. false)"
Expand All @@ -46,12 +49,13 @@ usage() {
exit 0
}

while getopts "j:u:p:i:dDv" option; do
while getopts "j:u:p:i:l:dDv" option; do
case ${option} in
j) JDBCURL="${OPTARG}" ;;
u) DBUSER="${OPTARG}" ;;
p) DBPWRD="${OPTARG}" ;;
i) IMGCACHEDIR="${OPTARG}" ;;
l) LIBDIR="${OPTARG}" ;;
d) DEBUG=true ;;
D) FULL_DEBUG=true ;;
v) VERBOSE=true ;;
Expand All @@ -70,28 +74,34 @@ fi

if $DEBUG; then
# enable global logging for CX
OPTIONS="${OPTIONS} --logging.level.org.comixed=DEBUG"
JAROPTIONS="${JAROPTIONS} --logging.level.org.comixed=DEBUG"
fi

if $FULL_DEBUG; then
# enable all debugging for all dependencies
OPTIONS="${OPTIONS} --logging.level.root=DEBUG"
JAROPTIONS="${JAROPTIONS} --logging.level.root=DEBUG"
fi

if [[ $JDBCURL ]]; then
OPTIONS="${OPTIONS} --spring.datasource.url=${JDBCURL}"
JAROPTIONS="${JAROPTIONS} --spring.datasource.url=${JDBCURL}"
fi

if [[ $DBUSER ]]; then
OPTIONS="${OPTIONS} --spring.datasource.username=${DBUSER}"
JAROPTIONS="${JAROPTIONS} --spring.datasource.username=${DBUSER}"
fi

if [[ $DBPWRD ]]; then
OPTIONS="${OPTIONS} --spring.datasource.password=${DBPWRD}"
JAROPTIONS="${JAROPTIONS} --spring.datasource.password=${DBPWRD}"
fi

if [[ $IMGCACHEDIR ]]; then
OPTIONS="${OPTIONS} --comixed.images.cache.location=${IMGCACHEDIR}"
JAROPTIONS="${JAROPTIONS} --comixed.images.cache.location=${IMGCACHEDIR}"
fi

$JAVA -jar $COMIXED_JAR_FILE $OPTIONS
# build a list of JVM arguments

if [[ $LIBDIR ]]; then
JVMOPTIONS="${JVMOPTIONS} -classpath ${LIBDIR}"
fi

$JAVA ${JVMOPTIONS} -jar ${COMIXED_JAR_FILE} ${JAROPTIONS}

0 comments on commit 9ea2696

Please sign in to comment.