]> git.openstreetmap.org Git - nominatim.git/blob - utils/setup.php
first draft of setupClass
[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 }\r
72 \r
73 if ($aCMDResult['create-partition-tables'] || $aCMDResult['all']) {\r
74     $bDidSomething = true;\r
75     $cSetup -> createPartitionTables();\r
76 }\r
77 \r
78 if ($aCMDResult['create-partition-functions'] || $aCMDResult['all']) {\r
79     $bDidSomething = true;\r
80     $cSetup -> createPartitionFunctions();\r
81 }\r
82 /*\r
83 if ($aCMDResult['import-wikipedia-articles'] || $aCMDResult['all']) {\r
84     $bDidSomething = true;\r
85     $cSetup -> importWikipediaArticles();\r
86 }\r
87 */\r
88 if ($aCMDResult['load-data'] || $aCMDResult['all']) {\r
89     $bDidSomething = true;\r
90     $cSetup -> loadData($aCMDResult['disable-token-precalc']);\r
91 }\r
92     \r
93 if ($aCMDResult['import-tiger-data']) {\r
94     $bDidSomething = true;\r
95     $cSetup -> importTigerData();\r
96 }\r
97 \r
98 if ($aCMDResult['calculate-postcodes'] || $aCMDResult['all']) {\r
99     $bDidSomething = true;\r
100     $cSetup -> calculatePostcodes($aCMDResult['all']);\r
101 }\r
102 \r
103 if ($aCMDResult['index'] || $aCMDResult['all']) {\r
104     $bDidSomething = true;\r
105     $cSetup -> index($aCMDResult['index-noanalyse']);\r
106 }\r
107 \r
108 if ($aCMDResult['create-search-indices'] || $aCMDResult['all']) {\r
109     $bDidSomething = true;\r
110     $cSetup -> createSearchIndices();\r
111 }\r
112 \r
113 if ($aCMDResult['create-country-names'] || $aCMDResult['all']) {\r
114     $bDidSomething = true;\r
115     $cSetup -> createCountryNames($aCMDResult);\r
116 }\r
117 \r
118 if ($aCMDResult['drop']) {\r
119     $bDidSomething = true;\r
120     $cSetup -> drop($aCMDResult);\r
121 }\r
122 \r
123 // ******************************************************\r
124 // If we did something, repeat the warnings\r
125 if (!$bDidSomething) {\r
126     showUsage($aCMDOptions, true);\r
127 } else {\r
128     echo "Summary of warnings:\n\n";\r
129     repeatWarnings();\r
130     echo "\n";\r
131     info('Setup finished.');\r
132 }\r
133 \r
134 \r
135 \r