Update run.sh

Work in progress
This commit is contained in:
Olivier DEBAUCHE 2021-06-12 14:56:11 +02:00 committed by GitHub
parent 8db3745ae7
commit f415088e21
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

26
run.sh
View File

@ -13,10 +13,11 @@ function setPostgresPassword() {
} }
if [ "$#" -ne 1 ]; then if [ "$#" -ne 1 ]; then
echo "usage: <import|run>" echo "usage: <import|upgrade|run>"
echo "commands:" echo "commands:"
echo " import: Set up the database and import /data.osm.pbf" echo " import: Set up the database and import /data.osm.pbf"
echo " run: Runs Apache and renderd to serve tiles at /tile/{z}/{x}/{y}.png" écho ". upgrade: Upgrade the database
echo " run: Runs Apache and renderd to serve tiles at /tile/{z}/{x}/{y}.png"
echo "environment variables:" echo "environment variables:"
echo " THREADS: defines number of threads used for importing / tile rendering" echo " THREADS: defines number of threads used for importing / tile rendering"
echo " UPDATES: consecutive updates (enabled/disabled)" echo " UPDATES: consecutive updates (enabled/disabled)"
@ -92,6 +93,27 @@ if [ "$1" = "import" ]; then
exit 0 exit 0
fi fi
if [ "$1" = "upgrade" ]; then
# Ensure that database directory is in right state
chown postgres:postgres -R /var/lib/postgresql
if [ ! -f /var/lib/postgresql/13/main/PG_VERSION ]; then
sudo -u postgres /usr/lib/postgresql/13/bin/pg_ctl -D /var/lib/postgresql/13/main/ initdb -o "--locale C.UTF-8"
fi
# Initialize PostgreSQL
createPostgresConfig
service postgresql start
service postgresql stop
exit 0
fi
if [ "$1" = "run" ]; then if [ "$1" = "run" ]; then
# Clean /tmp # Clean /tmp
rm -rf /tmp/* rm -rf /tmp/*