From 10d4792540b1d17cab9d80764aaf1d379c564944 Mon Sep 17 00:00:00 2001 From: Mark Longair Date: Tue, 6 Jan 2015 17:11:56 +0000 Subject: [PATCH] install-site.sh: On Ubuntu trusty don't create template_postgis On Ubuntu 14.04 (Trusty Tahr) the script for creating template_postgis doesn't work, and PostGIS support should be added via CREATE EXTENSION instead. Any project that uses install_postgis and has been updated to use this version of commonlib should be updated; for example the corresponding changes for MapIt are here: https://github.com/mysociety/mapit/pull/156 Also fix the version of the Django script used to one that still supports Debian squeeze. --- bin/install-site.sh | 50 +++++++++++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 20 deletions(-) diff --git a/bin/install-site.sh b/bin/install-site.sh index c365ffb6..4ab86b4f 100755 --- a/bin/install-site.sh +++ b/bin/install-site.sh @@ -393,26 +393,36 @@ install_nginx() { } install_postgis() { - echo -n "Installing PostGIS... " - POSTGIS_SCRIPT='https://docs.djangoproject.com/en/dev/_downloads/create_template_postgis-debian.sh' - su -l -c "curl '$POSTGIS_SCRIPT' | bash -s" postgres - # According to Matthew's installation instructions, these two SRID - # may be missing the appropriate +datum from the proj4text column, - # depending on what PostGIS version is being used. Check whether - # they are missing, and if so, update the column. - for T in 27700:+datum=OSGB36 29902:+datum=ire65 - do - SRID="${T%%:*}" - DATUM="${T##*:}" - EXISTING="$(echo "select proj4text from spatial_ref_sys where srid = '$SRID'" | su -l -c "psql -t -P 'format=unaligned' template_postgis" postgres)" - if ! echo "$EXISTING" | grep -- "$DATUM" - then - echo Adding $DATUM to the proj4text column of spatial_ref_sys for srid $SRID - NEW_VALUE="${EXISTING% } $DATUM " - echo "UPDATE spatial_ref_sys SET proj4text = '$NEW_VALUE' WHERE srid = '$SRID'" | su -l -c 'psql template_postgis' postgres - fi - done - echo $DONE_MSG + if [ x"$DISTRIBUTION" = x"ubuntu" ] && [ x"$DISTVERSION" = x"trusty" ] + then + # On trusty, we have Postgresql >= 9.1 (9.3) *and* PostGIS >= 2.0 + # and so PostGIS support should be installed with "CREATE EXTENSION + # postgis; CREATE EXTENSION postgis_topology;" instead. (So this + # condition would arguably be better written as a condition on + # those two versions.) + echo "PostGIS support should already be available." + else + echo -n "Installing PostGIS... " + POSTGIS_SCRIPT='https://docs.djangoproject.com/en/1.7/_downloads/create_template_postgis-debian.sh' + su -l -c "curl '$POSTGIS_SCRIPT' | bash -s" postgres + # According to Matthew's installation instructions, these two SRID + # may be missing the appropriate +datum from the proj4text column, + # depending on what PostGIS version is being used. Check whether + # they are missing, and if so, update the column. + for T in 27700:+datum=OSGB36 29902:+datum=ire65 + do + SRID="${T%%:*}" + DATUM="${T##*:}" + EXISTING="$(echo "select proj4text from spatial_ref_sys where srid = '$SRID'" | su -l -c "psql -t -P 'format=unaligned' template_postgis" postgres)" + if ! echo "$EXISTING" | grep -- "$DATUM" + then + echo Adding $DATUM to the proj4text column of spatial_ref_sys for srid $SRID + NEW_VALUE="${EXISTING% } $DATUM " + echo "UPDATE spatial_ref_sys SET proj4text = '$NEW_VALUE' WHERE srid = '$SRID'" | su -l -c 'psql template_postgis' postgres + fi + done + echo $DONE_MSG + fi } make_log_directory() {