]> git.openstreetmap.org Git - nominatim.git/blobdiff - utils/setup.php
release in postgis version string is optional
[nominatim.git] / utils / setup.php
index 8cbb29781729d46bdee0d9f5407389ef845453d3..ff890af97e074850403d964b9544ce569151e52c 100755 (executable)
@@ -95,7 +95,7 @@
                {
                        fail('database already exists ('.CONST_Database_DSN.')');
                }
-               passthru('createdb -E UTF-8 '.$aDSNInfo['database']);
+               passthruCheckReturn('createdb -E UTF-8 '.$aDSNInfo['database']);
        }
 
        if ($aCMDResult['setup-db'] || $aCMDResult['all'])
                // TODO: path detection, detection memory, etc.
 
                $oDB =& getDB();
+
+               $sVersionString = $oDB->getOne('select version()');
+               preg_match('#PostgreSQL ([0-9]+)[.]([0-9]+)[.]([0-9]+) #', $sVersionString, $aMatches);
+               if (CONST_Postgresql_Version != $aMatches[1].'.'.$aMatches[2])
+               {
+                       echo "ERROR: PostgreSQL version is not correct.  Expected ".CONST_Postgresql_Version." found ".$aMatches[1].'.'.$aMatches[2]."\n";
+                       exit;
+               }
+
                passthru('createlang plpgsql '.$aDSNInfo['database']);
                $pgver = (float) CONST_Postgresql_Version;
                if ($pgver < 9.1) {
                } else {
                        pgsqlRunScript('CREATE EXTENSION hstore');
                }
+
                pgsqlRunScriptFile(CONST_Path_Postgresql_Postgis.'/postgis.sql');
+               $sVersionString = $oDB->getOne('select postgis_full_version()');
+               preg_match('#POSTGIS="([0-9]+)[.]([0-9]+)[.]([0-9]+)( r([0-9]+))?"#', $sVersionString, $aMatches);
+               if (CONST_Postgis_Version != $aMatches[1].'.'.$aMatches[2])
+               {
+                       echo "ERROR: PostGIS version is not correct.  Expected ".CONST_Postgis_Version." found ".$aMatches[1].'.'.$aMatches[2]."\n";
+                       exit;
+               }
+
                pgsqlRunScriptFile(CONST_Path_Postgresql_Postgis.'/spatial_ref_sys.sql');
                pgsqlRunScriptFile(CONST_BasePath.'/data/country_name.sql');
                pgsqlRunScriptFile(CONST_BasePath.'/data/country_naturalearthdata.sql');
                @symlink(CONST_BasePath.'/website/reverse.php', $sTargetDir.'/reverse.php');
                @symlink(CONST_BasePath.'/website/search.php', $sTargetDir.'/search.php');
                @symlink(CONST_BasePath.'/website/search.php', $sTargetDir.'/index.php');
+               @symlink(CONST_BasePath.'/website/deletable.php', $sTargetDir.'/deletable.php');
+               @symlink(CONST_BasePath.'/website/polygons.php', $sTargetDir.'/polygons.php');
                @symlink(CONST_BasePath.'/website/images', $sTargetDir.'/images');
                @symlink(CONST_BasePath.'/website/js', $sTargetDir.'/js');
                @symlink(CONST_BasePath.'/website/css', $sTargetDir.'/css');