diff --git a/etc/vagrant/bootstrap.sh b/etc/vagrant/bootstrap.sh index e554ccdd4aa4ad824cc8927b7f04de2fad78926b..4653db7a839e37b47533d9c7bde7a6035ea9ee1d 100644 --- a/etc/vagrant/bootstrap.sh +++ b/etc/vagrant/bootstrap.sh @@ -27,7 +27,6 @@ INSTALL_POSTGRES=true INSTALL_POSTGRES_ADMIN=true INSTALL_TEMPLATE_PROJECT=true -NEO4J_DB_USER=neo4j PG_DB_NAME="isochrone" PG_DB_USER="niko" PG_DB_PASSWORD="secretPhdPassword#2013!" @@ -40,7 +39,7 @@ CACHE_DIR_LOCAL=/tmp/vagrant-cache CACHE_DIR_REMOTE=http://www.krismer.de/files/PhD DEPLOY_DIR=/opt DOWNLOAD_DIR=$CACHE_DIR_LOCAL/wget -SHARED_DIR=/vagrant +SHARED_CONF_DIR=/vagrant/conf CMAKE_VERSION=2.8.12.1 CMAKE_VERSION_MAIN=v2.8 @@ -53,10 +52,12 @@ JAVA_VERSION=7u45 JAVA_FILE=jdk-$JAVA_VERSION-linux-x64.rpm MAVEN_VERSION=3.1.1 MAVEN_FILE=apache-maven-$MAVEN_VERSION-bin.zip +NEO4J_DB_USER=neo4j NEO4J_VERSION=1.9.5 NEO4J_FILE=neo4j-community-$NEO4J_VERSION-unix.tar.gz NEO4J_SERVICE_NAME=neo4j-service NEO4J_SPATIAL_VERSION=0.11-neo4j-1.9 +NEXUS_REPO=https://server.krismer.de/nexus/content/repositories/releases OSM_BBOX_BZ="top=46.5200 left=11.3000 bottom=46.4500 right=11.3873" OSM_BBOX_IBK="top=47.3592 left=11.3020 bottom=47.2108 right=11.4554" OSM_FILE_AUSTRIA=austria-131201.osm.pbf @@ -79,25 +80,21 @@ REPO_BASE_CONFIG=/etc/yum.repos.d/fedora-updates.repo REPO_RPMFORGE_CONFIG=/etc/yum.repos.d/rpmforge.repo TABLE_PREFIX_BZ=bz_ TABLE_PREFIX_IBK=ibk_ -TEMPLATE_PROJECT_FILE=https://server.krismer.de/nexus/content/groups/public/de/krismer/CanIGet2/0.1-SNAPSHOT/CanIGet2-0.1-20131204.174349-1.war +TEMPLATE_PROJECT_FILE=$NEXUS_REPO/de/krismer/CanIGet2/0.1/CanIGet2-0.1.war +TOMCAT_USER=tomcat TOMCAT_VERSION=7 -TOMCAT_PKG_NAME=tomcat -TOMCAT_SERVICE_NAME=$TOMCAT_PKG_NAME TOPOLOGY_TOLERANCE=0.0005 ## Calculated variables ####################### -DISTRI=$(cat /etc/issue | head -n 1 | cut -d " " -f 1) INSTALL_JAVA=false INSTALL_MAVEN=false INSTALL_TOMCAT=false -START=$(date +%s) -WORKING_DIR=`pwd` if $INSTALL_GEOSERVER || $INSTALL_TEMPLATE_PROJECT; then INSTALL_TOMCAT=true -if +fi if $INSTALL_NEO4J_SPATIAL; then INSTALL_MAVEN=$IMPORT_OSMDATA || $IMPORT_OSMDATA_CACHED fi @@ -111,17 +108,22 @@ if $INSTALL_POSTGRES_ADMIN || $INSALL_POSTGIS; then INSTALL_POSTGRES=true fi +DISTRI=$(cat /etc/issue | head -n 1 | cut -d " " -f 1) if [ $DISTRI == "CentOS" ]; then POSTGRESQL_REPO_RPM=http://yum.postgresql.org/9.3/redhat/rhel-6-x86_64/pgdg-centos93-9.3-1.noarch.rpm REPO_BASE_CONFIG=/etc/yum.repos.d/CentOS-Base.repo TOMCAT_VERSION=6 - TOMCAT_PKG_NAME=tomcat$TOMCAT_VERSION - TOMCAT_SERVICE_NAME=$TOMCAT_PKG_NAME elif [ $DISTRI != "Fedora" ]; then echo "Unsupported OS. Only CentOS and Fedora are supported!" exit 1; fi +START=$(date +%s) +TOMCAT_PKG_NAME=tomcat$TOMCAT_VERSION +TOMCAT_SERVICE_NAME=$TOMCAT_PKG_NAME +TOMCAT_WEBAPP_DIR=$DEPLOY_DIR/$TOMCAT_PKG_NAME/webapps +WORKING_DIR=`pwd` + ## Functions ############ @@ -347,13 +349,17 @@ fi if $INSTALL_GEOSERVER; then echo "Installing geoserver $GEOSERVER_VERSION" fn_download_newer $DOWNLOAD_DIR/$GEOSERVER_FILE http://sourceforge.net/projects/geoserver/files/GeoServer/$GEOSERVER_VERSION/$GEOSERVER_FILE - unzip -o -d $DEPLOY_DIR/$TOMCAT_PKG_NAME/webapps $DOWNLOAD_DIR/$GEOSERVER_FILE geoserver.war > install_geoserver.log 2>&1 - echo "CATALINA_OPTS=\"-Djava.awt.headless=true -DGEOSERVER_DATA_DIR=$DEPLOY_DIR/geoserver/data_dir\"" >> /usr/share/$TOMCAT_PKG_NAME/conf/tomcat.conf - mkdir -p $DEPLOY_DIR/geoserver/data_dir + unzip -o -d $TOMCAT_WEBAPP_DIR $DOWNLOAD_DIR/$GEOSERVER_FILE geoserver.war > install_geoserver.log 2>&1 + echo "CATALINA_OPTS=\"-Djava.awt.headless=true -Xmx512m -Xms128m -XX:MaxPermSize=128m -DGEOSERVER_DATA_DIR=$DEPLOY_DIR/geoserver/data\"" >> /usr/share/$TOMCAT_PKG_NAME/conf/$TOMCAT_PKG_NAME.conf echo "Installing geoserver web archive into tomcat" - mkdir -p $DEPLOY_DIR/$TOMCAT_PKG_NAME/webapps/geoserver - unzip $DEPLOY_DIR/$TOMCAT_PKG_NAME/webapps/geoserver.war -d $DEPLOY_DIR/$TOMCAT_PKG_NAME/webapps/geoserver >> install_geoserver.log 2>&1 + mkdir -p $TOMCAT_WEBAPP_DIR/geoserver + unzip -o -d $TOMCAT_WEBAPP_DIR/geoserver $TOMCAT_WEBAPP_DIR/geoserver.war >> install_geoserver.log 2>&1 + rm -f $TOMCAT_WEBAPP_DIR/geoserver.war >> install_geoserver.log 2>&1 + + echo "Installing geoserver data directory" + mkdir -p $DEPLOY_DIR/geoserver >> install_geoserver.log 2>&1 + mv $TOMCAT_WEBAPP_DIR/geoserver/data $DEPLOY_DIR/geoserver >> install_geoserver.log 2>&1 echo "Installing geoserver-shell $GEOSERVER_SHELL_VERSION" fn_download_newer $DOWNLOAD_DIR/$GEOSERVER_SHELL_FILE $CACHE_DIR_REMOTE/$GEOSERVER_SHELL_FILE @@ -363,6 +369,15 @@ if $INSTALL_GEOSERVER; then make install >> install_geoserver_shell.log 2>&1 fi +if $INSTALL_TEMPLATE_PROJECT; then + echo "Installing template project CanIGet2" + fn_download_newer $DOWNLOAD_DIR/caniget2.war $TEMPLATE_PROJECT_FILE + cp $DOWNLOAD_DIR/caniget2.war $TOMCAT_WEBAPP_DIR + unzip -o -d $TOMCAT_WEBAPP_DIR/caniget2 $TOMCAT_WEBAPP_DIR/caniget2.war > install_caniget2.log 2>&1 + rm -f $TOMCAT_WEBAPP_DIR/caniget2.war >> install_caniget2.log 2>&1 +fi + + if $INSTALL_JAVA; then echo "Installing java (oracle jdk-$JAVA_VERSION)" fn_download_newer $DOWNLOAD_DIR/$JAVA_FILE $CACHE_DIR_REMOTE/$JAVA_FILE @@ -385,14 +400,14 @@ if $INSTALL_MAVEN; then unzip -o $DOWNLOAD_DIR/$MAVEN_FILE -d $DEPLOY_DIR > install_maven.log 2>&1 ln -sf $DEPLOY_DIR/apache-maven-$MAVEN_VERSION $DEPLOY_DIR/apache-maven - echo "export M2_HOME=/opt/apache-maven" > /etc/profile.d/maven.sh + echo "export M2_HOME=$DEPLOY_DIR/apache-maven" > /etc/profile.d/maven.sh echo "export PATH=\${M2_HOME}/bin:\${PATH}" >> /etc/profile.d/maven.sh source /etc/profile.d/maven.sh echo "Configuring maven to use vagrant-cache plugin" # yum -y install xmlstarlet >> install_xmlstarlet.log # xmlstarlet edit --inplace --subnode "/_:settings" -t elem -n "localRepository" -v "$CACHE_DIR_LOCAL/maven" $DEPLOY_DIR/apache-maven/conf/settings.xml - cp $SHARED_DIR/maven-settings.xml $DEPLOY_DIR/apache-maven/conf/settings.xml + cp $SHARED_CONF_DIR/maven-settings.xml $DEPLOY_DIR/apache-maven/conf/settings.xml fi if $INSTALL_NEO4J; then @@ -418,11 +433,11 @@ if $INSTALL_NEO4J_SPATIAL; then # We need to compile the source when importing data, so that the main class gets compiled echo "Installing neo4j-spatial into geoserver from source" mvn clean install -DskipTests > $WORKING_DIR/install_neo4j_spatial.log 2>&1 - unzip -o $DEPLOY_DIR/neo4j-spatial/target/*server-plugin.zip -d $DEPLOY_DIR/$TOMCAT_PKG_NAME/webapps/geoserver/WEB-INF/lib > $WORKING_DIR/install_neo4j_spatial_plugin.log 2>&1 + unzip -o $DEPLOY_DIR/neo4j-spatial/target/*server-plugin.zip -d $TOMCAT_WEBAPP_DIR/geoserver/WEB-INF/lib > $WORKING_DIR/install_neo4j_spatial_plugin.log 2>&1 else echo "Installing neo4j-spatial into geoserver from binary" fn_download_newer $DOWNLOAD_DIR/neo4j-spatial-$NEO4J_SPATIAL_VERSION-server-plugin.zip http://dist.neo4j.org.s3.amazonaws.com/spatial/neo4j-spatial-$NEO4J_SPATIAL_VERSION-server-plugin.zip - unzip -o $DOWNLOAD_DIR/neo4j-spatial-$NEO4J_SPATIAL_VERSION-server-plugin.zip -d $DEPLOY_DIR/$TOMCAT_PKG_NAME/webapps/geoserver/WEB-INF/lib > $WORKING_DIR/install_neo4j_spatial_plugin.log 2>&1 + unzip -o $DOWNLOAD_DIR/neo4j-spatial-$NEO4J_SPATIAL_VERSION-server-plugin.zip -d $TOMCAT_WEBAPP_DIR/geoserver/WEB-INF/lib > $WORKING_DIR/install_neo4j_spatial_plugin.log 2>&1 fi fi cd $WORKING_DIR @@ -462,14 +477,14 @@ if $INSTALL_POSTGRES; then service $POSTGRESQL_SERVICE_NAME initdb > initialize_postgresql.log 2>&1 echo "Configuring and starting postgresql-server" - cp $SHARED_DIR/pg_hba.conf $POSTGRESQL_HBA_CONF + cp $SHARED_CONF_DIR/pg_hba.conf $POSTGRESQL_HBA_CONF echo "listen_addresses = '*'" >> $POSTGRESQL_DATA_DIR/postgresql.conf echo "port = 5432" >> $POSTGRESQL_DATA_DIR/postgresql.conf fi if $INSTALL_POSTGRES_ADMIN; then echo "Configuring phpPgAdmin" - cp $SHARED_DIR/phpPgAdmin.conf /etc/httpd/conf.d/phpPgAdmin.conf + cp $SHARED_CONF_DIR/phpPgAdmin.conf /etc/httpd/conf.d/phpPgAdmin.conf sed -i 's/\$conf\['\''servers'\''\]\[0\]\['\''host'\''\] = '\'''\''/\$conf\['\''servers'\''\]\[0\]\['\''host'\''\] = '\''localhost'\''/' /usr/share/phpPgAdmin/conf/config.inc.php fi @@ -486,11 +501,11 @@ fi if $INSTALL_TOMCAT; then echo "Configuring tomcat users" - cp $SHARED_DIR/tomcat-users.xml /usr/share/$TOMCAT_PKG_NAME/conf/tomcat-users.xml + cp $SHARED_CONF_DIR/tomcat-users.xml /usr/share/$TOMCAT_PKG_NAME/conf/tomcat-users.xml echo "Configuring tomcat permissions" - chown -R tomcat:tomcat $DEPLOY_DIR/$TOMCAT_PKG_NAME/webapps/geoserver - chown -R tomcat:tomcat $DEPLOY_DIR/geoserver + chown -R $TOMCAT_USER:$TOMCAT_USER $TOMCAT_WEBAPP_DIR/geoserver + chown -R $TOMCAT_USER:$TOMCAT_USER $DEPLOY_DIR/geoserver fi echo "Starting services" @@ -539,30 +554,24 @@ if $IMPORT_OSMDATA || $IMPORT_OSMDATA_CACHED; then if $INSTALL_GEOSERVER; then if $INSTALL_NEO4J_SPATIAL; then echo "Configuring neo4j data permissions for geoserver" - chown -R tomcat:tomcat $DEPLOY_DIR/neo4j/data/graph.db + chown -R $TOMCAT_USER:$TOMCAT_USER $DEPLOY_DIR/neo4j/data/graph.db fi echo "Configuring geoserver $GEOSERVER_VERSION using geoserver-shell $GEOSERVER_SHELL_VERSION" - sh $DEPLOY_DIR/gs-shell/bin/gs-shell --cmdfile $SHARED_DIR/geoserver_setup_workspace.gs > setup_geoserver_workspace.log 2>&1 + sh $DEPLOY_DIR/gs-shell/bin/gs-shell --cmdfile $SHARED_CONF_DIR/geoserver_setup_workspace.gs > setup_geoserver_workspace.log 2>&1 if $INSTALL_NEO4J_SPATIAL; then - sh $DEPLOY_DIR/gs-shell/bin/gs-shell --cmdfile $SHARED_DIR/geoserver_setup_neo4j.gs > setup_geoserver_neo4j.log 2>&1 + sh $DEPLOY_DIR/gs-shell/bin/gs-shell --cmdfile $SHARED_CONF_DIR/geoserver_setup_neo4j_ds.gs > setup_geoserver_neo4j.log 2>&1 + sh $DEPLOY_DIR/gs-shell/bin/gs-shell --cmdfile $SHARED_CONF_DIR/geoserver_setup_neo4j_ft_bz.gs >> setup_geoserver_neo4j.log 2>&1 + sh $DEPLOY_DIR/gs-shell/bin/gs-shell --cmdfile $SHARED_CONF_DIR/geoserver_setup_neo4j_ft_ibk.gs >> setup_geoserver_neo4j.log 2>&1 fi if $INSTALL_POSTGIS; then - sh $DEPLOY_DIR/gs-shell/bin/gs-shell --cmdfile $SHARED_DIR/geoserver_setup_postgis.gs > setup_geoserver_postgis.log 2>&1 + sh $DEPLOY_DIR/gs-shell/bin/gs-shell --cmdfile $SHARED_CONF_DIR/geoserver_setup_postgis_ds.gs > setup_geoserver_postgis.log 2>&1 + sh $DEPLOY_DIR/gs-shell/bin/gs-shell --cmdfile $SHARED_CONF_DIR/geoserver_setup_postgis_ft_bz.gs >> setup_geoserver_postgis.log 2>&1 + sh $DEPLOY_DIR/gs-shell/bin/gs-shell --cmdfile $SHARED_CONF_DIR/geoserver_setup_postgis_ft_ibk.gs >> setup_geoserver_postgis.log 2>&1 fi fi fi -if $INSTALL_TEMPLATE_PROJECT; then - echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" - echo " Installing template project(s) - echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" - - echo "Installing template project 'CanIGet2'" - fn_download_newer $DOWNLOAD_DIR/caniget2.war $TEMPLATE_PROJECT_FILE - cp $DOWNLOAD_DIR/caniget2.war $DEPLOY_DIR/$TOMCAT_PKG_NAME/webapps -fi - END=$(date +%s) TOTAL=$(( $END - $START )) diff --git a/etc/vagrant/geoserver_setup_neo4j.gs b/etc/vagrant/conf/geoserver_setup_neo4j_ds.gs similarity index 88% rename from etc/vagrant/geoserver_setup_neo4j.gs rename to etc/vagrant/conf/geoserver_setup_neo4j_ds.gs index a392bc09aaaaaca343151447eb65db5b1813ff8c..41ad4573d78a94fd5e9bfc9f496ba967ff48e24f 100644 --- a/etc/vagrant/geoserver_setup_neo4j.gs +++ b/etc/vagrant/conf/geoserver_setup_neo4j_ds.gs @@ -3,5 +3,3 @@ geoserver set --url http://localhost:8080/geoserver --user admin --password geos datastore create --workspace isochrone --name Neo4J --connectionParams "dbtype=neo4j 'The directory path of the Neo4j database: '=/opt/neo4j/data/graph.db" datastore modify --workspace isochrone --name Neo4J --description "Neo4J datastore" datastore modify --workspace isochrone --name Neo4J --enabled true - -# ToDo: publish /opt/innsbruck-131101-filtered.osm diff --git a/etc/vagrant/conf/geoserver_setup_neo4j_ft.gs b/etc/vagrant/conf/geoserver_setup_neo4j_ft.gs new file mode 100644 index 0000000000000000000000000000000000000000..10c0af3462fe49879016a55544b7c954a05db138 --- /dev/null +++ b/etc/vagrant/conf/geoserver_setup_neo4j_ft.gs @@ -0,0 +1,3 @@ +geoserver set --url http://localhost:8080/geoserver --user admin --password geoserver + +#layer group create --workspace isochrone --layers n4j_bz_ways,n4j_ibk_ways diff --git a/etc/vagrant/conf/geoserver_setup_neo4j_ft_bz.gs b/etc/vagrant/conf/geoserver_setup_neo4j_ft_bz.gs new file mode 100644 index 0000000000000000000000000000000000000000..2da56fe7c6497bd6de77de7344f877a567ae4770 --- /dev/null +++ b/etc/vagrant/conf/geoserver_setup_neo4j_ft_bz.gs @@ -0,0 +1,3 @@ +geoserver set --url http://localhost:8080/geoserver --user admin --password geoserver + +# ToDo: Create featuretype for datastore "Neo4j" and public roads in bozen diff --git a/etc/vagrant/conf/geoserver_setup_neo4j_ft_ibk.gs b/etc/vagrant/conf/geoserver_setup_neo4j_ft_ibk.gs new file mode 100644 index 0000000000000000000000000000000000000000..26c225398bc68a068eea9a2fb45e02c98723e356 --- /dev/null +++ b/etc/vagrant/conf/geoserver_setup_neo4j_ft_ibk.gs @@ -0,0 +1,3 @@ +geoserver set --url http://localhost:8080/geoserver --user admin --password geoserver + +# ToDo: Create featuretype for datastore "Neo4j" and public roads in innsbruck diff --git a/etc/vagrant/geoserver_setup_postgis.gs b/etc/vagrant/conf/geoserver_setup_postgis_ds.gs similarity index 81% rename from etc/vagrant/geoserver_setup_postgis.gs rename to etc/vagrant/conf/geoserver_setup_postgis_ds.gs index cf79c8977624655926e81db4a613a16497dafd0d..4abeb9d3ce9a380c9bf5f55cca559790392f9b38 100644 --- a/etc/vagrant/geoserver_setup_postgis.gs +++ b/etc/vagrant/conf/geoserver_setup_postgis_ds.gs @@ -2,6 +2,4 @@ geoserver set --url http://localhost:8080/geoserver --user admin --password geos postgis datastore create --workspace isochrone --datastore PostGIS --host localhost --port 5432 --database isochrone --schema public --user niko --password secretPhdPassword#2013! datastore modify --workspace isochrone --name PostGIS --description "PostGIS datastore" -datastore modify --workspace isochrone --name PostGIS --enabled true - -postgis featuretype publish --workspace isochrone --datastore PostGIS --table ibk_ways +datastore modify --workspace isochrone --name PostGIS --enabled true \ No newline at end of file diff --git a/etc/vagrant/conf/geoserver_setup_postgis_ft.gs b/etc/vagrant/conf/geoserver_setup_postgis_ft.gs new file mode 100644 index 0000000000000000000000000000000000000000..6c55e9e3e384518c23c98f95cc9f6f088c440a68 --- /dev/null +++ b/etc/vagrant/conf/geoserver_setup_postgis_ft.gs @@ -0,0 +1,3 @@ +geoserver set --url http://localhost:8080/geoserver --user admin --password geoserver + +layer group create --workspace isochrone --layers pg_bz_ways,pg_ibk_ways diff --git a/etc/vagrant/conf/geoserver_setup_postgis_ft_bz.gs b/etc/vagrant/conf/geoserver_setup_postgis_ft_bz.gs new file mode 100644 index 0000000000000000000000000000000000000000..07216acf283189ab84b480401e843c3c1468da90 --- /dev/null +++ b/etc/vagrant/conf/geoserver_setup_postgis_ft_bz.gs @@ -0,0 +1,4 @@ +geoserver set --url http://localhost:8080/geoserver --user admin --password geoserver + +postgis featuretype publish --workspace isochrone --datastore PostGIS --table bz_ways +featuretype modify --workspace isochrone --datastore PostGIS --featuretype "bz_ways" --name "pg_bz_ways" diff --git a/etc/vagrant/conf/geoserver_setup_postgis_ft_ibk.gs b/etc/vagrant/conf/geoserver_setup_postgis_ft_ibk.gs new file mode 100644 index 0000000000000000000000000000000000000000..72b41ad59b1e0228e685a56c967db2789d199069 --- /dev/null +++ b/etc/vagrant/conf/geoserver_setup_postgis_ft_ibk.gs @@ -0,0 +1,4 @@ +geoserver set --url http://localhost:8080/geoserver --user admin --password geoserver + +postgis featuretype publish --workspace isochrone --datastore PostGIS --table ibk_ways +featuretype modify --workspace isochrone --datastore PostGIS --featuretype "ibk_ways" --name "pg_ibk_ways" diff --git a/etc/vagrant/geoserver_setup_workspace.gs b/etc/vagrant/conf/geoserver_setup_ws.gs similarity index 100% rename from etc/vagrant/geoserver_setup_workspace.gs rename to etc/vagrant/conf/geoserver_setup_ws.gs diff --git a/etc/vagrant/maven-settings.xml b/etc/vagrant/conf/maven-settings.xml similarity index 100% rename from etc/vagrant/maven-settings.xml rename to etc/vagrant/conf/maven-settings.xml diff --git a/etc/vagrant/pg_hba.conf b/etc/vagrant/conf/pg_hba.conf similarity index 100% rename from etc/vagrant/pg_hba.conf rename to etc/vagrant/conf/pg_hba.conf diff --git a/etc/vagrant/phpPgAdmin.conf b/etc/vagrant/conf/phpPgAdmin.conf similarity index 100% rename from etc/vagrant/phpPgAdmin.conf rename to etc/vagrant/conf/phpPgAdmin.conf diff --git a/etc/vagrant/tomcat-users.xml b/etc/vagrant/conf/tomcat-users.xml similarity index 100% rename from etc/vagrant/tomcat-users.xml rename to etc/vagrant/conf/tomcat-users.xml