X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/4f49ef07e653e91fae3a75976074833905c79aa8..4a3121b52f368a089d69bc4d6da0a8b6acd8603d:/utils/setup.php diff --git a/utils/setup.php b/utils/setup.php index 8cbb2978..ff890af9 100755 --- a/utils/setup.php +++ b/utils/setup.php @@ -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']) @@ -105,6 +105,15 @@ // 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) { @@ -113,7 +122,16 @@ } 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'); @@ -568,6 +586,8 @@ @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');