teichmann@4484: #!/bin/bash aheinecke@5251: # Release script for Flys aheinecke@5251: # aheinecke@5251: # Authors: aheinecke@5251: # Andre Heinecke aheinecke@5251: # aheinecke@5251: # Copyright: aheinecke@5251: # Copyright (C) 2013 Intevation GmbH aheinecke@5251: # aheinecke@5251: # This program is free software; you can redistribute it and/or aheinecke@5251: # modify it under the terms of the GNU General Public License aheinecke@5251: # as published by the Free Software Foundation; either version 2 aheinecke@5251: # of the License, or (at your option) any later version. aheinecke@5251: # aheinecke@5251: # This program is distributed in the hope that it will be useful, aheinecke@5251: # but WITHOUT ANY WARRANTY; without even the implied warranty of aheinecke@5251: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the aheinecke@5251: # GNU General Public License for more details. aheinecke@5251: # aheinecke@5251: # You should have received a copy of the GNU General Public License aheinecke@5251: # along with this program; if not, write to the Free Software aheinecke@5251: # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ingo@4065: aheinecke@5220: set -e aheinecke@5251: DEFAULT_WD=/tmp/flys-release aheinecke@5251: DEVELOPER=aheinecke aheinecke@5220: aheinecke@5900: ARTIFACTS_HG_REPO="http://wald.intevation.org/hg/dive4elements/framework" teichmann@4484: HTTPCLIIENT_HG_REPO="http://wald.intevation.org/hg/dive4elements/http-client" aheinecke@5900: FLYS_HG_REPO="http://wald.intevation.org/hg/dive4elements/river" ingo@4065: aheinecke@5900: REPOS="river http-client framework" aheinecke@5251: # Do not use spaces in path aheinecke@5251: FLYS_SOURCE_DIR=/local-vol1/aheinecke/flys-release ingo@4065: aheinecke@5320: ORACLE_HIBERNATE=$FLYS_SOURCE_DIR/hibernate-spatial-oracle-1.1.jar aheinecke@5320: ORACLE_JDBC=$FLYS_SOURCE_DIR/ojdbc5.jar aheinecke@5320: aheinecke@5251: SCRIPT_DIR=$(readlink -f `dirname $0`) aheinecke@5251: usage(){ aheinecke@5251: cat << EOF ingo@4065: aheinecke@5251: usage: $0 [options] VERSION teichmann@4484: aheinecke@5251: Create a flys package aheinecke@5251: aheinecke@5251: OPTIONS: aheinecke@5251: -?, --help Show this message aheinecke@5251: -w The working directory to use. (do not use spaces in path) aheinecke@5251: Default: $DEFAULT_WD aheinecke@5251: -t Tag the current default branch as "VERSION" aheinecke@5251: -o, --oracle Release is for oracle. aheinecke@5493: VERSION must be in the format MAYOR.MINOR.PATCH or default aheinecke@5251: EOF aheinecke@5251: exit 0 aheinecke@5251: } aheinecke@5251: # --backend-db-url Url of database backend. Default: $BACKENDURL aheinecke@5251: # --backend-db-pass Backend db password. Default: $BACKENDPASS aheinecke@5251: # --backend-db-port Backend db port. Default: $BACKENDPORT aheinecke@5251: # --backend-db-user Backend db user. Default: $BACKENDUSER aheinecke@5251: # --backend-db-backend Backend db backend name. Default: $BACKENDBACK aheinecke@5251: # --seddb-url Sediment db url. Default: $SEDDBURL aheinecke@5251: # --seddb-port Sediment db port. Default: $SEDDBPORT aheinecke@5251: # --seddb-user Sediment db user. Default: $SEDDBUSER aheinecke@5251: # --seddb-pass Sediment db password. Default: $SEDDBPASS aheinecke@5251: # --seddb-back Sediment db backend. Default: $SEDDBBACK aheinecke@5251: TOMCAT_PORT=${TOMCAT_PORT:-8282} aheinecke@5671: MAPSERVER_URL=${MAPSERVER_URL:-http://flys-devel.intevation.de} aheinecke@6224: WIKI_URL=${WIKI_URL:-https://flys3-devel.bafg.de/wiki} aheinecke@5530: # Prefix to FreeSans.ttf aheinecke@5530: FONT_PATH=${FONT_PATH:-/opt/flys} teichmann@4494: aheinecke@5251: # Seddb Configuration aheinecke@5251: SEDDBURL=${SEDDBURL:-czech-republic.atlas.intevation.de} aheinecke@6225: SEDDBPORT=${SEDDBPORT:-5432} aheinecke@6225: SEDDBBACK=${SEDDBBACK:-seddb} aheinecke@6225: SEDDBUSER=${SEDDBUSER:-flys} aheinecke@6225: SEDDBPASS=${SEDDBPASS:-flys} aheinecke@5418: SEDINITSQLS=${SEDINITSQLS:-} aheinecke@5418: ingo@4065: aheinecke@5251: # Backend configuration aheinecke@5251: BACKENDURL=${BACKENDURL:-czech-republic.atlas.intevation.de} aheinecke@5251: BACKENDPORT=${BACKENDPORT:-5432} aheinecke@5493: BACKENDBACK=${BACKENDBACK:-flys_devel} aheinecke@5251: BACKENDUSER=${BACKENDUSER:-flys_dami} aheinecke@5251: BACKENDPASS=${BACKENDPASS:-flys_dami} aheinecke@5255: INITSQLS=${INITSQLS:-} tom@7008: DGM_PATH=${DGM_PATH:-/vol1/projects/Geospatial/flys-3.0/testdaten/dami_dgms/} aheinecke@5268: LOG_DIR=/var/log/flys ingo@4065: aheinecke@5251: OPTS=`getopt -o ?w:,t,o \ aheinecke@5251: -l help,oracle \ aheinecke@5251: -n $0 -- "$@"` ingo@4065: aheinecke@5251: if [ $? != 0 ] ; then usage; fi aheinecke@5251: eval set -- "$OPTS" aheinecke@5251: while true ; do aheinecke@5251: case "$1" in aheinecke@5251: "-?"|"--help") aheinecke@5251: usage;; aheinecke@5251: "--") aheinecke@5251: shift aheinecke@5251: break;; aheinecke@5251: "-w") aheinecke@5251: WORK_DIR=$2 aheinecke@5251: shift 2;; aheinecke@5251: "-o"|"--oracle") aheinecke@5251: BUILD_ORACLE="TRUE" aheinecke@5251: shift;; aheinecke@5251: "-t") aheinecke@5251: DO_TAG="TRUE" aheinecke@5251: shift;; aheinecke@5251: *) aheinecke@5251: echo "Unknown Option $1" aheinecke@5251: usage;; aheinecke@5251: esac aheinecke@5251: done teichmann@4484: aheinecke@5251: if [ $# != 1 ]; then aheinecke@5251: usage aheinecke@5251: fi aheinecke@5251: aheinecke@5251: VERSION=$1 aheinecke@5493: if [ "$VERSION" = "default" ]; then aheinecke@5493: ARTIFACT_PORT=${ARTIFACT_PORT:-29999} aheinecke@5493: else aheinecke@5493: ARTIFACT_PORT=${ARTIFACT_PORT:-`echo 1$VERSION | sed 's/\.//g'`} aheinecke@5493: fi aheinecke@5251: aheinecke@5251: if [ -z $WORK_DIR ]; then aheinecke@5251: WORK_DIR=$DEFAULT_WD aheinecke@5251: fi aheinecke@5251: aheinecke@5251: mkdir -p $WORK_DIR aheinecke@5251: aheinecke@5251: if [ ! -d $FLYS_SOURCE_DIR ]; then aheinecke@5251: mkdir -p $FLYS_SOURCE_DIR aheinecke@5251: echo "Cloning sources" aheinecke@5251: cd $FLYS_SOURCE_DIR aheinecke@5900: hg clone $ARTIFACTS_HG_REPO framework aheinecke@5251: hg clone $HTTPCLIIENT_HG_REPO http-client aheinecke@5900: hg clone $FLYS_HG_REPO river aheinecke@5251: else aheinecke@5251: echo "Updating sources / Reverting changes" aheinecke@5251: cd $FLYS_SOURCE_DIR aheinecke@5251: for repo in $REPOS; do aheinecke@5383: cd $repo && hg pull && hg revert -a && hg up && cd $FLYS_SOURCE_DIR aheinecke@5251: done; aheinecke@5251: fi aheinecke@5251: aheinecke@5251: if [ "$DO_TAG" = "TRUE" ]; then aheinecke@5251: echo "Tagging version $VERSION" aheinecke@5251: for repo in $REPOS; do aheinecke@5251: cd $repo aheinecke@5251: CHANGESET=$(hg log -l1 |head -1 | awk -F: '{print $3}') aheinecke@5251: echo "" aheinecke@5251: echo "Do you really want to tag $repo rev: $CHANGESET as Version $VERSION?" aheinecke@5251: echo "press enter to continue or CTRL+C to abort." aheinecke@5251: echo "" aheinecke@5251: hg log -l1 aheinecke@5251: read aheinecke@5320: OLD_REV=$(cat .hgtags | tail -1 | awk '{print $2}') aheinecke@5251: hg tag $VERSION -m "Added tag $VERSION for changeset $CHANGESET" aheinecke@5251: hg push ssh://$DEVELOPER@scm.wald.intevation.org/hg/dive4elements/$repo aheinecke@5320: echo "Changelog for $repo" >> $WORK_DIR/changes_$OLD_REV-$VERSION.txt aheinecke@5320: echo "#############################################################################" \ aheinecke@5320: >> $WORK_DIR/changes_$OLD_REV-$VERSION.txt aheinecke@5320: hg log -r $VERSION:$OLD_REV --style changelog >> $WORK_DIR/changes_$OLD_REV-$VERSION.txt aheinecke@5251: cd $FLYS_SOURCE_DIR aheinecke@5251: done; aheinecke@5251: fi aheinecke@5251: aheinecke@5251: # Update to current version aheinecke@5251: for repo in $REPOS; do aheinecke@5251: cd $repo aheinecke@5251: hg up $VERSION aheinecke@5251: cd $FLYS_SOURCE_DIR aheinecke@5251: done aheinecke@5251: aheinecke@5251: rm -rf "$WORK_DIR/server" "$WORK_DIR/client" aheinecke@5251: cd $WORK_DIR aheinecke@5251: mkdir -p "$WORK_DIR/server/bin/lib/own" aheinecke@5251: mkdir "$WORK_DIR/server/shapefiles" aheinecke@5251: mkdir "$WORK_DIR/client" aheinecke@5251: aheinecke@5251: echo "[INFO]: Preparing configuration of web client" aheinecke@5251: echo "[INFO]: Tomcat Port: $TOMCAT_PORT" aheinecke@5251: echo "[INFO]: Artifact Port: $ARTIFACT_PORT" aheinecke@5692: aheinecke@5692: #Needs to be done before the tomcat replacement below aheinecke@6020: sed -i -e "s@http://localhost:8888/flys/mapfish-print@https://localhost/flys-${VERSION}/flys/mapfish-print@g" \ aheinecke@5900: $FLYS_SOURCE_DIR/river/gwt-client/src/main/webapp/WEB-INF/web.xml aheinecke@5692: 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" \ aheinecke@5900: $FLYS_SOURCE_DIR/river/gwt-client/src/main/webapp/WEB-INF/web.xml ingo@4065: christian@6419: sed -i -e "s@https://flys3-devel.bafg.de/wiki@${WIKI_URL}@g" \ tom@6440: $FLYS_SOURCE_DIR/river/gwt-client/src/main/java/org/dive4elements/river/client/client/config.xml christian@6419: aheinecke@5268: sed -i -e "s@/tmp/flys-client.log@${LOG_DIR}/client-${VERSION}.log@g" \ aheinecke@5900: $FLYS_SOURCE_DIR/river/gwt-client/src/main/webapp/WEB-INF/log4j.properties teichmann@4493: aheinecke@6164: if [ -r "$FEATURES_XML" ]; then aheinecke@6164: cp "$FEATURES_XML" $FLYS_SOURCE_DIR/river/gwt-client/src/main/webapp/WEB-INF/features.xml aheinecke@6164: fi aheinecke@6164: aheinecke@5900: find $FLYS_SOURCE_DIR/river/ -name \*.properties -o -name \*.xsl | \ aheinecke@5325: xargs sed -i "s@https://flys-intern.intevation.de@${WIKI_URL}@g"; teichmann@5119: aheinecke@5678: sed -i -e "s@/usr/share/fonts/truetype/freefont@${FONT_PATH}@g" \ aheinecke@5900: $FLYS_SOURCE_DIR/river/gwt-client/src/main/webapp/WEB-INF/config.yaml aheinecke@5678: aheinecke@5251: if [ ! -f $FLYS_SOURCE_DIR/OpenLayers-2.11.tar.gz ]; then aheinecke@5251: echo "INFO: download OpenLayers-2.11 for client" aheinecke@5251: cd $FLYS_SOURCE_DIR aheinecke@5251: curl -O http://openlayers.org/download/OpenLayers-2.11.tar.gz aheinecke@5251: tar xvfz OpenLayers-2.11.tar.gz aheinecke@5251: # TODO: Remove more superfluous OpenLayers stuff. aheinecke@5251: rm -rf OpenLayers-2.11/doc aheinecke@5251: rm -rf OpenLayers-2.11/tests aheinecke@5251: rm -rf OpenLayers-2.11/examples aheinecke@5251: cd $WORK_DIR aheinecke@5251: fi aheinecke@5900: cp -r $FLYS_SOURCE_DIR/OpenLayers-2.11 $FLYS_SOURCE_DIR/river/gwt-client/src/main/webapp/ ingo@4065: ingo@4065: echo "INFO: compile and build sources" aheinecke@5900: mvn -f $FLYS_SOURCE_DIR/framework/pom.xml clean compile package install aheinecke@5900: mvn -f $FLYS_SOURCE_DIR/river/backend/pom.xml clean compile package install aheinecke@5900: mvn -f $FLYS_SOURCE_DIR/river/artifacts/pom.xml clean compile package dependency:copy-dependencies install aheinecke@5251: mvn -f $FLYS_SOURCE_DIR/http-client/pom.xml clean compile package install aheinecke@5900: mvn -f $FLYS_SOURCE_DIR/river/gwt-client/pom.xml clean compile package ingo@4065: aheinecke@5251: ingo@4065: echo "INFO: copy dependencies and libs" aheinecke@5900: cp $FLYS_SOURCE_DIR/framework/artifact-database/target/artifact-database-1.0-SNAPSHOT.jar $WORK_DIR/server/bin/lib/own/ aheinecke@5900: cp $FLYS_SOURCE_DIR/framework/artifacts/target/artifacts-1.0-SNAPSHOT.jar $WORK_DIR/server/bin/lib/own/ aheinecke@5900: cp $FLYS_SOURCE_DIR/framework/artifacts-common/target/artifacts-common-1.0-SNAPSHOT.jar $WORK_DIR/server/bin/lib/own/ aheinecke@5900: cp $FLYS_SOURCE_DIR/river/backend/target/river-backend-1.0-SNAPSHOT.jar $WORK_DIR/server/bin/lib/own/ aheinecke@5900: cp $FLYS_SOURCE_DIR/river/artifacts/target/river-artifacts-1.0-SNAPSHOT.jar $WORK_DIR/server/bin/lib/own/ aheinecke@5900: cp $FLYS_SOURCE_DIR/river/gwt-client/target/gwt-client-1.0-SNAPSHOT.war $WORK_DIR/client/flys-${VERSION}.war aheinecke@5900: cp $FLYS_SOURCE_DIR/river/artifacts/target/dependency/* $WORK_DIR/server/bin/lib/ ingo@4065: ingo@4065: echo "INFO: copy scripts and libraries to target destination" aheinecke@5251: cp ${SCRIPT_DIR}/bin/run.sh $WORK_DIR/server/bin/ aheinecke@5251: cp ${SCRIPT_DIR}/bin/wsplgen.exe $WORK_DIR/server/bin/ aheinecke@5251: cp ${SCRIPT_DIR}/libs/* $WORK_DIR/server/bin/lib/ ingo@4065: ingo@4065: aheinecke@5251: if [ "$BUILD_ORACLE" = "TRUE" ]; then aheinecke@5251: echo "INFO: remove PostgreSQL and PostGIS libraries" aheinecke@5251: rm $WORK_DIR/server/bin/lib/postg* aheinecke@5251: rm $WORK_DIR/server/bin/lib/hibernate-spatial-postgis* aheinecke@5320: if [ ! -f $ORACLE_JDBC ]; then aheinecke@5320: echo "Could not find oracle jdbc in $ORACLE_JDBC" aheinecke@5320: echo "Please make sure that the ORACLE_JDBC variable is set correctly" aheinecke@5320: exit 1 aheinecke@5320: fi aheinecke@5320: if [ ! -f $ORACLE_HIBERNATE ]; then aheinecke@5320: echo "Could not find hibernate-spatial-oracle in $ORACLE_HIBERNATE" aheinecke@5320: echo "Please make sure that the ORACLE_HIBERNATE variable is set correctly" aheinecke@5320: exit 1 aheinecke@5320: fi aheinecke@5320: cp $ORACLE_HIBERNATE $ORACLE_JDBC $WORK_DIR/server/bin/lib/ aheinecke@5251: else aheinecke@5251: echo "INFO: remove Oralce libraries" aheinecke@5251: rm -f $WORK_DIR/server/bin/lib/hibernate-spatial-oracle-1.1.jar aheinecke@5251: rm -f $WORK_DIR/server/bin/lib/ojdbc* aheinecke@5251: fi ingo@4065: ingo@4065: # fetch the configuration stuff ingo@4065: echo "INFO: copy default configuration to target destination" aheinecke@5900: cp -R $FLYS_SOURCE_DIR/river/artifacts/doc/conf $WORK_DIR/server/ teichmann@4484: aheinecke@5251: sed -i "s/8181/$ARTIFACT_PORT/g" \ aheinecke@5251: $WORK_DIR/server/conf/rest-server.xml teichmann@4484: aheinecke@5671: sed -i -e "s@http://example.com/@${MAPSERVER_URL}/@g" \ aheinecke@5251: $WORK_DIR/server/conf/floodmap.xml ingo@4065: aheinecke@5671: sed -i -e "s@http://example.com/@${MAPSERVER_URL}/@g" \ aheinecke@5251: $WORK_DIR/server/conf/rivermap.xml aheinecke@5251: aheinecke@5530: sed -i -e "s@/usr/share/fonts/truetype/freefont@${FONT_PATH}@g" \ aheinecke@5530: $WORK_DIR/server/conf/mapserver/fontset.txt aheinecke@5530: aheinecke@5325: sed -i -e "s@/tmp/flys-rivers-wms.log@${LOG_DIR}/rivers-wms-${VERSION}.log@g" \ aheinecke@5268: $WORK_DIR/server/conf/mapserver/river-mapfile.vm aheinecke@5268: aheinecke@5325: sed -i -e "s@/tmp/flys-user-wms.log@${LOG_DIR}/user-wms-${VERSION}.log@g" \ aheinecke@5268: $WORK_DIR/server/conf/mapserver/mapfile.vm aheinecke@5268: aheinecke@5268: sed "s@/tmp/flys-server-default.log@${LOG_DIR}/server-${VERSION}.log@" \ aheinecke@5251: $SCRIPT_DIR/confs/log4j.properties \ aheinecke@5251: > $WORK_DIR/server/conf/log4j.properties aheinecke@5251: aheinecke@5602: sed -i -e "s@/path/to/rivers/@${DGM_PATH}@g" \ teichmann@5705: -e "s@http://example.com@${WIKI_URL}@g" \ aheinecke@5602: $WORK_DIR/server/conf/conf.xml aheinecke@5602: aheinecke@5251: aheinecke@5251: if [ "$BUILD_ORACLE" = "TRUE" ]; then aheinecke@5251: # Oracle backend configuration aheinecke@5251: cat > $WORK_DIR/server/conf/backend-db.xml << EOF aheinecke@5251: aheinecke@5251: aheinecke@5255: $BACKENDUSER aheinecke@5255: $BACKENDPASS aheinecke@5251: org.hibernatespatial.oracle.OracleSpatial10gDialect aheinecke@5251: oracle.jdbc.driver.OracleDriver aheinecke@5255: jdbc:oracle:thin:@//$BACKENDURL:$BACKENDPORT/$BACKENDBACK aheinecke@5255: $INITSQLS aheinecke@5251: aheinecke@5251: EOF aheinecke@6225: aheinecke@6225: cat > $WORK_DIR/server/conf/seddb-db.xml << EOF aheinecke@6225: aheinecke@6225: aheinecke@6225: $SEDDBUSER aheinecke@6225: $SEDDBPASS aheinecke@6225: org.hibernate.dialect.Oracle9iDialect aheinecke@6225: oracle.jdbc.driver.OracleDriver aheinecke@6225: jdbc:oracle:thin:@//$SEDDBURL:$SEDDBPORT/$SEDDBBACK aheinecke@6225: $SEDINITSQLS aheinecke@6225: aheinecke@6225: EOF aheinecke@6225: aheinecke@5251: else aheinecke@5251: #Postgresql backend configuration aheinecke@5251: cat > $WORK_DIR/server/conf/backend-db.xml << EOF aheinecke@5251: aheinecke@5251: aheinecke@5251: $BACKENDUSER aheinecke@5251: $BACKENDPASS aheinecke@5251: org.hibernate.dialect.PostgreSQLDialect aheinecke@5251: org.postgresql.Driver aheinecke@5251: jdbc:postgresql://$BACKENDURL:$BACKENDPORT/$BACKENDBACK aheinecke@5255: $INITSQLS aheinecke@5251: aheinecke@5251: EOF aheinecke@6225: aheinecke@6225: cat > $WORK_DIR/server/conf/seddb-db.xml << EOF aheinecke@6225: aheinecke@6225: aheinecke@6225: $SEDDBUSER aheinecke@6225: $SEDDBPASS aheinecke@6225: org.hibernate.dialect.PostgreSQLDialect aheinecke@6225: org.postgresql.Driver aheinecke@6225: jdbc:postgresql://$SEDDBURL:$SEDDBPORT/$SEDDBBACK aheinecke@6225: aheinecke@6225: EOF aheinecke@6225: aheinecke@5251: fi aheinecke@5251: aheinecke@5251: mkdir $WORK_DIR/artifactsdb aheinecke@5251: mkdir $WORK_DIR/datacagedb aheinecke@5251: aheinecke@5900: cp $FLYS_SOURCE_DIR/framework/artifact-database/doc/schema-h2.sql $WORK_DIR/artifactsdb/artifacts-h2.sql aheinecke@5900: cp $FLYS_SOURCE_DIR/river/artifacts/doc/conf/datacage.sql $WORK_DIR/datacagedb/datacage.sql ingo@4065: ingo@4065: echo "INFO: create h2 database for artifacts and datacage" aheinecke@5251: $SCRIPT_DIR/h2/createArtifacts.sh $WORK_DIR/artifactsdb/artifacts-h2.sql aheinecke@5251: $SCRIPT_DIR/h2/createDatacage.sh $WORK_DIR/datacagedb/datacage.sql ingo@4065: aheinecke@5251: mv $WORK_DIR/artifactsdb $WORK_DIR/server/ aheinecke@5251: mv $WORK_DIR/datacagedb $WORK_DIR/server/ ingo@4065: ingo@4065: echo "INFO: create tarball" aheinecke@6612: if [ -d "$WORK_DIR/flys-$VERSION" ]; then aheinecke@6612: echo "INFO: removing old directory" aheinecke@6612: rm -rf "$WORK_DIR/flys-$VERSION" aheinecke@6612: fi aheinecke@6612: aheinecke@5251: mkdir $WORK_DIR/flys-$VERSION aheinecke@5251: mv $WORK_DIR/server $WORK_DIR/client $WORK_DIR/flys-$VERSION aheinecke@5251: cd $WORK_DIR aheinecke@5251: tar cfz flys-$VERSION.tar.gz flys-$VERSION aheinecke@5251: echo "INFO: cleanup" aheinecke@5251: #rm -r $WORK_DIR/flys-$VERSION ingo@4065: aheinecke@5251: echo "DONE: $WORK_DIR/flys-$VERSION.tar.gz" aheinecke@5320: echo "Changelog: $WORK_DIR/changes_$OLD_REV-$VERSION.txt"