Strabon

view endpoint-exec/strabon-init @ 1456:3a20ea696d0e

#58 Added dependencies and a script for initializing the template_postgis
(strabon-init). See more at Changelog.
author Giannis Vlachopoulos <johnvl@di.uoa.gr>
date Thu Jan 15 13:44:51 2015 +0200 (2015-01-15)
parents
children
line source
1 #!/bin/bash
3 sudo -u postgres psql -c "ALTER USER postgres WITH PASSWORD 'postgres';"
6 #dpkg -l
7 POSTGRES_SQL_PATH=`pg_config --sharedir`'/contrib/';
8 mytemp=`ls $POSTGRES_SQL_PATH | grep 'postgis-'`
10 #check if mytemp is empty, in this case the user must explicitly provide the postgis contrib path
11 if [ $mytemp == "" ]
12 then
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/...)"
14 read POSTGIS_SQL_PATH;
15 else
16 POSTGIS_SQL_PATH=$POSTGRES_SQL_PATH$mytemp
17 fi
19 FILE=$POSTGIS_SQL_PATH'/postgis.sql'
20 if [ -f $FILE ];
21 then
22 echo "PostGIS installation directory found : $POSTGIS_SQL_PATH "
23 else
24 echo "PostGis installation directory not found. Aborting..."
25 fi
27 template_exists=`sudo -u postgres psql -l | grep template_postgis | wc -l`
28 if [ $template_exists -eq 1 ]
29 then
30 echo "Database template_postgis already exists, aborting...";
31 exit 0
32 fi
34 sudo -u postgres createdb -E UTF8 -T template0 template_postgis
35 sudo -u postgres createlang -d template_postgis plpgsql
36 sudo -u postgres psql -d template_postgis -f $POSTGIS_SQL_PATH/postgis.sql
37 sudo -u postgres psql -d template_postgis -f $POSTGIS_SQL_PATH/spatial_ref_sys.sql
39 sudo -u postgres psql -d template_postgis -c "GRANT ALL ON geometry_columns TO PUBLIC;"
40 sudo -u postgres psql -d template_postgis -c "GRANT ALL ON geography_columns TO PUBLIC;"
41 sudo -u postgres psql -d template_postgis -c "GRANT ALL ON spatial_ref_sys TO PUBLIC;"
43 sudo -u postgres psql -d template_postgis -c "VACUUM FULL;"
44 sudo -u postgres psql -d template_postgis -c "VACUUM FREEZE;"
46 sudo -u postgres psql -d postgres -c "UPDATE pg_database SET datistemplate='true' WHERE datname='template_postgis';"
47 sudo -u postgres psql -d postgres -c "UPDATE pg_database SET datallowconn='false' WHERE datname='template_postgis';"
49 endpoint_exists=`sudo -u postgres psql -l | grep endpoint | wc -l`
50 if [ $template_exists -eq 0 ]
51 then
52 sudo -u postgres createdb endpoint -T template_postgis
53 fi