4 require_once(dirname(dirname(__FILE__)).'/settings/settings.php');
5 require_once(CONST_BasePath.'/lib/init-cmd.php');
6 require_once(CONST_BasePath.'/lib/classes/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()
9 require_once(CONST_BasePath.'/lib/setup_functions.php');
10 ini_set('memory_limit', '800M');
12 use Nominatim\Setup\SetupFunctions as SetupFunctions;
14 $aCMDOptions = createSetupArgvArray();
16 // $aCMDOptions passed to getCmdOpt by reference
17 getCmdOpt($_SERVER['argv'], $aCMDOptions, $aCMDResult, true, true);
19 $bDidSomething = false;
21 //*******************************************************
22 // Making some sanity check:
23 // Check if osm-file is set and points to a valid file
24 if ($aCMDResult['import-data'] || $aCMDResult['all']) {
25 // to remain in /lib/setup_functions.php function
26 checkInFile($aCMDResult['osm-file']);
29 // osmosis init is no longer supported
30 if ($aCMDResult['osmosis-init']) {
31 $bDidSomething = true;
32 echo "Command 'osmosis-init' no longer available, please use utils/update.php --init-updates.\n";
35 // ******************************************************
36 // instantiate Setup class
37 $cSetup = new SetupFunctions($aCMDResult);
39 // *******************************************************
40 // go through complete process if 'all' is selected or start selected functions
41 if ($aCMDResult['create-db'] || $aCMDResult['all']) {
42 $bDidSomething = true;
46 if ($aCMDResult['setup-db'] || $aCMDResult['all']) {
47 $bDidSomething = true;
51 // Try accessing the C module, so we know early if something is wrong
52 if (!checkModulePresence()) {
53 fail('error loading nominatim.so module');
56 if ($aCMDResult['import-data'] || $aCMDResult['all']) {
57 $bDidSomething = true;
58 $cSetup->importData($aCMDResult['osm-file']);
61 if ($aCMDResult['create-functions'] || $aCMDResult['all']) {
62 $bDidSomething = true;
63 $cSetup->createFunctions();
66 if ($aCMDResult['create-tables'] || $aCMDResult['all']) {
67 $bDidSomething = true;
68 $cSetup->createTables();
69 $cSetup->createFunctions();
72 if ($aCMDResult['create-partition-tables'] || $aCMDResult['all']) {
73 $bDidSomething = true;
74 $cSetup->createPartitionTables();
77 if ($aCMDResult['create-partition-functions'] || $aCMDResult['all']) {
78 $bDidSomething = true;
79 $cSetup->createPartitionFunctions();
82 if ($aCMDResult['import-wikipedia-articles'] || $aCMDResult['all']) {
83 $bDidSomething = true;
84 $cSetup->importWikipediaArticles();
87 if ($aCMDResult['load-data'] || $aCMDResult['all']) {
88 $bDidSomething = true;
89 $cSetup->loadData($aCMDResult['disable-token-precalc']);
92 if ($aCMDResult['import-tiger-data']) {
93 $bDidSomething = true;
94 $cSetup->importTigerData();
97 if ($aCMDResult['calculate-postcodes'] || $aCMDResult['all']) {
98 $bDidSomething = true;
99 $cSetup->calculatePostcodes($aCMDResult['all']);
102 if ($aCMDResult['index'] || $aCMDResult['all']) {
103 $bDidSomething = true;
104 $cSetup->index($aCMDResult['index-noanalyse']);
107 if ($aCMDResult['create-search-indices'] || $aCMDResult['all']) {
108 $bDidSomething = true;
109 $cSetup->createSearchIndices();
112 if ($aCMDResult['create-country-names'] || $aCMDResult['all']) {
113 $bDidSomething = true;
114 $cSetup->createCountryNames($aCMDResult);
117 if ($aCMDResult['drop']) {
118 $bDidSomething = true;
119 $cSetup->drop($aCMDResult);
122 // ******************************************************
123 // If we did something, repeat the warnings
124 if (!$bDidSomething) {
125 showUsage($aCMDOptions, true);
127 echo "Summary of warnings:\n\n";
130 info('Setup finished.');