]> git.openstreetmap.org Git - nominatim.git/commitdiff
Merge pull request #3338 from lonvia/remove-nested-cli-groups
authorSarah Hoffmann <lonvia@denofr.de>
Fri, 16 Feb 2024 18:27:25 +0000 (19:27 +0100)
committerGitHub <noreply@github.com>
Fri, 16 Feb 2024 18:27:25 +0000 (19:27 +0100)
Add documentation for importing without superuser rights

.github/workflows/ci-tests.yml
docs/admin/Advanced-Installations.md
nominatim/clicmd/setup.py

index 42c03edc17d9e76fd20463b6294c25ce1fa730bc..e3d7b4a6a63ca1cf0a3993959244789d38b9183f 100644 (file)
@@ -354,90 +354,43 @@ jobs:
       runs-on: ubuntu-latest
       needs: create-archive
 
-      strategy:
-          matrix:
-              name: [Ubuntu-22]
-              include:
-                  - name: Ubuntu-22
-                    image: "ubuntu:22.04"
-                    ubuntu: 22
-                    install_mode: install-apache
-
-      container:
-          image: ${{ matrix.image }}
-          env:
-              LANG: en_US.UTF-8
-
-      defaults:
-          run:
-              shell: sudo -Hu nominatim bash --noprofile --norc -eo pipefail {0}
-
       steps:
-          - name: Prepare container (Ubuntu)
-            run: |
-                export APT_LISTCHANGES_FRONTEND=none
-                export DEBIAN_FRONTEND=noninteractive
-                apt-get update -qq
-                apt-get install -y git sudo wget
-                ln -snf /usr/share/zoneinfo/$CONTAINER_TIMEZONE /etc/localtime && echo $CONTAINER_TIMEZONE > /etc/timezone
-            shell: bash
-
-          - name: Setup import user
-            run: |
-                useradd -m nominatim
-                echo 'nominatim   ALL=(ALL:ALL) NOPASSWD: ALL' > /etc/sudoers.d/nominiatim
-                echo "/home/nominatim/Nominatim/vagrant/Install-on-${OS}.sh no $INSTALL_MODE" > /home/nominatim/vagrant.sh
-            shell: bash
-            env:
-              OS: ${{ matrix.name }}
-              INSTALL_MODE: ${{ matrix.install_mode }}
-
           - uses: actions/download-artifact@v3
             with:
                 name: full-source
-                path: /home/nominatim
 
-          - name: Install Nominatim
-            run: |
-              export USERNAME=nominatim
-              export USERHOME=/home/nominatim
-              export NOSYSTEMD=yes
-              export HAVE_SELINUX=no
-              tar xf nominatim-src.tar.bz2
-              . vagrant.sh
-            working-directory: /home/nominatim
+          - name: Unpack Nominatim
+            run: tar xf nominatim-src.tar.bz2
+
+          - uses: ./Nominatim/.github/actions/setup-postgresql
+            with:
+                postgresql-version: 16
+                postgis-version: 3
+
+          - uses: ./Nominatim/.github/actions/build-nominatim
+            with:
+                flavour: ubuntu-22
+                lua: 5.3
 
           - name: Prepare import environment
             run: |
                 mv Nominatim/test/testdb/apidb-test-data.pbf test.pbf
-                mv Nominatim/settings/flex-base.lua flex-base.lua
-                mv Nominatim/settings/import-extratags.lua import-extratags.lua
-                mv Nominatim/settings/taginfo.lua taginfo.lua
                 rm -rf Nominatim
-                mkdir data-env-reverse
-            working-directory: /home/nominatim
 
           - name: Prepare Database
             run: |
                 nominatim import --prepare-database
-            working-directory: /home/nominatim/nominatim-project
 
           - name: Create import user
             run: |
-                sudo -u postgres createuser -S osm-import
-                sudo -u postgres psql -c "ALTER USER \"osm-import\" WITH PASSWORD 'osm-import';"
-            working-directory: /home/nominatim/nominatim-project
-
-          - name: Grant import user rights
-            run: |
-                sudo -u postgres psql -c "GRANT INSERT, UPDATE ON ALL TABLES IN SCHEMA public TO \"osm-import\";"
-            working-directory: /home/nominatim/nominatim-project
+                sudo -u postgres createuser osm-import
+                psql -d nominatim -c "ALTER USER \"osm-import\" WITH PASSWORD 'osm-import'"
+                psql -d nominatim -c 'GRANT CREATE ON SCHEMA public TO "osm-import"'
 
           - name: Run import
             run: |
-                NOMINATIM_DATABASE_DSN="pgsql:host=127.0.0.1;dbname=nominatim;user=osm-import;password=osm-import" nominatim import --continue import-from-file --osm-file ../test.pbf
-            working-directory: /home/nominatim/nominatim-project
+                NOMINATIM_DATABASE_DSN="pgsql:host=127.0.0.1;dbname=nominatim;user=osm-import;password=osm-import" nominatim import --continue import-from-file --osm-file test.pbf
 
           - name: Check full import
-            run: nominatim admin --check-database
-            working-directory: /home/nominatim/nominatim-project
\ No newline at end of file
+            run: |
+              nominatim admin --check-database
index 3b98fec39579a5b286542349525bcd1bd63bcc5f..8bca2783e34feb5bd621771e2e083f452f9cc3a3 100644 (file)
@@ -5,6 +5,35 @@ your Nominatim database. It is assumed that you have already successfully
 installed the Nominatim software itself, if not return to the 
 [installation page](Installation.md).
 
+## Importing with a database user without superuser rights
+
+Nominatim usually creates its own PostgreSQL database at the beginning of the
+import process. This makes usage easier for the user but means that the
+database user doing the import needs the appropriate rights.
+
+If you prefer to run the import with a database user with limited rights,
+you can do so by changing the import process as follows:
+
+1. Run the command for database preparation with a database user with
+   superuser rights. For example, to use a db user 'dbadmin' for a
+   database 'nominatim', execute:
+
+   ```
+   NOMINATIM_DATABASE_DSN="pgsql:dbname=nominatim;user=dbadmin" nominatim import --prepare-database
+   ```
+
+2. Grant the import user the right to create tables. For example, foe user 'import-user':
+
+   ```
+   psql -d nominatim -c 'GRANT CREATE ON SCHEMA public TO "import-user"'
+   ```
+
+3. Now run the reminder of the import with the import user:
+
+   ```
+   NOMINATIM_DATABASE_DSN="pgsql:dbname=nominatim;user=import-user" nominatim import --continue import-from-file --osm-file file.pbf
+   ```
+
 ## Importing multiple regions (without updates)
 
 To import multiple regions in your database you can simply give multiple
index 67ca5bb10200aa1d095212898122569009e23d49..38a5a5b520470b0deff8a69365073f1830f93eb0 100644 (file)
@@ -39,8 +39,7 @@ class SetupAll:
     """
 
     def add_args(self, parser: argparse.ArgumentParser) -> None:
-        group_name = parser.add_argument_group('Required arguments')
-        group1 = group_name.add_argument_group()
+        group1 = parser.add_argument_group('Required arguments')
         group1.add_argument('--osm-file', metavar='FILE', action='append',
                            help='OSM file to be imported'
                                 ' (repeat for importing multiple files)',