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
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
15 $aCMDOptions = createSetupArgvArray();
\r
17 // $aCMDOptions passed to getCmdOpt by reference
\r
18 getCmdOpt($_SERVER['argv'], $aCMDOptions, $aCMDResult, true, true);
\r
21 $bDidSomething = false;
\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
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
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
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
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
58 if ($aCMDResult['import-data'] || $aCMDResult['all']) {
\r
59 $bDidSomething = true;
\r
60 $cSetup -> importData($aCMDResult['osm-file']);
\r
63 if ($aCMDResult['create-functions'] || $aCMDResult['all']) {
\r
64 $bDidSomething = true;
\r
65 $cSetup -> createFunctions();
\r
68 if ($aCMDResult['create-tables'] || $aCMDResult['all']) {
\r
69 $bDidSomething = true;
\r
70 $cSetup -> createTables();
\r
71 $cSetup -> recreateFunction();
\r
74 if ($aCMDResult['create-partition-tables'] || $aCMDResult['all']) {
\r
75 $bDidSomething = true;
\r
76 $cSetup -> createPartitionTables();
\r
79 if ($aCMDResult['create-partition-functions'] || $aCMDResult['all']) {
\r
80 $bDidSomething = true;
\r
81 $cSetup -> createPartitionFunctions();
\r
84 if ($aCMDResult['import-wikipedia-articles'] || $aCMDResult['all']) {
\r
85 $bDidSomething = true;
\r
86 $cSetup -> importWikipediaArticles();
\r
89 if ($aCMDResult['load-data'] || $aCMDResult['all']) {
\r
90 $bDidSomething = true;
\r
91 $cSetup -> loadData($aCMDResult['disable-token-precalc']);
\r
94 if ($aCMDResult['import-tiger-data']) {
\r
95 $bDidSomething = true;
\r
96 $cSetup -> importTigerData();
\r
99 if ($aCMDResult['calculate-postcodes'] || $aCMDResult['all']) {
\r
100 $bDidSomething = true;
\r
101 $cSetup -> calculatePostcodes($aCMDResult['all']);
\r
104 if ($aCMDResult['index'] || $aCMDResult['all']) {
\r
105 $bDidSomething = true;
\r
106 $cSetup -> index($aCMDResult['index-noanalyse']);
\r
109 if ($aCMDResult['create-search-indices'] || $aCMDResult['all']) {
\r
110 $bDidSomething = true;
\r
111 $cSetup -> createSearchIndices();
\r
114 if ($aCMDResult['create-country-names'] || $aCMDResult['all']) {
\r
115 $bDidSomething = true;
\r
116 $cSetup -> createCountryNames($aCMDResult);
\r
119 if ($aCMDResult['drop']) {
\r
120 $bDidSomething = true;
\r
121 $cSetup -> drop($aCMDResult);
\r
124 // ******************************************************
\r
125 // If we did something, repeat the warnings
\r
126 if (!$bDidSomething) {
\r
127 showUsage($aCMDOptions, true);
\r
129 echo "Summary of warnings:\n\n";
\r
132 info('Setup finished.');
\r