]> git.openstreetmap.org Git - nominatim.git/blobdiff - lib-php/setup/SetupClass.php
port setup-website to python
[nominatim.git] / lib-php / setup / SetupClass.php
index 03b0163153ac2ed3775097432663d0e902c65278..a423e12c1431014a81bb6e97e24bede5ea808e76 100755 (executable)
@@ -166,11 +166,6 @@ class SetupFunctions
         // Try accessing the C module, so we know early if something is wrong
         $this->checkModulePresence(); // raises exception on failure
 
-        if (!file_exists(CONST_DataDir.'/country_osm_grid.sql.gz')) {
-            echo 'Error: you need to download the country_osm_grid first:';
-            echo "\n    wget -O ".CONST_DataDir."/country_osm_grid.sql.gz https://www.nominatim.org/data/country_grid.sql.gz\n";
-            exit(1);
-        }
         $this->pgsqlRunScriptFile(CONST_DataDir.'/country_name.sql');
         $this->pgsqlRunScriptFile(CONST_DataDir.'/country_osm_grid.sql.gz');
 
@@ -662,50 +657,7 @@ class SetupFunctions
 
     public function drop()
     {
-        info('Drop tables only required for updates');
-
-        // The implementation is potentially a bit dangerous because it uses
-        // a positive selection of tables to keep, and deletes everything else.
-        // Including any tables that the unsuspecting user might have manually
-        // created. USE AT YOUR OWN PERIL.
-        // tables we want to keep. everything else goes.
-        $aKeepTables = array(
-                        '*columns',
-                        'import_polygon_*',
-                        'import_status',
-                        'place_addressline',
-                        'location_postcode',
-                        'location_property*',
-                        'placex',
-                        'search_name',
-                        'seq_*',
-                        'word',
-                        'query_log',
-                        'new_query_log',
-                        'spatial_ref_sys',
-                        'country_name',
-                        'place_classtype_*',
-                        'country_osm_grid'
-                       );
-
-        $aDropTables = array();
-        $aHaveTables = $this->db()->getListOfTables();
-
-        foreach ($aHaveTables as $sTable) {
-            $bFound = false;
-            foreach ($aKeepTables as $sKeep) {
-                if (fnmatch($sKeep, $sTable)) {
-                    $bFound = true;
-                    break;
-                }
-            }
-            if (!$bFound) array_push($aDropTables, $sTable);
-        }
-        foreach ($aDropTables as $sDrop) {
-            $this->dropTable($sDrop);
-        }
-
-        $this->removeFlatnodeFile();
+        (clone($this->oNominatimCmd))->addParams('freeze')->run();
     }
 
     /**
@@ -715,48 +667,7 @@ class SetupFunctions
      */
     public function setupWebsite()
     {
-        if (!is_dir(CONST_InstallDir.'/website')) {
-            info('Creating directory for website scripts at: '.CONST_InstallDir.'/website');
-            mkdir(CONST_InstallDir.'/website');
-        }
-
-        $aScripts = array(
-          'deletable.php',
-          'details.php',
-          'lookup.php',
-          'polygons.php',
-          'reverse.php',
-          'search.php',
-          'status.php'
-        );
-
-        foreach ($aScripts as $sScript) {
-            $rFile = fopen(CONST_InstallDir.'/website/'.$sScript, 'w');
-
-            fwrite($rFile, "<?php\n\n");
-            fwrite($rFile, '@define(\'CONST_Debug\', $_GET[\'debug\'] ?? false);'."\n\n");
-
-            fwriteConstDef($rFile, 'LibDir', CONST_LibDir);
-            fwriteConstDef($rFile, 'Database_DSN', getSetting('DATABASE_DSN'));
-            fwriteConstDef($rFile, 'Default_Language', getSetting('DEFAULT_LANGUAGE'));
-            fwriteConstDef($rFile, 'Log_DB', getSettingBool('LOG_DB'));
-            fwriteConstDef($rFile, 'Log_File', getSetting('LOG_FILE'));
-            fwriteConstDef($rFile, 'Max_Word_Frequency', (int)getSetting('MAX_WORD_FREQUENCY'));
-            fwriteConstDef($rFile, 'NoAccessControl', getSettingBool('CORS_NOACCESSCONTROL'));
-            fwriteConstDef($rFile, 'Places_Max_ID_count', (int)getSetting('LOOKUP_MAX_COUNT'));
-            fwriteConstDef($rFile, 'PolygonOutput_MaximumTypes', getSetting('POLYGON_OUTPUT_MAX_TYPES'));
-            fwriteConstDef($rFile, 'Search_BatchMode', getSettingBool('SEARCH_BATCH_MODE'));
-            fwriteConstDef($rFile, 'Search_NameOnlySearchFrequencyThreshold', getSetting('SEARCH_NAME_ONLY_THRESHOLD'));
-            fwriteConstDef($rFile, 'Term_Normalization_Rules', getSetting('TERM_NORMALIZATION'));
-            fwriteConstDef($rFile, 'Use_Aux_Location_data', getSettingBool('USE_AUX_LOCATION_DATA'));
-            fwriteConstDef($rFile, 'Use_US_Tiger_Data', getSettingBool('USE_US_TIGER_DATA'));
-            fwriteConstDef($rFile, 'MapIcon_URL', getSetting('MAPICON_URL'));
-
-            fwrite($rFile, 'require_once(\''.CONST_LibDir.'/website/'.$sScript."');\n");
-            fclose($rFile);
-
-            chmod(CONST_InstallDir.'/website/'.$sScript, 0755);
-        }
+        (clone($this->oNominatimCmd))->addParams('refresh', '--website')->run();
     }
 
     /**