scripts/sql-dk.sh
author František Kučera <franta-hg@frantovo.cz>
Tue, 26 Feb 2019 18:19:49 +0100
branchv_0
changeset 236 a3ec71fa8e17
parent 199 88de2602deb3
child 253 d8442b266ca8
permissions -rwxr-xr-x
Avoid reusing/rewriting the DB connection properties.
There was weird random errors while testing connection to multiple DB in parallel when one of them was meta connection to same DB connection.
Two kinds of exception: 1) missing password 2) „Passing DB password as CLI parameter is insecure!“
     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 # Additional JDBC drivers might be specified in CUSTOM_JDBC array
    22 # Plugins (formatters etc.) might be specified in PLUGINS array
    23 
    24 # JAR containing SQL-DK application
    25 [ -n "$JAR" ] || JAR="/usr/share/sql-dk/sql-dk.jar";
    26 
    27 CLASS_PATH="$JAR";
    28 
    29 for e in "${STANDARD_JDBC[@]}" "${CUSTOM_JDBC[@]}" "${PLUGINS[@]}"; do
    30 	CLASS_PATH="$CLASS_PATH:$e";
    31 done
    32 
    33 
    34 MAIN_CLASS="info.globalcode.sql.dk.CLIStarter";
    35 
    36 LOGGER="-Djava.util.logging.config.class=info.globalcode.sql.dk.logging.LoggerInitializer";
    37 [ -n "$LOG_LEVEL" ] && LOGGER_LEVEL="-Dinfo.globalcode.sql.dk.logging.LoggerInitializer.level=$LOG_LEVEL";
    38 
    39 java "${JAVA_OPTIONS[@]}" $LOGGER $LOGGER_LEVEL -cp "$CLASS_PATH" $MAIN_CLASS "$@"