scripts/sql-dk.sh
author František Kučera <franta-hg@frantovo.cz>
Sun, 13 Sep 2020 12:01:35 +0200
branchv_0
changeset 253 d8442b266ca8
parent 199 88de2602deb3
permissions -rwxr-xr-x
combatibility with Java 9+, Tested with Java 11; JAXB library
     1 #!/bin/bash
     2 
     3 # include user-defined overrides and customization
     4 if [ -f ~/.sql-dk/environment.sh ]; then # .sql-dk must match with DIR in Constants.java
     5 	. ~/.sql-dk/environment.sh
     6 else
     7 	mkdir -p ~/.sql-dk/
     8 	# link/copy support files for configuration:
     9 	[ -f ~/.sql-dk/environment.sh ] || touch ~/.sql-dk/environment.sh
    10 	[ -f ~/.sql-dk/config.xsd ] || ln -s /usr/share/doc/sql-dk/config.xsd ~/.sql-dk/config.xsd
    11 	[ -f ~/.sql-dk/config.rnc ] || ln -s /usr/share/doc/sql-dk/config.rnc ~/.sql-dk/config.rnc
    12 	[ -f ~/.sql-dk/config.xsl ] || gunzip < /usr/share/doc/sql-dk/config.xsl.gz > ~/.sql-dk/config.xsl # might not work in www browser if just symlinked
    13 fi
    14 
    15 # Standard JDBC drivers
    16 [ -n "$STANDARD_JDBC" ] || STANDARD_JDBC=(
    17 	"/usr/share/java/postgresql-jdbc4.jar"
    18 	"/usr/share/java/mysql.jar"
    19 );
    20 
    21 # Standard libraries
    22 [ -n "$STANDARD_LIB" ] || STANDARD_LIB=(
    23 	"/usr/share/java/jaxb-api.jar"
    24 	"/usr/share/java/jaxb-runtime.jar"
    25 );
    26 # JAXB library is needed since Java 9 (up to Java 8 it was part of the JRE).
    27 # By default, we use JARs from the distribution.
    28 # Some distributions might contain older versions of the JAXB library (2.3.0)
    29 # that work but generate following waringns:
    30 #   WARNING: An illegal reflective access operation has occurred
    31 #   WARNING: Illegal reflective access by com.sun.xml.bind.v2.runtime.reflect.opt.Injector (file:/usr/share/java/jaxb-runtime.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int)
    32 #   WARNING: Please consider reporting this to the maintainers of com.sun.xml.bind.v2.runtime.reflect.opt.Injector
    33 #   WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
    34 #   WARNING: All illegal access operations will be denied in a future release
    35 # In order to get rid of them, the user can use newer JARs from Maven that are copied into the java/sql-dk/target/lib/ directory during build.
    36 # This is done by adding them in the STANDARD_LIB variable in his environment.sh file.
    37 
    38 
    39 # Additional JDBC drivers might be specified in CUSTOM_JDBC array
    40 # Plugins (formatters etc.) might be specified in PLUGINS array
    41 
    42 # JAR containing SQL-DK application
    43 [ -n "$JAR" ] || JAR="/usr/share/sql-dk/sql-dk.jar";
    44 
    45 CLASS_PATH="$JAR";
    46 
    47 for e in "${CUSTOM_JDBC[@]}" "${PLUGINS[@]}" "${STANDARD_JDBC[@]}" "${STANDARD_LIB[@]}"; do
    48 	CLASS_PATH="$CLASS_PATH:$e";
    49 done
    50 
    51 
    52 MAIN_CLASS="info.globalcode.sql.dk.CLIStarter";
    53 
    54 LOGGER="-Djava.util.logging.config.class=info.globalcode.sql.dk.logging.LoggerInitializer";
    55 [ -n "$LOG_LEVEL" ] && LOGGER_LEVEL="-Dinfo.globalcode.sql.dk.logging.LoggerInitializer.level=$LOG_LEVEL";
    56 
    57 java "${JAVA_OPTIONS[@]}" $LOGGER $LOGGER_LEVEL -cp "$CLASS_PATH" $MAIN_CLASS "$@"