X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/14aca11dcd4c9778cac78f14c9c51c6bbe00bf96..3ff6eccfd7748b8e16b8e498150da76d2754c236:/utils/setup.php diff --git a/utils/setup.php b/utils/setup.php old mode 100755 new mode 100644 index 449dd4da..90df0835 --- 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); -} - -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.'); +}