-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Creating docker for FIWARE R5 with SpagoBI 5.2
- Loading branch information
aportosa
committed
Sep 5, 2016
1 parent
090c703
commit 50d23da
Showing
1 changed file
with
71 additions
and
0 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,71 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
if [[ -z "$PUBLIC_ADDRESS" ]]; then | ||
#get the address of container | ||
#example : default via 172.17.42.1 dev eth0 172.17.0.0/16 dev eth0 proto kernel scope link src 172.17.0.109 | ||
PUBLIC_ADDRESS=`ip route | grep src | awk '{print $9}'` | ||
fi | ||
|
||
|
||
#replace the address of container inside server.xml | ||
sed -i "s/http:\/\/.*:8080/http:\/\/${PUBLIC_ADDRESS}:8080/g" ${SPAGOBI_DIRECTORY}/conf/server.xml | ||
sed -i "s/http:\/\/192\.168\.93\.1:8080/http:\/\/${PUBLIC_ADDRESS}:8080/g" ${SPAGOBI_DIRECTORY}/webapps/SpagoBIConsoleEngine/WEB-INF/web.xml | ||
sed -i "s/http:\/\/192\.168\.93\.1:8080/http:\/\/${PUBLIC_ADDRESS}:8080/g" ${SPAGOBI_DIRECTORY}/webapps/SpagoBIChartEngine/WEB-INF/web.xml | ||
|
||
#wait for MySql if it's a compose image | ||
if [ -n "$WAIT_MYSQL" ]; then | ||
while ! curl http://$DB_PORT_3306_TCP_ADDR:$DB_PORT_3306_TCP_PORT/ | ||
do | ||
echo "$(date) - still trying to connect to mysql" | ||
sleep 1 | ||
done | ||
fi | ||
|
||
if [ -n "$DB_ENV_MYSQL_DATABASE" ]; then | ||
#copy the original files | ||
cp ${SPAGOBI_DIRECTORY}/conf/server.xml.bak ${SPAGOBI_DIRECTORY}/conf/server.xml | ||
cp ${SPAGOBI_DIRECTORY}/webapps/SpagoBI/WEB-INF/classes/hibernate.cfg.xml.bak ${SPAGOBI_DIRECTORY}/webapps/SpagoBI/WEB-INF/classes/hibernate.cfg.xml | ||
cp ${SPAGOBI_DIRECTORY}/webapps/SpagoBI/WEB-INF/classes/jbpm.hibernate.cfg.xml.bak ${SPAGOBI_DIRECTORY}/webapps/SpagoBI/WEB-INF/classes/jbpm.hibernate.cfg.xml | ||
cp ${SPAGOBI_DIRECTORY}/webapps/SpagoBI/WEB-INF/classes/quartz.properties.bak ${SPAGOBI_DIRECTORY}/webapps/SpagoBI/WEB-INF/classes/quartz.properties | ||
|
||
# Get the database values from the relation. | ||
DB_USER=$DB_ENV_MYSQL_USER | ||
DB_DB=$DB_ENV_MYSQL_DATABASE | ||
DB_PASS=$DB_ENV_MYSQL_PASSWORD | ||
DB_HOST=$DB_PORT_3306_TCP_ADDR | ||
DB_PORT=$DB_PORT_3306_TCP_PORT | ||
|
||
#insert spago bi metadata into db if it doesn't exist | ||
Result=`mysql -h${DB_HOST} -P${DB_PORT} -u${DB_USER} -p${DB_PASS} ${DB_DB} -e "SHOW TABLES LIKE '%SBI_%';"` | ||
if [ -z "$Result" ]; then | ||
mysql -h${DB_HOST} -P${DB_PORT} -u${DB_USER} -p${DB_PASS} ${DB_DB} --execute="source $MYSQL_SCRIPT_DIRECTORY/MySQL_create.sql" | ||
mysql -h${DB_HOST} -P${DB_PORT} -u${DB_USER} -p${DB_PASS} ${DB_DB} --execute="source $MYSQL_SCRIPT_DIRECTORY/MySQL_create_quartz_schema.sql" | ||
mysql -h${DB_HOST} -P${DB_PORT} -u${DB_USER} -p${DB_PASS} ${DB_DB} --execute="source $MYSQL_SCRIPT_DIRECTORY/MySQL_create_social.sql" | ||
fi | ||
|
||
#replace hsql with mysql | ||
#replace in server.xml | ||
old_driver='org\.hsqldb\.jdbcDriver' | ||
new_driver='com\.mysql\.jdbc\.Driver' | ||
sed -i "s|${old_driver}|${new_driver}|" ${SPAGOBI_DIRECTORY}/conf/server.xml | ||
old_connection='jdbc:hsqldb:file:${catalina.base}/database/spagobi' | ||
mysql_connection='jdbc:mysql://'${DB_HOST}':'${DB_PORT}'/'${DB_DB} | ||
sed -i "s|${old_connection}|${mysql_connection}|" ${SPAGOBI_DIRECTORY}/conf/server.xml | ||
old_username_password='username="sa" password=""' | ||
new_username_password='username="'${DB_USER}'" password="'${DB_PASS}'"' | ||
sed -i "s|${old_username_password}|${new_username_password}|" ${SPAGOBI_DIRECTORY}/conf/server.xml | ||
#replace in properties files dialect | ||
old_dialect='org\.hibernate\.dialect\.HSQLDialect' | ||
new_dialect='org\.hibernate\.dialect\.MySQLDialect' | ||
sed -i "s|${old_dialect}|${new_dialect}|" ${SPAGOBI_DIRECTORY}/webapps/SpagoBI/WEB-INF/classes/hibernate.cfg.xml | ||
sed -i "s|${old_dialect}|${new_dialect}|" ${SPAGOBI_DIRECTORY}/webapps/SpagoBI/WEB-INF/classes/jbpm.hibernate.cfg.xml | ||
#replace in properties files delegate | ||
old_delegate='org\.quartz\.impl\.jdbcjobstore\.HSQLDBDelegate' | ||
new_delegate='org\.quartz\.impl\.jdbcjobstore\.StdJDBCDelegate' | ||
sed -i "s|${old_delegate}|${new_delegate}|" ${SPAGOBI_DIRECTORY}/webapps/SpagoBI/WEB-INF/classes/quartz.properties | ||
|
||
|
||
fi | ||
|
||
exec "$@" |