teichmann@4484: #!/bin/bash ingo@4065: aheinecke@5220: set -e aheinecke@5220: ingo@4065: echo "INFO: define required variables" teichmann@4484: ARTIFACTS_HG_REPO="http://wald.intevation.org/hg/dive4elements/artifacts" teichmann@4484: HTTPCLIIENT_HG_REPO="http://wald.intevation.org/hg/dive4elements/http-client" teichmann@4484: FLYS_HG_REPO="http://wald.intevation.org/hg/dive4elements/flys" ingo@4065: ingo@4065: ARTIFACTS_HG="hg.artifacts" ingo@4065: HTTPCLIENT_HG="hg.http-client" ingo@4065: FLYS_HG="hg.flys" ingo@4065: ingo@4065: PREFIX="flys-" teichmann@4485: RELEASE=${RELEASE:-default} teichmann@4151: RELEASE_DATE=`date +'%Y-%m-%d'` teichmann@4485: DIRECTORY=$PREFIX$RELEASE-$RELEASE_DATE ingo@4065: rrenkert@4503: ARTIFACT_PORT=${ARTIFACT_PORT:-9002} teichmann@4487: TOMCAT_PORT=${TOMCAT_PORT:-8005} teichmann@4484: rrenkert@4889: MAPSERVER_URL=${MAPSERVER_URL:-czech-republic.atlas.intevation.de} teichmann@5119: WIKI_URL=${WIKI_URL:-https://flys-intern.intevation.de/Flys-3.0} teichmann@4494: ingo@4065: echo "INFO: create server directories" teichmann@4151: mkdir -p $DIRECTORY/server/bin/lib/own ingo@4065: mkdir $DIRECTORY/server/shapefiles ingo@4065: mkdir $DIRECTORY/client ingo@4065: ingo@4065: echo "INFO: checkout sources" ingo@4065: echo " ... checkout $ARTIFACTS_HG_REPO" teichmann@4484: teichmann@4484: rm -rf $ARTIFACTS_HG ingo@4065: hg clone $ARTIFACTS_HG_REPO $ARTIFACTS_HG ingo@4065: (cd $ARTIFACTS_HG && hg co $RELEASE) ingo@4065: ingo@4065: echo " ... checkout $HTTPCLIIENT_HG_REPO" teichmann@4484: rm -rf $HTTPCLIENT_HG ingo@4065: hg clone $HTTPCLIIENT_HG_REPO $HTTPCLIENT_HG ingo@4065: (cd $HTTPCLIENT_HG && hg co $RELEASE) ingo@4065: ingo@4065: echo " ... checkout $FLYS_HG_REPO" teichmann@4484: rm -rf $FLYS_HG ingo@4065: hg clone $FLYS_HG_REPO $FLYS_HG ingo@4065: (cd $FLYS_HG && hg co $RELEASE) ingo@4065: ingo@4065: # adapt client configuration ingo@4065: echo "INFO: prepare configuration of web client" teichmann@4484: rrenkert@4503: sed -i -e "s@http://localhost:8181@http://localhost:$ARTIFACT_PORT@g" \ teichmann@4487: -e "s@http://localhost:8888@http://localhost:$TOMCAT_PORT@g" \ teichmann@4484: $FLYS_HG/flys-client/src/main/webapp/WEB-INF/web.xml ingo@4065: teichmann@5119: sed -i -e "s@/tmp/flys-client.log@/var/log/flys/client-${RELEASE}.log@g" \ teichmann@4493: $FLYS_HG/flys-client/src/main/webapp/WEB-INF/log4j.properties teichmann@4493: teichmann@5119: # Fix the Wiki URLs teichmann@5119: find $FLYS_HG/flys-artifacts/src/main/resources/ -name messages_\*.properties \ teichmann@5119: -exec sed -i "s@https://flys-intern.intevation.de/Flys-3.0@${WIKI_URL}@g" {} \; teichmann@5119: ingo@4065: echo "INFO: download OpenLayers-2.11 for client" ingo@4065: curl -O http://openlayers.org/download/OpenLayers-2.11.tar.gz ingo@4065: tar xvfz OpenLayers-2.11.tar.gz teichmann@4151: # TODO: Remove more superfluous OpenLayers stuff. teichmann@4151: rm -rf OpenLayers-2.11/doc teichmann@4151: rm -rf OpenLayers-2.11/tests teichmann@4151: rm -rf OpenLayers-2.11/examples ingo@4065: mv OpenLayers-2.11 $FLYS_HG/flys-client/src/main/webapp/ ingo@4065: ingo@4065: # compile and build our code stuff ingo@4065: echo "INFO: compile and build sources" teichmann@4484: mvn -f $ARTIFACTS_HG/pom.xml clean compile package install teichmann@4484: mvn -f $FLYS_HG/flys-backend/pom.xml clean compile package install rrenkert@4503: mvn -f $FLYS_HG/flys-artifacts/pom.xml clean compile package dependency:copy-dependencies install ingo@4065: mvn -f $HTTPCLIENT_HG/pom.xml clean compile package install ingo@4065: mvn -f $FLYS_HG/flys-client/pom.xml clean compile package ingo@4065: ingo@4065: ## fetch the java stuff ingo@4065: echo "INFO: copy dependencies and libs" ingo@4065: cp $ARTIFACTS_HG/artifact-database/target/artifact-database-1.0-SNAPSHOT.jar $DIRECTORY/server/bin/lib/own/ ingo@4065: cp $ARTIFACTS_HG/artifacts/target/artifacts-1.0-SNAPSHOT.jar $DIRECTORY/server/bin/lib/own/ ingo@4065: cp $ARTIFACTS_HG/artifacts-common/target/artifacts-common-1.0-SNAPSHOT.jar $DIRECTORY/server/bin/lib/own/ ingo@4065: cp $FLYS_HG/flys-backend/target/flys-backend-1.0-SNAPSHOT.jar $DIRECTORY/server/bin/lib/own/ ingo@4065: cp $FLYS_HG/flys-artifacts/target/flys-artifacts-1.0-SNAPSHOT.jar $DIRECTORY/server/bin/lib/own/ teichmann@4484: cp $FLYS_HG/flys-client/target/FLYS-1.0-SNAPSHOT.war $DIRECTORY/client/flys-${RELEASE}.war ingo@4065: cp $FLYS_HG/flys-artifacts/target/dependency/* $DIRECTORY/server/bin/lib/ ingo@4065: ingo@4065: echo "INFO: copy scripts and libraries to target destination" ingo@4065: cp bin/run.sh $DIRECTORY/server/bin/ ingo@4065: cp bin/wsplgen.exe $DIRECTORY/server/bin/ ingo@4065: cp libs/* $DIRECTORY/server/bin/lib/ ingo@4065: ingo@4065: #echo "INFO: remove PostgreSQL and PostGIS libraries" ingo@4065: #rm $DIRECTORY/server/bin/lib/postg* ingo@4065: #rm $DIRECTORY/server/bin/lib/hibernate-spatial-postgis* ingo@4065: ingo@4065: echo "INFO: remove Oralce libraries" teichmann@4651: rm -f $DIRECTORY/server/bin/lib/hibernate-spatial-oracle-1.1.jar teichmann@4651: rm -f $DIRECTORY/server/bin/lib/ojdbc* ingo@4065: ingo@4065: # fetch the configuration stuff ingo@4065: echo "INFO: copy default configuration to target destination" ingo@4065: cp -R $FLYS_HG/flys-artifacts/doc/conf $DIRECTORY/server/ teichmann@4484: teichmann@4484: #cp confs/* $DIRECTORY/server/conf/ teichmann@4651: mkdir -p $DIRECTORY/server/conf teichmann@4484: rrenkert@4503: sed "s/8999/$ARTIFACT_PORT/g" \ teichmann@4484: confs/rest-server.xml \ teichmann@4484: > $DIRECTORY/server/conf/rest-server.xml teichmann@4484: rrenkert@4889: sed -e "s@http://example.com/@http://${MAPSERVER_URL}/@g" \ teichmann@4484: confs/floodmap.xml \ teichmann@4484: > $DIRECTORY/server/conf/floodmap.xml teichmann@4484: rrenkert@4889: sed -e "s@http://example.com/@http://${MAPSERVER_URL}/@g" \ rrenkert@4889: confs/rivermap.xml \ rrenkert@4889: > $DIRECTORY/server/conf/rivermap.xml rrenkert@4889: teichmann@5119: sed "s@/tmp/flys-server-default.log@/var/log/flys/server-${RELEASE}.log@" \ teichmann@4484: confs/log4j.properties \ teichmann@4484: > $DIRECTORY/server/conf/log4j.properties teichmann@4484: teichmann@4484: # TODO: Use templating here teichmann@4484: cp confs/seddb-db.xml $DIRECTORY/server/conf/seddb-db.xml teichmann@4484: cp confs/backend-db.xml $DIRECTORY/server/conf/backend-db.xml teichmann@4484: cp confs/artifact-db.xml $DIRECTORY/server/conf/artifact-db.xml teichmann@4484: cp confs/datacage-db.xml $DIRECTORY/server/conf/datacage-db.xml teichmann@4491: cp confs/mapserver/fontset.txt $DIRECTORY/server/conf/mapserver/fontset.txt ingo@4065: ingo@4065: cp $ARTIFACTS_HG/artifact-database/doc/schema-h2.sql h2/artifacts-h2.sql ingo@4065: cp $FLYS_HG/flys-artifacts/doc/conf/datacage.sql h2/datacage.sql ingo@4065: ingo@4065: echo "INFO: create h2 database for artifacts and datacage" ingo@4065: h2/createArtifacts.sh ingo@4065: h2/createDatacage.sh ingo@4065: ingo@4065: mv artifactsdb $DIRECTORY/server/ ingo@4065: mv datacagedb $DIRECTORY/server/ ingo@4065: ingo@4065: echo "INFO: create tarball" ingo@4065: tar cvfz $DIRECTORY.tar.gz $DIRECTORY ingo@4065: ingo@4065: echo "INFO: remove temporary files and directories" ingo@4065: rm -rf $ARTIFACTS_HG ingo@4065: rm -rf $HTTPCLIENT_HG ingo@4065: rm -rf $FLYS_HG ingo@4065: rm -rf $DIRECTORY ingo@4065: rm -rf OpenLayers.2.11.tar.gz