Strabon

diff endpoint-exec/strabon-init @ 1497:0aadb8a44fc9

[maven-release-plugin] prepare release v3.3.1
author Babis Nikolaou <charnik@di.uoa.gr>
date Wed Mar 11 20:30:33 2015 +0200 (2015-03-11)
parents
children
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/endpoint-exec/strabon-init	Wed Mar 11 20:30:33 2015 +0200
     1.3 @@ -0,0 +1,53 @@
     1.4 +#!/bin/bash
     1.5 +
     1.6 +sudo -u postgres psql -c "ALTER USER postgres WITH PASSWORD 'postgres';"
     1.7 +
     1.8 +
     1.9 +#dpkg -l
    1.10 +POSTGRES_SQL_PATH=`pg_config --sharedir`'/contrib/';
    1.11 +mytemp=`ls $POSTGRES_SQL_PATH | grep 'postgis-'`
    1.12 +
    1.13 +#check if mytemp is empty, in this case the user must explicitly provide the postgis contrib path
    1.14 +if [ $mytemp == "" ]
    1.15 +then
    1.16 +	echo "Postgis installation could not be found in the default directory. Please state explicitly the full path of your PostGIS installation (e.g. /home/user/...)"
    1.17 +	read POSTGIS_SQL_PATH;
    1.18 +else
    1.19 +	POSTGIS_SQL_PATH=$POSTGRES_SQL_PATH$mytemp
    1.20 +fi
    1.21 +
    1.22 +FILE=$POSTGIS_SQL_PATH'/postgis.sql'
    1.23 +if [ -f $FILE ];
    1.24 +then
    1.25 +   echo "PostGIS installation directory found : $POSTGIS_SQL_PATH "
    1.26 +else
    1.27 +   echo "PostGis installation directory not found. Aborting..."
    1.28 +fi
    1.29 +
    1.30 +template_exists=`sudo -u postgres psql -l | grep template_postgis | wc -l`
    1.31 +if [ $template_exists -eq 1 ]
    1.32 +then
    1.33 +	echo "Database template_postgis already exists, aborting...";
    1.34 +	exit 0
    1.35 +fi
    1.36 +
    1.37 +sudo -u postgres createdb -E UTF8 -T template0 template_postgis
    1.38 +sudo -u postgres createlang -d  template_postgis plpgsql
    1.39 +sudo -u postgres  psql -d template_postgis -f $POSTGIS_SQL_PATH/postgis.sql
    1.40 +sudo -u postgres  psql -d template_postgis -f $POSTGIS_SQL_PATH/spatial_ref_sys.sql
    1.41 +
    1.42 +sudo -u postgres psql -d template_postgis -c "GRANT ALL ON geometry_columns TO PUBLIC;"
    1.43 +sudo -u postgres psql -d template_postgis -c "GRANT ALL ON geography_columns TO PUBLIC;"
    1.44 +sudo -u postgres psql -d template_postgis -c "GRANT ALL ON spatial_ref_sys TO PUBLIC;"
    1.45 +
    1.46 +sudo -u postgres psql -d template_postgis -c "VACUUM FULL;"
    1.47 +sudo -u postgres psql -d template_postgis -c "VACUUM FREEZE;"
    1.48 +
    1.49 +sudo -u postgres psql -d postgres -c "UPDATE pg_database SET datistemplate='true' WHERE datname='template_postgis';"
    1.50 +sudo -u postgres psql -d postgres -c "UPDATE pg_database SET datallowconn='false' WHERE datname='template_postgis';"
    1.51 +
    1.52 +endpoint_exists=`sudo -u postgres psql -l | grep endpoint | wc -l`
    1.53 +if [ $template_exists -eq 0 ]
    1.54 +then
    1.55 +	sudo -u postgres createdb endpoint -T template_postgis
    1.56 +fi