X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/14aca11dcd4c9778cac78f14c9c51c6bbe00bf96..69f30e8e193b5be4b7fc6b504641e6d17fe1827b:/utils/setup.php?ds=sidebyside diff --git a/utils/setup.php b/utils/setup.php old mode 100755 new mode 100644 index 449dd4da..66b71920 --- a/utils/setup.php +++ b/utils/setup.php @@ -1,99 +1,166 @@ -#!@PHP_BIN@ -Cq createDB(); +} + +$oSetup->connect(); -// get info how many processors and huch much cache mem we can use -$prepSreturn = prepSystem($aCMDResult); -$iCacheMemory = $prepSreturn[0]; -$iInstances = $prepSreturn[1]; +if ($aCMDResult['setup-db'] || $aCMDResult['all']) { + $bDidSomething = true; + $oSetup->setupDB(); +} -// prepares DB for import or update, returns Data Source Name -$aDSNInfo = prepDB($aCMDResult); +// Try accessing the C module, so we know early if something is wrong +if (!checkModulePresence()) { + fail('error loading nominatim.so module'); +} if ($aCMDResult['import-data'] || $aCMDResult['all']) { $bDidSomething = true; - importData($aCMDResult, $iCacheMemory, $aDSNInfo); + $oSetup->importData($aCMDResult['osm-file']); } if ($aCMDResult['create-functions'] || $aCMDResult['all']) { $bDidSomething = true; - createFunctions($aCMDResult); + $oSetup->createFunctions(); } if ($aCMDResult['create-tables'] || $aCMDResult['all']) { $bDidSomething = true; - createTables($aCMDResult); + $oSetup->createTables($aCMDResult['reverse-only']); + $oSetup->createFunctions(); } if ($aCMDResult['create-partition-tables'] || $aCMDResult['all']) { $bDidSomething = true; - createPartitionTables($aCMDResult); + $oSetup->createPartitionTables(); } if ($aCMDResult['create-partition-functions'] || $aCMDResult['all']) { $bDidSomething = true; - createPartitionFunctions($aCMDResult); + $oSetup->createPartitionFunctions(); } if ($aCMDResult['import-wikipedia-articles'] || $aCMDResult['all']) { $bDidSomething = true; - importWikipediaArticles(); + $oSetup->importWikipediaArticles(); } - if ($aCMDResult['load-data'] || $aCMDResult['all']) { $bDidSomething = true; - loadData($aCMDResult, $iInstances); + $oSetup->loadData($aCMDResult['disable-token-precalc']); } if ($aCMDResult['import-tiger-data']) { $bDidSomething = true; - importTigerData($aCMDResult, $iInstances); + $oSetup->importTigerData(); } if ($aCMDResult['calculate-postcodes'] || $aCMDResult['all']) { $bDidSomething = true; - calculatePostcodes($aCMDResult); -} - -if ($aCMDResult['osmosis-init']) { - $bDidSomething = true; - echo "Command 'osmosis-init' no longer available, please use utils/update.php --init-updates.\n"; + $oSetup->calculatePostcodes($aCMDResult['all']); } if ($aCMDResult['index'] || $aCMDResult['all']) { $bDidSomething = true; - index($aCMDResult, $aDSNInfo, $iInstances); + $oSetup->index($aCMDResult['index-noanalyse']); } if ($aCMDResult['create-search-indices'] || $aCMDResult['all']) { $bDidSomething = true; - createSearchIndices($aCMDResult); + $oSetup->createSearchIndices(); } if ($aCMDResult['create-country-names'] || $aCMDResult['all']) { $bDidSomething = true; - createCountryNames($aCMDResult); + $oSetup->createCountryNames($aCMDResult); } if ($aCMDResult['drop']) { $bDidSomething = true; - drop($aCMDResult); + $oSetup->drop($aCMDResult); } -didSomething($bDidSomething); +// ****************************************************** +// If we did something, repeat the warnings +if (!$bDidSomething) { + showUsage($aCMDOptions, true); +} else { + echo "Summary of warnings:\n\n"; + repeatWarnings(); + echo "\n"; + info('Setup finished.'); +}