Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

#245 Pass environment variables to all sudo commands #308

Merged
merged 1 commit into from
Mar 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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