Strabon

annotate endpoint-exec/strabon-init @ 1487:0397b9f4b68f

[maven-release-plugin] prepare release v3.3.1
author Babis Nikolaou <charnik@di.uoa.gr>
date Wed Mar 11 20:00:38 2015 +0200 (2015-03-11)
parents
children
rev   line source
johnvl@1456 1 #!/bin/bash
johnvl@1456 2
johnvl@1456 3 sudo -u postgres psql -c "ALTER USER postgres WITH PASSWORD 'postgres';"
johnvl@1456 4
johnvl@1456 5
johnvl@1456 6 #dpkg -l
johnvl@1456 7 POSTGRES_SQL_PATH=`pg_config --sharedir`'/contrib/';
johnvl@1456 8 mytemp=`ls $POSTGRES_SQL_PATH | grep 'postgis-'`
johnvl@1456 9
johnvl@1456 10 #check if mytemp is empty, in this case the user must explicitly provide the postgis contrib path
johnvl@1456 11 if [ $mytemp == "" ]
johnvl@1456 12 then
johnvl@1456 13 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/...)"
johnvl@1456 14 read POSTGIS_SQL_PATH;
johnvl@1456 15 else
johnvl@1456 16 POSTGIS_SQL_PATH=$POSTGRES_SQL_PATH$mytemp
johnvl@1456 17 fi
johnvl@1456 18
johnvl@1456 19 FILE=$POSTGIS_SQL_PATH'/postgis.sql'
johnvl@1456 20 if [ -f $FILE ];
johnvl@1456 21 then
johnvl@1456 22 echo "PostGIS installation directory found : $POSTGIS_SQL_PATH "
johnvl@1456 23 else
johnvl@1456 24 echo "PostGis installation directory not found. Aborting..."
johnvl@1456 25 fi
johnvl@1456 26
johnvl@1456 27 template_exists=`sudo -u postgres psql -l | grep template_postgis | wc -l`
johnvl@1456 28 if [ $template_exists -eq 1 ]
johnvl@1456 29 then
johnvl@1456 30 echo "Database template_postgis already exists, aborting...";
johnvl@1456 31 exit 0
johnvl@1456 32 fi
johnvl@1456 33
johnvl@1456 34 sudo -u postgres createdb -E UTF8 -T template0 template_postgis
johnvl@1456 35 sudo -u postgres createlang -d template_postgis plpgsql
johnvl@1456 36 sudo -u postgres psql -d template_postgis -f $POSTGIS_SQL_PATH/postgis.sql
johnvl@1456 37 sudo -u postgres psql -d template_postgis -f $POSTGIS_SQL_PATH/spatial_ref_sys.sql
johnvl@1456 38
johnvl@1456 39 sudo -u postgres psql -d template_postgis -c "GRANT ALL ON geometry_columns TO PUBLIC;"
johnvl@1456 40 sudo -u postgres psql -d template_postgis -c "GRANT ALL ON geography_columns TO PUBLIC;"
johnvl@1456 41 sudo -u postgres psql -d template_postgis -c "GRANT ALL ON spatial_ref_sys TO PUBLIC;"
johnvl@1456 42
johnvl@1456 43 sudo -u postgres psql -d template_postgis -c "VACUUM FULL;"
johnvl@1456 44 sudo -u postgres psql -d template_postgis -c "VACUUM FREEZE;"
johnvl@1456 45
johnvl@1456 46 sudo -u postgres psql -d postgres -c "UPDATE pg_database SET datistemplate='true' WHERE datname='template_postgis';"
johnvl@1456 47 sudo -u postgres psql -d postgres -c "UPDATE pg_database SET datallowconn='false' WHERE datname='template_postgis';"
johnvl@1456 48
johnvl@1456 49 endpoint_exists=`sudo -u postgres psql -l | grep endpoint | wc -l`
johnvl@1456 50 if [ $template_exists -eq 0 ]
johnvl@1456 51 then
johnvl@1456 52 sudo -u postgres createdb endpoint -T template_postgis
johnvl@1456 53 fi