This repository was archived by the owner on Jul 26, 2018. It is now read-only.
forked from makinacorpus/osm-mirror
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·220 lines (151 loc) · 6.64 KB
/
install.sh
File metadata and controls
executable file
·220 lines (151 loc) · 6.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
#!/bin/bash
set -e
OSM_MIRROR_CONF=/etc/default/openstreetmap-conf
function echo_step () {
echo -e "\e[92m\e[1m$1\e[0m"
}
function echo_error () {
echo -e "\e[91m\e[1m$1\e[0m"
}
#.......................................................................
jessie=$(grep "Debian GNU/Linux 8" /etc/issue | wc -l)
if [ ! $jessie -eq 1 ] ; then
echo_error "Unsupported operating system. Aborted."
exit 5
fi
#.......................................................................
echo_step "Configure instance..."
if [[ -z "$EXTENT" ]]; then
read -e -p "Enter extent (xmin,ymin,xmax,ymax): " -i "2.04,43.88,2.22,43.98" EXTENT
fi
cat << _EOF_ > $OSM_MIRROR_CONF
DB_NAME="gis"
DB_USER="gisuser"
DB_PASSWORD="corpus"
EXTENT="${EXTENT}"
_EOF_
source $OSM_MIRROR_CONF
#.......................................................................
echo_step "Upgrade operating system..."
apt-get update > /dev/null
apt-get dist-upgrade -y
#.......................................................................
echo_step "Install necessary components..."
apt-get install -y git curl wget libgdal1h gdal-bin mapnik-utils unzip \
apache2 postgresql-9.4 postgis dpkg-dev debhelper apache2-dev \
libmapnik-dev autoconf automake m4 libtool libcurl4-gnutls-dev \
libcairo2-dev apache2-mpm-event osm2pgsql
locale-gen en_US en_US.UTF-8
locale-gen fr_FR fr_FR.UTF-8
dpkg-reconfigure locales
export DEBIAN_FRONTEND=noninteractive
#.......................................................................
if [ ! -f README.md ]; then
echo_step "Downloading installer source..."
git clone --recursive --depth=50 --branch=jessie https://github.com/makinacorpus/osm-mirror.git /tmp/osm-mirror
rm -f /tmp/osm-mirror/install.sh
shopt -s dotglob nullglob
cp -R /tmp/osm-mirror/* .
fi
#.......................................................................
echo_step "Install mod_tile..."
if [ -d mod_tile ]; then
cd mod_tile
git checkout master
git pull
else
git clone https://github.com/makinacorpus/mod_tile
cd mod_tile
fi
dpkg-buildpackage
cd ..
dpkg -i renderd_0.4.1_amd64.deb
dpkg -i libapache2-mod-tile_0.4.1_amd64.deb
#.......................................................................
echo_step "Configure database..."
su postgres -c "psql -c \"CREATE USER ${DB_USER} WITH PASSWORD '${DB_PASSWORD}';\""
su postgres -c "psql -c \"CREATE DATABASE ${DB_NAME} OWNER ${DB_USER} ENCODING 'UTF8' TEMPLATE template0;\""
su postgres -c "psql -d ${DB_NAME} -c \"CREATE EXTENSION postgis;\""
su postgres -c "psql -d ${DB_NAME} -c \"GRANT ALL ON spatial_ref_sys, geometry_columns, raster_columns TO ${DB_USER};\""
cat << _EOF_ >> /etc/postgresql/9.4/main/pg_hba.conf
# Automatically added by OSM installation :
local ${DB_NAME} ${DB_USER} trust
host ${DB_NAME} ${DB_USER} 127.0.0.1/32 trust
_EOF_
echo_step "Restart service..."
/etc/init.d/postgresql restart
#.......................................................................
OSM_DATA=/usr/share/mapnik-osm-data/world_boundaries
if [ ! -f $OSM_DATA/10m-land.shp ]; then
echo_step "Load world boundaries data..."
mkdir -p $OSM_DATA
rm -rf $OSM_DATA/ne_10m_populated_places_fixed.*
zipfile=/tmp/ne_10m_populated_places.zip
curl -L -o "$zipfile" "http://www.naturalearthdata.com/http//www.naturalearthdata.com/download/10m/cultural/ne_10m_populated_places.zip"
unzip -qqu $zipfile -d /tmp
rm $zipfile
mv /tmp/ne_10m_populated_places.* $OSM_DATA/
ogr2ogr $OSM_DATA/ne_10m_populated_places_fixed.shp $OSM_DATA/ne_10m_populated_places.shp
zipfile=/tmp/simplified-land-polygons-complete-3857.zip
curl -L -o "$zipfile" "http://data.openstreetmapdata.com/simplified-land-polygons-complete-3857.zip"
unzip -qqu $zipfile simplified-land-polygons-complete-3857/simplified_land_polygons.{shp,shx,prj,dbf,cpg} -d /tmp
rm $zipfile
mv /tmp/simplified-land-polygons-complete-3857/simplified_land_polygons.* $OSM_DATA/
zipfile=/tmp/land-polygons-split-3857.zip
curl -L -o "$zipfile" "http://data.openstreetmapdata.com/land-polygons-split-3857.zip"
unzip -qqu $zipfile -d /tmp
rm $zipfile
mv /tmp/land-polygons-split-3857/land_polygons.* $OSM_DATA/
zipfile=/tmp/coastline-good.zip
curl -L -o "$zipfile" "http://tilemill-data.s3.amazonaws.com/osm/coastline-good.zip"
unzip -qqu $zipfile -d /tmp
rm $zipfile
mv /tmp/coastline-good.* $OSM_DATA/
tarfile=/tmp/shoreline_300.tar.bz2
curl -L -o "$tarfile" "http://tile.openstreetmap.org/shoreline_300.tar.bz2"
tar -xf $tarfile -C /tmp
rm $tarfile
mv /tmp/shoreline_300.* $OSM_DATA/
tarfile=/tmp/world_boundaries-spherical.tgz
curl -L -o "$tarfile" "http://planet.openstreetmap.org/historical-shapefiles/world_boundaries-spherical.tgz"
tar -xf $tarfile -C /tmp
rm $tarfile
mv /tmp/world_boundaries/builtup_area.* $OSM_DATA/
zipfile=/tmp/ne_110m_admin_0_boundary_lines_land.zip
curl -L -o "$zipfile" "http://www.naturalearthdata.com/http//www.naturalearthdata.com/download/110m/cultural/ne_110m_admin_0_boundary_lines_land.zip"
unzip -qqu $zipfile -d /tmp
rm $zipfile
mv /tmp/ne_110m_admin_0_boundary_lines_land.* $OSM_DATA/
zipfile=/tmp/10m-land.zip
curl -L -o "$zipfile" "http://mapbox-geodata.s3.amazonaws.com/natural-earth-1.3.0/physical/10m-land.zip"
unzip -qqu $zipfile -d /tmp
rm $zipfile
mv /tmp/10m-land.* $OSM_DATA/
shapeindex --shape_files \
$OSM_DATA/simplified_land_polygons.shp \
$OSM_DATA/land_polygons.shp \
$OSM_DATA/coastline-good.shp \
$OSM_DATA/10m-land.shp \
$OSM_DATA/shoreline_300.shp \
$OSM_DATA/ne_10m_populated_places_fixed.shp \
$OSM_DATA/builtup_area.shp \
$OSM_DATA/ne_110m_admin_0_boundary_lines_land.shp
fi
#.......................................................................
echo_step "Deploy preview map..."
rm -rf /var/www/html
cp -R preview/* /var/www/
#.......................................................................
echo_step "Setup monthly update in root crontab..."
croncmd="`pwd`/update-data.sh 2> /var/log/openstreetmap-errors"
cronjob="0 2 1 * * $croncmd"
( crontab -u root -l 2> /dev/null | grep -v "$croncmd" ; echo "$cronjob" ) | crontab -u root -
#.......................................................................
./update-data.sh
# Grant rights on OSM tables
/usr/bin/install-postgis-osm-user.sh ${DB_NAME} www-data 2> /dev/null
/usr/bin/install-postgis-osm-user.sh ${DB_NAME} gisuser 2> /dev/null
#.......................................................................
./update-conf.sh
#.......................................................................
echo_step "Install done."