4 require_once dirname(dirname(__FILE__)) . '/settings/settings.php';
5 require_once CONST_BasePath . '/lib/init-cmd.php';
6 require_once CONST_BasePath . '/lib/SetupClass.php';
7 // ->indirect via init-cmd.php->/lib/cmd.php for runWithEnv, getCmdOpt
8 // ->indirect via init-cmd.php->/lib/init.php->db.php for &getDB()
10 require_once CONST_BasePath . '/lib/setup_functions.php';
11 ini_set('memory_limit', '800M');
13 use Nominatim\Setup\SetupFunctions as SetupFunctions;
15 $aCMDOptions = createSetupArgvArray();
17 // $aCMDOptions passed to getCmdOpt by reference
18 getCmdOpt($_SERVER['argv'], $aCMDOptions, $aCMDResult, true, true);
20 $bDidSomething = false;
22 //*******************************************************
23 // Making some sanity check:
24 // Check if osm-file is set and points to a valid file
25 if ($aCMDResult['import-data'] || $aCMDResult['all']) {
26 // to remain in /lib/setup_functions.php function
27 checkInFile($aCMDResult['osm-file']);
28 echo $aCMDResult['osm-file'];
31 // osmosis init is no longer supported
32 if ($aCMDResult['osmosis-init']) {
33 $bDidSomething = true;
34 echo "Command 'osmosis-init' no longer available, please use utils/update.php --init-updates.\n";
37 // ******************************************************
38 // instantiate Setup class
39 $cSetup = new SetupFunctions($aCMDResult);
41 // *******************************************************
42 // go through complete process if 'all' is selected or start selected functions
43 if ($aCMDResult['create-db'] || $aCMDResult['all']) {
44 $bDidSomething = true;
48 if ($aCMDResult['setup-db'] || $aCMDResult['all']) {
49 $bDidSomething = true;
53 // Try accessing the C module, so we know early if something is wrong
54 if (!checkModulePresence()) {
55 fail('error loading nominatim.so module');
58 if ($aCMDResult['import-data'] || $aCMDResult['all']) {
59 $bDidSomething = true;
60 $cSetup->importData($aCMDResult['osm-file']);
63 if ($aCMDResult['create-functions'] || $aCMDResult['all']) {
64 $bDidSomething = true;
65 $cSetup->createFunctions();
68 if ($aCMDResult['create-tables'] || $aCMDResult['all']) {
69 $bDidSomething = true;
70 $cSetup->createTables();
71 $cSetup->createFunctions();
74 if ($aCMDResult['create-partition-tables'] || $aCMDResult['all']) {
75 $bDidSomething = true;
76 $cSetup->createPartitionTables();
79 if ($aCMDResult['create-partition-functions'] || $aCMDResult['all']) {
80 $bDidSomething = true;
81 $cSetup->createPartitionFunctions();
84 if ($aCMDResult['import-wikipedia-articles'] || $aCMDResult['all']) {
85 $bDidSomething = true;
86 $cSetup->importWikipediaArticles();
89 if ($aCMDResult['load-data'] || $aCMDResult['all']) {
90 $bDidSomething = true;
91 $cSetup->loadData($aCMDResult['disable-token-precalc']);
94 if ($aCMDResult['import-tiger-data']) {
95 $bDidSomething = true;
96 $cSetup->importTigerData();
99 if ($aCMDResult['calculate-postcodes'] || $aCMDResult['all']) {
100 $bDidSomething = true;
101 $cSetup->calculatePostcodes($aCMDResult['all']);
104 if ($aCMDResult['index'] || $aCMDResult['all']) {
105 $bDidSomething = true;
106 $cSetup->index($aCMDResult['index-noanalyse']);
109 if ($aCMDResult['create-search-indices'] || $aCMDResult['all']) {
110 $bDidSomething = true;
111 $cSetup->createSearchIndices();
114 if ($aCMDResult['create-country-names'] || $aCMDResult['all']) {
115 $bDidSomething = true;
116 $cSetup->createCountryNames($aCMDResult);
119 if ($aCMDResult['drop']) {
120 $bDidSomething = true;
121 $cSetup->drop($aCMDResult);
124 // ******************************************************
125 // If we did something, repeat the warnings
126 if (!$bDidSomething) {
127 showUsage($aCMDOptions, true);
129 echo "Summary of warnings:\n\n";
132 info('Setup finished.');