forked from Gepardec/JBSS
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Erhard Siegl
committed
Mar 15, 2015
1 parent
0c569e7
commit dabdb37
Showing
15 changed files
with
168 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "jbss-substitute"] | ||
path = jbss-substitute | ||
url = [email protected]:Gepardec/jbss-substitute.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/bin/sh | ||
|
||
if [ -z "$ENV_CONFIG" ]; then | ||
ENV_CONFIG=$1 | ||
fi | ||
|
||
if [ ! -d "$ENV_CONFIG" ]; then | ||
echo "WARN: File $ENV_CONFIG doesn't exist! Set ENV_CONFIG or use argument" 1>&2 | ||
echo "WARN: !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" | ||
ENV_CONFIG=../environments/fm/example.env | ||
echo "WARN: Example values from $ENV_CONFIG will be used!" 1>&2 | ||
echo "WARN: Change this code in real-world environments" 1>&2 | ||
echo "WARN: !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" | ||
# exit 1 | ||
fi | ||
|
||
########################### | ||
# provide the script and libraries for template processing | ||
########################### | ||
provideSubstitute() { | ||
echo "Let's try to get the latest freemarker-utilities" | ||
JBSS_SUBSTITUTE=../../jbss-substitute/ | ||
cp $JBSS_SUBSTITUTE/target/jbss-substitute-*-jar-with-dependencies.jar substitute.jar | ||
cp $JBSS_SUBSTITUTE/src/main/resources/substitute.sh ./substitute | ||
chmod a+x substitute | ||
|
||
if [ ! -x substitute ]; then | ||
echo "Script substitute is missing or not executable!" 1>&2 | ||
echo "Should be copied from $JBSS_SUBSTITUTE/src/main/resources" 1>&2 | ||
exit 2 | ||
fi | ||
if [ ! -r substitute.jar ]; then | ||
echo "Library jbss-substitute.jar is missing!" 1>&2; exit 3 | ||
fi | ||
} | ||
|
||
########################### | ||
# convert all m4 templates in directory and subdirectories | ||
########################### | ||
convert() { | ||
dir=$1 | ||
echo "Configure Directory $dir" | ||
for f in `find $dir -name "*.templ"`; do | ||
dirname=`dirname $f` | ||
basename=`basename $f .templ` | ||
echo Process template $f | ||
./substitute -p "$ENV_CONFIG" -t $f -o $dirname/$basename | ||
done | ||
} | ||
|
||
provideSubstitute | ||
convert `pwd` |
14 changes: 14 additions & 0 deletions
14
configs/database_with_freemarker_template/03_createDatasource.conf.templ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/subsystem=datasources/data-source=bookingDatasource:add( \ | ||
jndi-name="java:/datasources/bookingDatasource", \ | ||
connection-url="jdbc:h2:mem:test;DB_CLOSE_DELAY=-1", \ | ||
driver-name=h2, user-name=${CONF_DB_USER}, password=${CONF_DB_PASSWORD}) | ||
/subsystem=datasources/data-source=bookingDatasource:enable | ||
|
||
<#list CONF_DBS_USER?keys as key> | ||
|
||
/subsystem=datasources/data-source=myDatasource${key}:add( \ | ||
jndi-name="java:/datasources/myDatasource${key}", \ | ||
connection-url="jdbc:h2:mem:test;DB_CLOSE_DELAY=-1", \ | ||
driver-name=h2, user-name=${CONF_DBS_USER[key]}, password=${CONF_DBS_PASSWORD[key]}) | ||
/subsystem=datasources/data-source=myDatasource${key}:enable | ||
</#list> |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#!/bin/bash | ||
|
||
# Substitute script | ||
|
||
MY_PATH=$(readlink -f $0) | ||
BIN_DIR=`dirname $MY_PATH` | ||
BASE_DIR=$BIN_DIR/.. | ||
CONFIG_DIR=$BASE_DIR | ||
PRG=`basename $0` | ||
|
||
SAVE_DATE=`date +save_%Y_%m_%d-%H_%M_%S` | ||
RM_ACTION=manual | ||
|
||
##################################################################### | ||
## print_usage | ||
##################################################################### | ||
print_usage(){ | ||
cat <<EOF 1>&2 | ||
usage: $PRG -p properties_file -t template_file -o output_file | ||
Funktion: | ||
Transforms the given freemarker template using properties from properties file and writes result to file | ||
EOF | ||
} | ||
|
||
###################### Optionen bestimmen ################### | ||
|
||
while getopts "p:t:o:" option | ||
do | ||
case $option in | ||
p) | ||
PROP_FILE=$OPTARG;; | ||
t) | ||
TEMPLATE_FILE=$OPTARG;; | ||
o) | ||
OUTPUT_FILE=$OPTARG;; | ||
*) | ||
print_usage | ||
exit 1 | ||
;; | ||
esac | ||
done | ||
|
||
shift `expr $OPTIND - 1` | ||
|
||
|
||
##################### Beginn ######################### | ||
|
||
if [ ! -f $PROP_FILE ] || [ x$PROP_FILE = x ] | ||
then | ||
echo "Property file $PROP_FILE not found" | ||
print_usage | ||
exit 1 | ||
fi | ||
|
||
if [ ! -f $TEMPLATE_FILE ] || [ x$TEMPLATE_FILE = x ] | ||
then | ||
echo "Template file $TEMPLATE_FILE not found" | ||
exit 1 | ||
fi | ||
java -jar $BIN_DIR/substitute.jar $PROP_FILE $TEMPLATE_FILE $OUTPUT_FILE |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
deploy ../deployments/jboss-seam-booking.ear |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
|
||
CONF_DB_USER=myuser | ||
CONF_DB_PASSWORD=default_db_password | ||
|
||
CONF_DBS_USER_1=myuserone | ||
CONF_DBS_PASSWORD_1=mypasswordone | ||
|
||
CONF_DBS_USER_2=myusertwo | ||
CONF_DBS_PASSWORD_2=mypasswordtwo |
Submodule jbss-substitute
added at
701338
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>com.gepardec.jbss</groupId> | ||
<artifactId>parent</artifactId> | ||
<version>1.0.0-SNAPSHOT</version> | ||
<packaging>pom</packaging> | ||
<modules> | ||
<module>modules</module> | ||
<module>jbss-substitute</module> | ||
</modules> | ||
<dependencies> | ||
</dependencies> | ||
<build> | ||
</build> | ||
</project> |