From 4a6eb7a25eaa14b1a0e7c56679893292f9b5fa9d Mon Sep 17 00:00:00 2001
From: Nikolaus Krismer <nikolaus.krismer@uibk.ac.at>
Date: Thu, 28 Nov 2013 16:30:00 +0000
Subject: [PATCH] reworking broken if conditions

---
 etc/vagrant/bootstrap.sh | 177 ++++++++++++++++++++++++---------------
 1 file changed, 108 insertions(+), 69 deletions(-)

diff --git a/etc/vagrant/bootstrap.sh b/etc/vagrant/bootstrap.sh
index 73d7400c..43cd4306 100644
--- a/etc/vagrant/bootstrap.sh
+++ b/etc/vagrant/bootstrap.sh
@@ -1,7 +1,7 @@
 #! /bin/bash
 ###########################
 # This bootstrap script installs some build tools and the packages
-#   postgresql, neo4j, httpd, postgis, pgRouting, osmosis, osm2pgrouting
+#   neo4j, neo4j-spatial, httpd, postgresql, postgis, pgRouting, osmosis, osm2pgrouting
 # into a centos6/fedora19 environment.
 # It can be used in the context of a Vagrantfile to configure a vagrant box.
 #
@@ -17,13 +17,24 @@
 IMPORT_DATA=true
 IMPORT_DATA_CACHED=true
 INSTALL_HTTPD=true
-INSTALL_NEO4J=true
+INSTALL_NEO4J=false
+INSTALL_NEO4J_SPATIAL=true
 INSTALL_POSTGIS=true
 INSTALL_TOMCAT=true
 INSTALL_POSTGRES_ADMIN=true
 
-DISTRI=$(cat /etc/issue | head -n 1 | cut -d " " -f 1)
-DOWNLOAD_DIR=/tmp/vagrant-cache/wget
+NEO4J_DB_USER=neo4j
+PG_DB_NAME="isochrone"
+PG_DB_USER="niko"
+PG_DB_PASSWORD="secretPhdPassword#2013!"
+
+###########################
+# General configuration
+###########################
+
+CACHE_DIR=/tmp/vagrant-cache
+SHARED_DIR=/vagrant
+DOWNLOAD_DIR=$CACHE_DIR/wget
 DEPLOY_DIR=/opt
 GEOSERVER_VERSION=2.4.2
 GEOSERVER_FILE=geoserver-$GEOSERVER_VERSION-war.zip
@@ -35,6 +46,7 @@ MAVEN_VERSION=3.1.1
 MAVEN_FILE=apache-maven-$MAVEN_VERSION-bin.zip
 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
 OSM_BBOX_IBK="top=47.3592 left=11.3020 bottom=47.2108 right=11.4554"
 OSM_FILE=austria-131101.osm.pbf
@@ -51,15 +63,32 @@ POSTGRESQL_REPO_RPM=http://yum.postgresql.org/9.3/fedora/fedora-19-x86_64/pgdg-f
 POSTGRESQL_SERVICE_NAME=postgresql-9.3
 PGROUTING_VERSION=2.0.0
 REPO_CONFIG_FILE=/etc/yum.repos.d/fedora-updates.repo
-START=$(date +%s)
 TABLE_PREFIX=ibk_
+TOMCAT_VERSION=7
 TOMCAT_PKG_NAME=tomcat
 TOMCAT_SERVICE_NAME=$TOMCAT_PKG_NAME
+
+## Calculated variables
+#######################
+
+DISTRI=$(cat /etc/issue | head -n 1 | cut -d " " -f 1)
+INSTALL_JAVA=false
+if $INSTALL_TOMCAT || $INSTALL_NEO4J || $INSTALL_NEO4J_SPATIAL || $IMPORT_DATA; then
+	INSTALL_JAVA=true
+fi
+START=$(date +%s)
 WORKING_DIR=`pwd`
 
-DATABASE_NAME="isochrone"
-DATABASE_USER="niko"
-DATABASE_PASSWORD="secretPhdPassword#2013!"
+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_CONFIG_FILE=/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
 
 ## Functions
 ############
@@ -82,6 +111,17 @@ echo ""
 echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
 echo " Bootstrapping the VM:"
 echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
+echo "Installing the following:"
+if $INSTALL_HTTPD; then echo "  - apache Webserver"; fi
+if $INSTALL_JAVA; then echo "  - java $JAVA_VERSION"; fi
+if $INSTALL_NEO4J; then echo "  - neo4j $NEO4J_VERSION"; fi
+if $INSTALL_NEO4J_SPATIAL; then echo "  - neo4j-spatial $NEO4J_SPATIAL_VERSION"; fi
+if $INSTALL_POSTGIS; then echo "  - postgresql 9.3 and postgis 2"; fi
+if $INSTALL_TOMCAT; then echo "  - tomcat $TOMCAT_VERSION"; fi
+if $INSTALL_POSTGRES_ADMIN; then echo "  - phpPgAdmin"; fi
+if $IMPORT_DATA; then echo "  - osmosis $OSMOSIS_VERSION"; fi
+if $IMPORT_DATA; then echo "Importing data from OSM"; elif $IMPORT_DATA_CACHED; then echo "Importing cached OSM data"; fi
+echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
 
 # Are we punching above our weight?
 if [ "$EUID" -ne "0" ]; then
@@ -95,21 +135,14 @@ mkdir -p $DOWNLOAD_DIR
 echo "Configuring timezone"
 cp /usr/share/zoneinfo/Europe/Vienna /etc/localtime > setup_timezone.log 2>&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_CONFIG_FILE=/etc/yum.repos.d/CentOS-Base.repo
-	TOMCAT_PKG_NAME=tomcat6
-	TOMCAT_SERVICE_NAME=$TOMCAT_PKG_NAME
-fi
-
-if [ $INSTALL_POSTGIS ]; then
+if $INSTALL_POSTGIS; then
 	if [ $DISTRI == "CentOS" ]; then
-		if [ $INSTALL_POSTGIS ]; then
+		if $INSTALL_POSTGIS; then
 			sed -i 's/\[base\]/\[base\]\nexclude=postgresql\*/' $REPO_CONFIG_FILE
 			sed -i 's/\[updates\]/\[updates\]\nexclude=postgresql\*/' $REPO_CONFIG_FILE
 		fi
 	else
-		if [ $INSTALL_POSTGIS ]; then
+		if $INSTALL_POSTGIS; then
 			sed -i 's/\[fedora\]/\[fedora\]\nexclude=postgresql\*/' $REPO_CONFIG_FILE
 		fi
 	fi
@@ -132,12 +165,12 @@ if [ $(getenforce) == "Enforcing" ]; then
   setenforce 0 > stop_selinux.log 2>&1
 fi
 
-if [ $INSTALL_HTTPD ]; then
+if $INSTALL_HTTPD; then
 	echo "Installing httpd server"
 	yum -y install httpd > install_httpd.log 2>&1
 fi
 
-if [ $INSTALL_POSTGIS ]; then
+if $INSTALL_POSTGIS; then
 	echo "Installing $POSTGRESQL_PKG_NAME"
 	yum -y install $POSTGRESQL_PKG_NAME $POSTGRESQL_PKG_NAME-server $POSTGRESQL_PKG_NAME-contrib postgis2_93 > install_database.log 2>&1
 
@@ -169,12 +202,12 @@ if [ $INSTALL_POSTGIS ]; then
 	cd $WORKING_DIR
 fi
 
-if [ $INSTALL_POSTGRES_ADMIN ]; then
+if $INSTALL_POSTGRES_ADMIN; then
 	echo "Installing phpPgAdmin"
 	yum -y install phpPgAdmin > install_phpPgAdmin.log 2>&1
 fi
 
-if [ $INSTALL_TOMCAT ]; then
+if $INSTALL_TOMCAT; then
 	echo "Installing $TOMCAT_PKG_NAME servlet container"
 	yum -y install $TOMCAT_PKG_NAME $TOMCAT_PKG_NAME-webapps $TOMCAT_PKG_NAME-admin-webapps > install_tomcat.log 2>&1
 	ln -sf /usr/share/$TOMCAT_PKG_NAME $DEPLOY_DIR/$TOMCAT_PKG_NAME
@@ -197,7 +230,7 @@ if [ $INSTALL_TOMCAT ]; then
 	make install >> install_geoserver_shell.log 2>&1
 fi
 
-if [ $INSTALL_TOMCAT -o $INSTALL_NEO4J -o $IMPORT_DATA ]; then
+if $INSTALL_JAVA; then
 	echo "Installing java (oracle jdk-$JAVA_VERSION)"
 	download_newer $DOWNLOAD_DIR/$JAVA_FILE http://www.krismer.de/files/$JAVA_FILE
 	yum -y localinstall $DOWNLOAD_DIR/$JAVA_FILE > install_java.log 2>&1
@@ -212,7 +245,7 @@ if [ $INSTALL_TOMCAT -o $INSTALL_NEO4J -o $IMPORT_DATA ]; then
 	alternatives --install /usr/bin/jar jar $DEPLOY_DIR/jdk/bin/jar 200000 >> setup_java.log 2>&1
 fi
 
-if [ $INSTALL_NEO4J ]; then
+if $INSTALL_NEO4J; then
 	echo "Installing neo4j dependencies"
 	yum install -y lsof > install_neo4j_deps.log 2>&1
 
@@ -220,17 +253,20 @@ if [ $INSTALL_NEO4J ]; then
 	download_newer $DOWNLOAD_DIR/$NEO4J_FILE http://dist.neo4j.org/$NEO4J_FILE
 	tar -xvzf $DOWNLOAD_DIR/$NEO4J_FILE -C $DEPLOY_DIR > install_neo4j.log 2>&1
 	ln -sf $DEPLOY_DIR/neo4j-community-$NEO4J_VERSION $DEPLOY_DIR/neo4j
+	echo "org.neo4j.server.webserver.address=0.0.0.0" >> $DEPLOY_DIR/neo4j/conf/neo4j-server.properties
+fi
 
+if $INSTALL_NEO4J_SPATIAL; then
 	echo "Installing maven $MAVEN_VERSION"
-	mkdir -p /tmp/vagrant-cache/maven
+	mkdir -p $CACHE_DIR/maven
 	download_newer $DOWNLOAD_DIR/$MAVEN_FILE http://tweedo.com/mirror/apache/maven/maven-3/3.1.1/binaries/$MAVEN_FILE
 	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
 #	yum -y install xmlstarlet >> install_maven.log
 
 #	echo "Configuring maven to use vagrant-cache plugin"
-#	xmlstarlet edit --inplace --subnode "/_:settings" -t elem -n "localRepository" -v "/tmp/vagrant-cache/maven" $DEPLOY_DIR/apache-maven/conf/settings.xml
-	cp /vagrant/maven-settings.xml $DEPLOY_DIR/apache-maven/conf/settings.xml
+#	xmlstarlet edit --inplace --subnode "/_:settings" -t elem -n "localRepository" -v "$CACHE_DIR/maven" $DEPLOY_DIR/apache-maven/conf/settings.xml
+	cp $SHARED_DIR/maven-settings.xml $DEPLOY_DIR/apache-maven/conf/settings.xml
 
 	echo "export M2_HOME=/opt/apache-maven" > /etc/profile.d/maven.sh
 	echo "export PATH=\${M2_HOME}/bin:\${PATH}" >> /etc/profile.d/maven.sh
@@ -244,14 +280,10 @@ if [ $INSTALL_NEO4J ]; then
 	mvn clean install -DskipTests > $WORKING_DIR/install_neo4j_spatial.log 2>&1
 	unzip -o target/*server-plugin.zip -d $DEPLOY_DIR/$TOMCAT_PKG_NAME/webapps/geoserver/WEB-INF/lib > $WORKING_DIR/install_neo4j_spatial_plugin.log 2>&1
 	cd $WORKING_DIR
-
-#	echo "Installing neo4j-spatial $NEO4J_SPATIAL_VERSION"
-#	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 > install_neo4j_spatial_plugin.log 2>&1
 fi
 
-if [ $IMPORT_DATA ]; then
-	if [ ! $IMPORT_DATA_CACHED ]; then
+if $IMPORT_DATA; then
+	if ! $IMPORT_DATA_CACHED; then
 		echo "Installing osmosis $OSMOSIS_VERSION"
 		download_newer $DOWNLOAD_DIR/$OSMOSIS_FILE http://bretth.dev.openstreetmap.org/osmosis-build/$OSMOSIS_FILE
 		mkdir -p $DEPLOY_DIR/osmosis-$OSMOSIS_VERSION
@@ -260,7 +292,7 @@ if [ $IMPORT_DATA ]; then
 		chmod a+x $DEPLOY_DIR/osmosis/bin/osmosis
 	fi
 
-	if [ $INSTALL_POSTGIS ]; then
+	if $INSTALL_POSTGIS; then
 		echo "Installing osm2pgrouting dependencies"
 		yum install -y expat-devel boost-devel > install_osm2pgrouting_deps.log 2>&1
 		echo "export PostgreSQL_ROOT=/usr/pgsql-9.3" > /etc/profile.d/postgresql.sh
@@ -283,49 +315,56 @@ echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
 echo " Installations done!"
 echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
 
-if [ $INSTALL_POSTGIS ]; then
+if $INSTALL_POSTGIS; then
 	echo "Initialize postgresql database"
 	service $POSTGRESQL_SERVICE_NAME initdb > initialize_postgresql.log 2>&1
 
 	echo "Configuring and starting postgresql-server"
-	cp /vagrant/pg_hba.conf $POSTGRESQL_HBA_CONF
+	cp $SHARED_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
+if $INSTALL_POSTGRES_ADMIN; then
 	echo "Configuring phpPgAdmin"
-	cp /vagrant/phpPgAdmin.conf /etc/httpd/conf.d/phpPgAdmin.conf
+	cp $SHARED_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
 
-if [ $INSTALL_NEO4J ]; then
+if $INSTALL_NEO4J; then
 	echo "Initialize neo4j database"
-	$DEPLOY_DIR/neo4j/bin/neo4j start > initialize_neo4j.log 2>&1
-	$DEPLOY_DIR/neo4j/bin/neo4j stop > initialize_neo4j.log 2>&1
+	$DEPLOY_DIR/neo4j/bin/neo4j -h -u $NEO4J_DB_USER install > initialize_neo4j.log 2>&1
+
+	# Configuring max open file limit for user "neo4j"
+	echo "$NEO4J_DB_USER    soft    nofile    40000" >> /etc/security/limits.conf
+	echo "$NEO4J_DB_USER    hard    nofile    40000" >> /etc/security/limits.conf
+	echo "session    required    pam_limits.so" >> /etc/pam.d/su
+	ulimit -n 40000
 fi
 
-if [ $INSTALL_TOMCAT ]; then
+if $INSTALL_TOMCAT; then
 	echo "Configuring tomcat"
-	cp /vagrant/tomcat-users.xml /usr/share/$TOMCAT_PKG_NAME/conf/tomcat-users.xml
+	cp $SHARED_DIR/tomcat-users.xml /usr/share/$TOMCAT_PKG_NAME/conf/tomcat-users.xml
 
 	echo "Setting permissions"
 	chown -R tomcat:tomcat $DEPLOY_DIR/$TOMCAT_PKG_NAME/webapps/geoserver
 	chown -R tomcat:tomcat $DEPLOY_DIR/geoserver
-	chown -R tomcat:tomcat $DEPLOY_DIR/neo4j
-	chown -R tomcat:tomcat $DEPLOY_DIR/neo4j-community-$NEO4J_VERSION
 fi
 
 echo "Starting services"
-if [ $INSTALL_HTTPD ]; then
+if $INSTALL_HTTPD; then
 	service httpd start > start_httpd.log 2>&1
 	chkconfig httpd on >> start_httpd.log 2>&1
 fi
-if [ $INSTALL_POSTGIS ]; then
+if $INSTALL_POSTGIS; then
 	service $POSTGRESQL_SERVICE_NAME start > start_pg.log 2>&1
 	chkconfig $POSTGRESQL_SERVICE_NAME on >> start_pg.log 2>&1
 fi
-if [ $INSTALL_TOMCAT ]; then
+if $INSTALL_NEO4J; then
+	service $NEO4J_SERVICE_NAME start > start_neo4j.log 2>&1
+	chkconfig $NEO4J_SERVICE_NAME on >> start_neo4j.log 2>&1
+fi
+if $INSTALL_TOMCAT; then
 	service $TOMCAT_SERVICE_NAME start > start_tomcat.log 2>&1
 	chkconfig $TOMCAT_SERVICE_NAME on >> start_tomcat.log 2>&1
 fi
@@ -334,8 +373,8 @@ echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
 echo " Services prepared!"
 echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
 
-if [ $IMPORT_DATA ]; then
-	if [ $IMPORT_DATA_CACHED ]; then
+if $IMPORT_DATA; then
+	if $IMPORT_DATA_CACHED; then
 		echo "Downloading cached OpenStreetMap file"
 		download_newer $DOWNLOAD_DIR/$OSM_FILE_FILTERED http://www.krismer.de/files/$OSM_FILE_FILTERED
 		cp $DOWNLOAD_DIR/$OSM_FILE_FILTERED $DEPLOY_DIR/$OSM_FILE_FILTERED
@@ -348,46 +387,46 @@ if [ $IMPORT_DATA ]; then
 	fi
 fi
 
-if [ $INSTALL_POSTGIS ]; then
-	echo "Creating postgresql database $DATABASE_NAME"
+if $INSTALL_POSTGIS; then
+	echo "Creating postgresql database $PG_DB_NAME"
 	cd $DEPLOY_DIR
-	sudo -u postgres psql -d template1 -c "CREATE DATABASE $DATABASE_NAME;" > $WORKING_DIR/setup_database.log 2>&1
-	sudo -u postgres psql -d $DATABASE_NAME -c "CREATE USER $DATABASE_USER WITH PASSWORD '$DATABASE_PASSWORD';" >> $WORKING_DIR/setup_database.log 2>&1
-	sudo -u postgres psql -d $DATABASE_NAME -c "ALTER DATABASE $DATABASE_NAME OWNER TO $DATABASE_USER;" >> $WORKING_DIR/setup_database.log 2>&1
-	sudo -u postgres psql -d $DATABASE_NAME -c "GRANT ALL PRIVILEGES ON DATABASE $DATABASE_NAME to $DATABASE_USER;" >> $WORKING_DIR/setup_database.log 2>&1
-	sudo -u postgres psql -d $DATABASE_NAME -c "CREATE EXTENSION postgis;" >> $WORKING_DIR/setup_database.log 2>&1
-	sudo -u postgres psql -d $DATABASE_NAME -c "CREATE EXTENSION pgRouting;" >> $WORKING_DIR/setup_database.log 2>&1
+	sudo -u postgres psql -d template1 -c "CREATE DATABASE $PG_DB_NAME;" > $WORKING_DIR/setup_database.log 2>&1
+	sudo -u postgres psql -d $PG_DB_NAME -c "CREATE USER $PG_DB_USER WITH PASSWORD '$PG_DB_PASSWORD';" >> $WORKING_DIR/setup_database.log 2>&1
+	sudo -u postgres psql -d $PG_DB_NAME -c "ALTER DATABASE $PG_DB_NAME OWNER TO $PG_DB_USER;" >> $WORKING_DIR/setup_database.log 2>&1
+	sudo -u postgres psql -d $PG_DB_NAME -c "GRANT ALL PRIVILEGES ON DATABASE $PG_DB_NAME to $PG_DB_USER;" >> $WORKING_DIR/setup_database.log 2>&1
+	sudo -u postgres psql -d $PG_DB_NAME -c "CREATE EXTENSION postgis;" >> $WORKING_DIR/setup_database.log 2>&1
+	sudo -u postgres psql -d $PG_DB_NAME -c "CREATE EXTENSION pgRouting;" >> $WORKING_DIR/setup_database.log 2>&1
 	cd $WORKING_DIR
 fi
 
-if [ $IMPORT_DATA -a $INSTALL_POSTGIS ]; then
+if $IMPORT_DATA && $INSTALL_POSTGIS; then
 	echo "Importing filtered OpenStreetMap data into pgRouting database"
-	$DEPLOY_DIR/osm2pgrouting/build/osm2pgrouting -file "$DEPLOY_DIR/$OSM_FILE_FILTERED" -conf "$OSM2PGROUTING_MAPPING_CONF" -dbname $DATABASE_NAME -user $DATABASE_USER -passwd $DATABASE_PASSWORD -clean -prefixtables $TABLE_PREFIX > import_osm2pgrouting.log 2>&1
+	$DEPLOY_DIR/osm2pgrouting/build/osm2pgrouting -file "$DEPLOY_DIR/$OSM_FILE_FILTERED" -conf "$OSM2PGROUTING_MAPPING_CONF" -dbname $PG_DB_NAME -user $PG_DB_USER -passwd $PG_DB_PASSWORD -clean -prefixtables $TABLE_PREFIX > import_osm2pgrouting.log 2>&1
 fi
 
-if [ $IMPORT_DATA -a $INSTALL_NEO4J ]; then
+if $IMPORT_DATA && $INSTALL_NEO4J_SPATIAL; then
 	echo "Importing filtered OpenStreetMap data into neo4j-spatial database"
 	cd $DEPLOY_DIR/neo4j-spatial
 	mvn exec:java -Dexec.mainClass=org.neo4j.gis.spatial.osm.OSMImporter -Dexec.args="$DEPLOY_DIR/neo4j/data/graph.db $DEPLOY_DIR/$OSM_FILE_FILTERED" > $WORKING_DIR/import_osm2neo4j.log 2>&1
-	if [ $INSTALL_TOMCAT ]; then
+	if $INSTALL_TOMCAT; then
 		echo "Setting permissions for neo4j data"
 		chown -R tomcat:tomcat $DEPLOY_DIR/neo4j/data/graph.db
 	fi
 	cd $WORKING_DIR
 fi
 
-if [ $INSTALL_TOMCAT ]; then
+if $INSTALL_TOMCAT; then
 	echo "Starting geoserver $GEOSERVER_VERSION"
 	JAVA_HOME=$DEPLOY_DIR/jre GEOSERVER_HOME=$DEPLOY_DIR/geoserver $DEPLOY_DIR/geoserver/bin/startup.sh > start_geoserver.log 2>&1 &
 
-	if [ $INSTALL_NEO4J -o $INSTALL_POSTGIS ]; then
+	if $INSTALL_NEO4J_SPATIAL || $INSTALL_POSTGIS; then
 		echo "Configuring geoserver $GEOSERVER_VERSION using geoserver-shell $GEOSERVER_SHELL_VERSION"
-		sh $DEPLOY_DIR/gs-shell/bin/gs-shell --cmdfile /vagrant/geoserver_setup_workspace.gs > setup_geoserver_workspace.log 2>&1
-		if [ $INSTALL_NEO4J ]; then
-			sh $DEPLOY_DIR/gs-shell/bin/gs-shell --cmdfile /vagrant/geoserver_setup_neo4j.gs > setup_geoserver_neo4j.log 2>&1
+		sh $DEPLOY_DIR/gs-shell/bin/gs-shell --cmdfile $SHARED_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
 		fi
-		if [ $INSTALL_POSTGIS ]; then
-			sh $DEPLOY_DIR/gs-shell/bin/gs-shell --cmdfile /vagrant/geoserver_setup_postgis.gs > setup_geoserver_postgis.log 2>&1
+		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
 		fi
 	fi
 fi
-- 
GitLab