Update run.sh for dealing with lang argument (second arg of the script)

This commit is contained in:
2026-09-03 17:10:54 +02:00
parent 0247539751
commit ef4177842f
+20 -6
View File
@@ -13,7 +13,7 @@ function setPostgresPassword() {
} }
function compileStyle() { function compileStyle() {
local lang=$1 local lang="${1:-}"
cd /data/style/ cd /data/style/
git clone --single-branch --branch v6.0.0 https://github.com/osmbe/openstreetmap-carto-be --depth 1 git clone --single-branch --branch v6.0.0 https://github.com/osmbe/openstreetmap-carto-be --depth 1
mkdir /data/style/patterns/ mkdir /data/style/patterns/
@@ -26,12 +26,14 @@ function compileStyle() {
if [ -z "$lang" ]; then if [ -z "$lang" ]; then
carto openstreetmap-carto-be/project.mml > mapnik.xml carto openstreetmap-carto-be/project.mml > mapnik.xml
return 1 return 1
else
carto "openstreetmap-carto-be/project-${lang}.mml" > mapnik-${lang}.xml
return 1
fi fi
carto "openstreetmap-carto-be/project-${lang}.mml" > mapnik-${lang}.xml
} }
if [ "$#" -ne 1 ]; then if [ "$#" -gt 2 ]; then
echo "usage: <import|run>" echo "usage: <import|run>"
echo "commands:" echo "commands:"
echo " import: Set up the database and import /data/region.osm.pbf" echo " import: Set up the database and import /data/region.osm.pbf"
@@ -54,7 +56,11 @@ fi
if [ "$1" == "import" ]; then if [ "$1" == "import" ]; then
compileStyle $2 if [ "$#" -gt 1 ]; then
compileStyle "$2"
else
compileStyle
fi
# Ensure that database directory is in right state # Ensure that database directory is in right state
mkdir -p /data/database/postgres/ mkdir -p /data/database/postgres/
@@ -146,7 +152,11 @@ if [ "$1" == "run" ]; then
# Clean /tmp # Clean /tmp
rm -rf /tmp/* rm -rf /tmp/*
compileStyle $2 if [ -z "$2" ]; then
compileStyle $2
else
compileStyle
fi
# migrate old files # migrate old files
if [ -f /data/database/PG_VERSION ] && ! [ -d /data/database/postgres/ ]; then if [ -f /data/database/PG_VERSION ] && ! [ -d /data/database/postgres/ ]; then
@@ -212,7 +222,11 @@ fi
if [ "$1" == "generate_tiles" ]; then if [ "$1" == "generate_tiles" ]; then
compileStyle $2 if [ -z "$2" ]; then
compileStyle $2
else
compileStyle
fi
service postgresql start service postgresql start
service apache2 restart service apache2 restart