LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 01-18-2017, 05:23 AM   #1
bluesymbol
LQ Newbie
 
Registered: Jan 2017
Posts: 1

Rep: Reputation: Disabled
Opentileserver - adding updated tiles via script


Hello!

First post here so I hope you can help! I'm not much of an expert by a long stretch but I'll do what I can!

We deploy a Mapnik server using the opentileserver.sh script - found in the below link.
https://github.com/MapFig/opentilese...ntileserver.sh

This works great, however we now need to update the maptiles as they are getting out of date. So, running the script designed to update the tiles results in just a sea of red 'failed to load' type tiles when you browse the page. Can anyone suggest why this maybe failing? The script seems to complete without error, it's only when the page is browsed that we see the issue.

Thanks
Blue

#!/bin/bash -e
#Version: 0.2
#Description: Reload OSM data to server built with opentileserver.sh
#Note: This script assumes all external commands
# (pg_config, osm2pgsl, ...) are installed.
#Usage: reload-opentileserver.sh [-add] [pbf_url]
# To run in non-Latin language uncomment below
#export LC_ALL=C
PBF_ADD='no'
if [ "${1}" == '-add' ]; then
PBF_ADD='yes'
shift 1;
fi

PBF_URL="${1}"; #http://download.geofabrik.de/europe/...latest.osm.pbf
OSM_USER='tile'
OSM_DB='gis'

#Check input parameters
if [ -z "${PBF_URL}" ]; then
echo "Usage: $0 [-add] pbf_url"; exit 1;
fi

#C_MEM is the sum of free memory and cached memory
C_MEM=$(free -m | grep -i 'mem:' | sed 's/[ \t]\+/ /g' | cut -f4,7 -d' ' | tr ' ' '+' | bc)
NP=$(grep -c 'model name' /proc/cpuinfo)
PG_VER=$(pg_config | grep '^VERSION' | cut -f4 -d' ' | cut -f1,2 -d.)
osm2pgsql_OPTS="--slim -d ${OSM_DB} -C ${C_MEM} --number-processes ${NP}"

#Clear renderd cache
service renderd stop
rm -rf /var/lib/mod_tile/default/*

PBF_FILE="/home/${OSM_USER}/${PBF_URL##*/}"
if [ ! -f ${PBF_FILE} ]; then
wget -P/home/${OSM_USER} ${PBF_URL}
chown ${OSM_USER}:${OSM_USER} ${PBF_FILE}
fi

cat >/etc/postgresql/${PG_VER}/main/pg_hba.conf <<CMD_EOF
local all all trust
host all all 127.0.0.1 255.255.255.255 md5
host all all 0.0.0.0/0 md5
host all all ::1/128 md5
CMD_EOF

#Turn off autovacuum and fsync during load of PBF
sed -i 's/#\?fsync.*/fsync = off/' /etc/postgresql/${PG_VER}/main/postgresql.conf
sed -i 's/#\?autovacuum.*/autovacuum = off/' /etc/postgresql/${PG_VER}/main/postgresql.conf

service postgresql restart


if [ "${PBF_ADD}" == 'no' ]; then
#Remove old osm db and user
sudo -u postgres dropdb --if-exists ${OSM_DB}
sudo -u postgres dropuser --if-exists ${OSM_USER}

#create user,db and extensions
psql -Upostgres ${OSM_DB} <<EOF_CMD
create user ${OSM_USER} with password '${OSM_PG_PASS}';
create database ${OSM_DB} owner=${OSM_USER};
\c ${OSM_DB}
CREATE EXTENSION postgis;
ALTER TABLE geometry_columns OWNER TO ${OSM_USER};
ALTER TABLE spatial_ref_sys OWNER TO ${OSM_USER};
EOF_CMD
if [ $? -ne 0 ]; then echo "Error: Failed to setup osm user, db or extensions"; exit 1; fi
fi

sudo -u ${OSM_USER} osm2pgsql ${osm2pgsql_OPTS} ${PBF_FILE}
if [ $? -eq 0 ]; then #If import went good
rm -rf ${PBF_FILE}
fi

#restore password for pg
#Turn on autovacuum and fsync during load of PBF
sed -i.save 's/#\?fsync.*/fsync = on/' /etc/postgresql/${PG_VER}/main/postgresql.conf
sed -i.save 's/#\?autovacuum.*/autovacuum = on/' /etc/postgresql/${PG_VER}/main/postgresql.conf
sed -i.save 's/local all all.*/local all all md5/' /etc/postgresql/${PG_VER}/main/pg_hba.conf

#Restart services
service postgresql restart
service apache2 reload
service renderd start
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
slackpkg+ setupmultilib.sh script needs to be updated Gerard Lally Slackware 1 07-31-2016 05:52 AM
LXer: I'm Not Down with Windows 8 Tiles LXer Syndicated Linux News 0 11-20-2012 08:50 PM
[SOLVED] Adding start up script in rcX.d --> Via update-rc SCRIPT defaults .... :-( jv2112 Linux - Newbie 6 07-04-2011 06:19 AM
Shell script adding autostart gnome script Coolrunr Programming 3 01-01-2009 02:23 PM
bash script to email updated ip ericnmu Linux - Networking 1 10-01-2004 10:30 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 12:58 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration