Skip to content

Commit

Permalink
Merge pull request #308 from mausch/env-vars
Browse files Browse the repository at this point in the history
#245 Pass environment variables to all sudo commands
  • Loading branch information
leonardehrenfried authored Mar 17, 2022
2 parents 1b7c9f5 + 3dc4d66 commit 2a43ad7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
18 changes: 9 additions & 9 deletions 4.0/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ if [ ! -f /var/lib/postgresql/12/main/PG_VERSION ]; then
fi

sudo service postgresql start && \
sudo -u postgres psql postgres -tAc "SELECT 1 FROM pg_roles WHERE rolname='nominatim'" | grep -q 1 || sudo -u postgres createuser -s nominatim && \
sudo -u postgres psql postgres -tAc "SELECT 1 FROM pg_roles WHERE rolname='www-data'" | grep -q 1 || sudo -u postgres createuser -SDR www-data && \
sudo -E -u postgres psql postgres -tAc "SELECT 1 FROM pg_roles WHERE rolname='nominatim'" | grep -q 1 || sudo -E -u postgres createuser -s nominatim && \
sudo -E -u postgres psql postgres -tAc "SELECT 1 FROM pg_roles WHERE rolname='www-data'" | grep -q 1 || sudo -E -u postgres createuser -SDR www-data && \

sudo -u postgres psql postgres -tAc "ALTER USER nominatim WITH ENCRYPTED PASSWORD '$NOMINATIM_PASSWORD'" && \
sudo -u postgres psql postgres -tAc "ALTER USER \"www-data\" WITH ENCRYPTED PASSWORD '${NOMINATIM_PASSWORD}'" && \
sudo -E -u postgres psql postgres -tAc "ALTER USER nominatim WITH ENCRYPTED PASSWORD '$NOMINATIM_PASSWORD'" && \
sudo -E -u postgres psql postgres -tAc "ALTER USER \"www-data\" WITH ENCRYPTED PASSWORD '${NOMINATIM_PASSWORD}'" && \

sudo -u postgres psql postgres -c "DROP DATABASE IF EXISTS nominatim"
sudo -E -u postgres psql postgres -c "DROP DATABASE IF EXISTS nominatim"

chown -R nominatim:nominatim ${PROJECT_DIR}

Expand All @@ -72,10 +72,10 @@ sudo -E -u nominatim nominatim import --osm-file $OSMFILE --threads $THREADS

if [ -f tiger-nominatim-preprocessed.csv.tar.gz ]; then
echo "Importing Tiger address data"
sudo -u nominatim nominatim add-data --tiger-data tiger-nominatim-preprocessed.csv.tar.gz
sudo -E -u nominatim nominatim add-data --tiger-data tiger-nominatim-preprocessed.csv.tar.gz
fi

sudo -u nominatim nominatim admin --check-database
sudo -E -u nominatim nominatim admin --check-database

if [ "$REPLICATION_URL" != "" ]; then
sudo -E -u nominatim nominatim replication --init
Expand All @@ -85,14 +85,14 @@ if [ "$REPLICATION_URL" != "" ]; then
else
if [ "$FREEZE" = "true" ]; then
echo "Freezing database"
sudo -u nominatim nominatim freeze
sudo -E -u nominatim nominatim freeze
fi
fi

# gather statistics for query planner to potentially improve query performance
# see, https://github.com/osm-search/Nominatim/issues/1023
# and https://github.com/osm-search/Nominatim/issues/1139
sudo -u nominatim psql -d nominatim -c "ANALYZE VERBOSE"
sudo -E -u nominatim psql -d nominatim -c "ANALYZE VERBOSE"

sudo service postgresql stop

Expand Down
2 changes: 1 addition & 1 deletion 4.0/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ fi

service postgresql start

cd ${PROJECT_DIR} && sudo -u nominatim nominatim refresh --website --functions
cd ${PROJECT_DIR} && sudo -E -u nominatim nominatim refresh --website --functions

service apache2 start

Expand Down

0 comments on commit 2a43ad7

Please sign in to comment.