X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/14aca11dcd4c9778cac78f14c9c51c6bbe00bf96..08e273c0c7ebcbb7f8e4c512c58b22da1bac95b7:/utils/setup.php diff --git a/utils/setup.php b/utils/setup.php old mode 100755 new mode 100644 index 449dd4da..3015f13a --- a/utils/setup.php +++ b/utils/setup.php @@ -1,99 +1,165 @@ -#!@PHP_BIN@ -Cq createDB(); +} -// prepares DB for import or update, returns Data Source Name -$aDSNInfo = prepDB($aCMDResult); +$oSetup->connect(); + +if ($aCMDResult['setup-db'] || $aCMDResult['all']) { + $bDidSomething = true; + $oSetup->setupDB(); +} + +// Try accessing the C module, so we know early if something is wrong +checkModulePresence(); // raises exception on failure 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(); + $oSetup->createTableTriggers(); } 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); + $oSetup->calculatePostcodes($aCMDResult['all']); } -if ($aCMDResult['osmosis-init']) { +if ($aCMDResult['index'] || $aCMDResult['all']) { $bDidSomething = true; - echo "Command 'osmosis-init' no longer available, please use utils/update.php --init-updates.\n"; + $oSetup->index($aCMDResult['index-noanalyse']); } -if ($aCMDResult['index'] || $aCMDResult['all']) { +if ($aCMDResult['drop']) { $bDidSomething = true; - index($aCMDResult, $aDSNInfo, $iInstances); + $oSetup->drop($aCMDResult); } 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); +// ****************************************************** +// 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.'); } - -didSomething($bDidSomething);