1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
|
#/bin/sh
# don't launch directly this script
# use 'make install-demo' to do so
set -e
PGBIN=@POSTGIS_BIN@
PGSHARE=@POSTGIS_SHARE@/contrib/postgis-1.5
PGUSER=postgres
SHP2PGSQL=@SHP2PGSQL@
DB=tinyows_demo
if [ -d /usr/local/pgsql/share/contrib/postgis-3.5 ]; then
PGSHARE=/usr/local/pgsql/share/contrib/postgis-3.5
elif [ -d /usr/local/pgsql/share/contrib/postgis-3.4 ]; then
PGSHARE=/usr/local/pgsql/share/contrib/postgis-3.4
elif [ -d /usr/local/pgsql/share/contrib/postgis-3.3 ]; then
PGSHARE=/usr/local/pgsql/share/contrib/postgis-3.3
elif [ -d /usr/local/pgsql/share/contrib/postgis-3.2 ]; then
PGSHARE=/usr/local/pgsql/share/contrib/postgis-3.2
elif [ -d /usr/local/pgsql/share/contrib/postgis-3.1 ]; then
PGSHARE=/usr/local/pgsql/share/contrib/postgis-3.1
elif [ -d @POSTGIS_SHARE@/contrib/postgis-3.0 ]; then
PGSHARE=@POSTGIS_SHARE@/contrib/postgis-3.0
elif [ -d @POSTGIS_SHARE@/contrib/postgis-2.5 ]; then
PGSHARE=@POSTGIS_SHARE@/contrib/postgis-2.5
elif [ -d @POSTGIS_SHARE@/contrib/postgis-2.4 ]; then
PGSHARE=@POSTGIS_SHARE@/contrib/postgis-2.4
elif [ -d @POSTGIS_SHARE@/contrib/postgis-2.3 ]; then
PGSHARE=@POSTGIS_SHARE@/contrib/postgis-2.3
elif [ -d @POSTGIS_SHARE@/contrib/postgis-2.2 ]; then
PGSHARE=@POSTGIS_SHARE@/contrib/postgis-2.2
elif [ -d @POSTGIS_SHARE@/contrib/postgis-2.1 ]; then
PGSHARE=@POSTGIS_SHARE@/contrib/postgis-2.1
elif [ -d @POSTGIS_SHARE@/contrib/postgis-2.0 ]; then
PGSHARE=@POSTGIS_SHARE@/contrib/postgis-2.0
elif [ -d @POSTGIS_SHARE@/contrib/postgis-1.5 ]; then
PGSHARE=@POSTGIS_SHARE@/contrib/postgis-1.5
else
echo "Unable to find PostGIS dir in @POSTGIS_SHARE@/contrib/" && exit 1
fi
echo "Create Spatial Database: $DB"
su $PGUSER -c "$PGBIN/dropdb $DB > /dev/null 2> /dev/null || /bin/true"
su $PGUSER -c "$PGBIN/createdb $DB"
if test -f "$PGBIN/createlang"; then
su $PGUSER -c "$PGBIN/createlang plpgsql $DB"
fi
su $PGUSER -c "$PGBIN/psql $DB < $PGSHARE/postgis.sql"
su $PGUSER -c "$PGBIN/psql $DB < $PGSHARE/spatial_ref_sys.sql"
echo "Import layer data: world"
$SHP2PGSQL -s 4326 -I demo/world.shp world > _world.sql
su $PGUSER -c "$PGBIN/psql $DB < _world.sql"
echo "Import layer data: france_dept"
$SHP2PGSQL -s 27582 -I -W latin1 demo/france.shp france > _france.sql
su $PGUSER -c "$PGBIN/psql $DB < _france.sql"
echo "Import non spatial layer"
echo "CREATE TABLE geometry_less(id SERIAL PRIMARY KEY, intcol INTEGER, textcol TEXT);" > _geometry_less.sql
echo "INSERT INTO geometry_less (intcol, textcol) VALUES (123, 'foo');" >> _geometry_less.sql
su $PGUSER -c "$PGBIN/psql $DB < _geometry_less.sql"
rm _world.sql _france.sql _geometry_less.sql
|