]> git.openstreetmap.org Git - nominatim.git/blob - utils/setup.php
splitted createTables and changed formatting to please Travis
[nominatim.git] / utils / setup.php
1 #!@PHP_BIN@ -Cq\r
2 <?php\r
3 \r
4 require_once(dirname(dirname(__FILE__)).'/settings/settings.php');\r
5 require_once(CONST_BasePath.'/lib/init-cmd.php');\r
6 include_once(CONST_InstallPath.'/utils/setupClass.php');\r
7 // ->indirect via init-cmd.php -> /lib/cmd.php                  for runWithEnv, getCmdOpt\r
8 // ->indirect via init-cmd.php -> /lib/init.php -> db.php       for &getDB()\r
9 \r
10 include_once(CONST_BasePath.'/lib/setup_functions.php');\r
11 include_once(CONST_BasePath.'/lib/setup_functions.php');\r
12 ini_set('memory_limit', '800M');\r
13 \r
14 \r
15 $aCMDOptions = createSetupArgvArray();\r
16 \r
17 // $aCMDOptions passed to getCmdOpt by reference\r
18 getCmdOpt($_SERVER['argv'], $aCMDOptions, $aCMDResult, true, true);\r
19 \r
20 \r
21 $bDidSomething = false;\r
22 \r
23 //*******************************************************\r
24 // Making some sanity check:\r
25 // Check if osm-file is set and points to a valid file\r
26 if ($aCMDResult['import-data'] || $aCMDResult['all']) {\r
27     // to remain in /lib/setup_functions.php function\r
28     checkInFile($aCMDResult['osm-file']);\r
29     echo $aCMDResult['osm-file'];\r
30 }\r
31 \r
32 // osmosis init is no longer supported\r
33 if ($aCMDResult['osmosis-init']) {\r
34     $bDidSomething = true;\r
35     echo "Command 'osmosis-init' no longer available, please use utils/update.php --init-updates.\n";\r
36 }\r
37 \r
38 // ******************************************************\r
39 // instantiate Setup class\r
40 $cSetup = new SetupFunctions($aCMDResult);\r
41 if ($aCMDResult['create-db'] || $aCMDResult['all']) {\r
42     $bDidSomething = true;\r
43     $cSetup -> createDB();\r
44 }\r
45 \r
46 // *******************************************************\r
47 // go through complete process if 'all' is selected or start selected functions\r
48 if ($aCMDResult['setup-db'] || $aCMDResult['all']) {\r
49     $bDidSomething = true;\r
50     $cSetup -> setupDB();\r
51 }\r
52 \r
53 // Try accessing the C module, so we know early if something is wrong\r
54 if (!checkModulePresence()) {\r
55     fail('error loading nominatim.so module');\r
56 }\r
57 \r
58 if ($aCMDResult['import-data'] || $aCMDResult['all']) {\r
59     $bDidSomething = true;\r
60     $cSetup -> importData($aCMDResult['osm-file']);\r
61 }\r
62  \r
63 if ($aCMDResult['create-functions'] || $aCMDResult['all']) {\r
64     $bDidSomething = true;\r
65     $cSetup -> createFunctions();\r
66 }\r
67 \r
68 if ($aCMDResult['create-tables'] || $aCMDResult['all']) {\r
69     $bDidSomething = true;\r
70     $cSetup -> createTables();\r
71     $cSetup -> recreateFunction();\r
72 }\r
73 \r
74 if ($aCMDResult['create-partition-tables'] || $aCMDResult['all']) {\r
75     $bDidSomething = true;\r
76     $cSetup -> createPartitionTables();\r
77 }\r
78 \r
79 if ($aCMDResult['create-partition-functions'] || $aCMDResult['all']) {\r
80     $bDidSomething = true;\r
81     $cSetup -> createPartitionFunctions();\r
82 }\r
83 \r
84 if ($aCMDResult['import-wikipedia-articles'] || $aCMDResult['all']) {\r
85     $bDidSomething = true;\r
86     $cSetup -> importWikipediaArticles();\r
87 }\r
88 \r
89 if ($aCMDResult['load-data'] || $aCMDResult['all']) {\r
90     $bDidSomething = true;\r
91     $cSetup -> loadData($aCMDResult['disable-token-precalc']);\r
92 }\r
93     \r
94 if ($aCMDResult['import-tiger-data']) {\r
95     $bDidSomething = true;\r
96     $cSetup -> importTigerData();\r
97 }\r
98 \r
99 if ($aCMDResult['calculate-postcodes'] || $aCMDResult['all']) {\r
100     $bDidSomething = true;\r
101     $cSetup -> calculatePostcodes($aCMDResult['all']);\r
102 }\r
103 \r
104 if ($aCMDResult['index'] || $aCMDResult['all']) {\r
105     $bDidSomething = true;\r
106     $cSetup -> index($aCMDResult['index-noanalyse']);\r
107 }\r
108 \r
109 if ($aCMDResult['create-search-indices'] || $aCMDResult['all']) {\r
110     $bDidSomething = true;\r
111     $cSetup -> createSearchIndices();\r
112 }\r
113 \r
114 if ($aCMDResult['create-country-names'] || $aCMDResult['all']) {\r
115     $bDidSomething = true;\r
116     $cSetup -> createCountryNames($aCMDResult);\r
117 }\r
118 \r
119 if ($aCMDResult['drop']) {\r
120     $bDidSomething = true;\r
121     $cSetup -> drop($aCMDResult);\r
122 }\r
123 \r
124 // ******************************************************\r
125 // If we did something, repeat the warnings\r
126 if (!$bDidSomething) {\r
127     showUsage($aCMDOptions, true);\r
128 } else {\r
129     echo "Summary of warnings:\n\n";\r
130     repeatWarnings();\r
131     echo "\n";\r
132     info('Setup finished.');\r
133 }\r