diff --git a/pkg/srv/install_scripts/load_mod_tile.sh b/pkg/srv/install_scripts/load_mod_tile.sh new file mode 100644 index 0000000..7b27da1 --- /dev/null +++ b/pkg/srv/install_scripts/load_mod_tile.sh @@ -0,0 +1,12 @@ +#!/bin/bash + + +if grep -q "/usr/local/etc/renderd.conf" /etc/apache2/sites-available/000-default.conf ; then + echo "renderd was already added to apache config" +else + sed -i "s|ServerAdmin webmaster@localhost|ServerAdmin webmaster@localhost\n\tLoadTileConfigFile /usr/local/etc/renderd.conf\n\tModTileRenderdSocketName /var/run/renderd/renderd.sock\n\tModTileRequestTimeout 0\n\tModTileMissingRequestTimeout 30|" /etc/apache2/sites-available/000-default.conf +fi + +a2enconf mod_tile +service apache2 reload +sudo -u algogis renderd -f -c /usr/local/etc/renderd.conf diff --git a/pkg/srv/install_scripts/move_postgres.sh b/pkg/srv/install_scripts/move_postgres.sh new file mode 100644 index 0000000..2347745 --- /dev/null +++ b/pkg/srv/install_scripts/move_postgres.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +NEW_PATH="/srv/postgresql" +OLD_PATH="/var/lib/postgresql/9.4/main" +FILE_PATH="/etc/postgresql/9.4/main/postgresql.conf" + +# REMOVE OLD DIRS +rm -rf /srv/ + +# STOP SERVICES +systemctl stop postgresql + +# CHANGE POSTGRES DIRECTORY +sed -i "s|$OLD_PATH|$NEW_PATH|g" $FILE_PATH + +# CREATE STRUCTURE +mkdir -p /srv/postgresql +mkdir /srv/styles +mkdir /srv/planet + +# COPY POSTGRESQL +cp -r $OLD_PATH/. $NEW_PATH/ + +# FIX PERMISSIONS +chown -R postgres:postgres /srv/postgresql/ +chmod 700 /srv/postgresql/ + + + +# START SERVICES +systemctl start postgresql + + diff --git a/pkg/srv/install_scripts/setup_apache.sh b/pkg/srv/install_scripts/setup_apache.sh new file mode 100644 index 0000000..75cc205 --- /dev/null +++ b/pkg/srv/install_scripts/setup_apache.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +file_name="/usr/local/etc/renderd.conf" + +sed -i "s|;socketname=/var/run/renderd/renderd.sock|socketname=/var/run/renderd/renderd.sock|g" $file_name + +sed -i "s|plugins_dir=/usr/lib/mapnik/input|plugins_dir=/usr/local/lib/mapnik/input|g" $file_name + +sed -i "s|font_dir=/usr/share/fonts/truetype|font_dir=/usr/share/fonts/truetype/ttf-dejavu|g" $file_name + +sed -i "s|XML=/home/jburgess/osm/svn.openstreetmap.org/applications/rendering/mapnik/osm-local.xml|XML=/srv/styles/OSMBright/OSMBright.xml|g" $file_name + +sed -i "s|HOST=tile.openstreetmap.org|HOST=localhost|g" $file_name +echo "changed config file /usr/local/etc/renderd.conf" +if [ ! -d "/var/run/renderd" ] && [ ! -d "/var/lib/mod_tile" ]; then + mkdir /var/run/renderd + mkdir /var/lib/mod_tile + chown algogis /var/run/renderd + chown algogis /var/lib/mod_tile + echo "renderd dir created at /var/run/renderd" + echo "mod_tile dir created at /var/lib/mod_tile" +fi +if [ ! -f "/etc/apache2/conf-available/mod_tile.conf" ]; then + echo "LoadModule tile_module /usr/lib/apache2/modules/mod_tile.so" >> /etc/apache2/conf-available/mod_tile.conf + echo "Mod_tile config created at /etc/apache2/conf-available/" +fi diff --git a/pkg/srv/install_scripts/setup_dataset.sh b/pkg/srv/install_scripts/setup_dataset.sh new file mode 100644 index 0000000..d85b50c --- /dev/null +++ b/pkg/srv/install_scripts/setup_dataset.sh @@ -0,0 +1,43 @@ +#!/bin/bash +if [ -d "/srv/planet/" ]; then + echo "A dataset already exists at /srv/planet/ this action could overwrite the existing dataset. Do you want to proceed?(y/n)" + read proceed + if [ ! $proceed == "y" ]; then + exit 1; + fi + +fi +mkdir -p /srv/planet +cd /srv/planet +echo "Planet (p), Hamburg (h) or Germany (g) dataset ?:" +read dataset +file="" +file_name="" +if [ $dataset == "p" ]; then + file="http://planet.openstreetmap.org/pbf/planet-latest.osm.pbf" + file_name="planet-latest.osm.pbf" +elif [ $dataset == "g" ]; then + file="http://download.geofabrik.de/europe/germany-latest.osm.pbf" + file_name="germany-latest.osm.pbf" +elif [ $dataset == "h" ]; then + file="http://download.geofabrik.de/europe/germany/hamburg-latest.osm.pbf" + file_name="hamburg-latest.osm.pbf" +fi +if [ ! $file == "" ] && [ ! $file_name == "" ]; then + if [ ! -f "/srv/planet/$file_name" ]; then + wget $file + fi +else + exit 1; +fi +chown -R algogis /srv/planet/ +echo "Do you want to use fast and slowspace ?(y/n)" +read fast + +if [ $fast == "y" ]; then + exit 1; +else + sudo -u algogis osm2pgsql --verbose --unlogged --cache-strategy dense --create --slim --drop -d gis -C 4096 --number-processes 2 --disable-parallel-indexing --flat-nodes /srv/planet/nodes.flat $file_name +fi + + diff --git a/pkg/srv/install_scripts/setup_styles.sh b/pkg/srv/install_scripts/setup_styles.sh new file mode 100644 index 0000000..36d4e2c --- /dev/null +++ b/pkg/srv/install_scripts/setup_styles.sh @@ -0,0 +1,55 @@ +#!/bin/bash + +MASTER_STYLE="https://github.com/mapbox/osm-bright/archive/master.zip" +SIMPLIFIED_POLY="http://data.openstreetmapdata.com/simplified-land-polygons-complete-3857.zip" +LAND_POLY="http://data.openstreetmapdata.com/land-polygons-split-3857.zip" +SIMPLIFIED_SHAPE_NEW="\"/srv/osm-bright-master/shp/simplified-land-polygons-complete-3857/simplified-land-polygons-complete-3857.shp\", \"type\": \"shape\"" + +SIMPLIFIED_SHAPE_OLD="\"http://data.openstreetmapdata.com/simplified-land-polygons-complete-3857.zip\"" + +SPLIT_SHAPE_OLD="\"http://data.openstreetmapdata.com/land-polygons-split-3857.zip\"" + +SPLIT_SHAPE_NEW="\"/srv/osm-bright-master/shp/land-polygons-split-3857/land-polygons-split-3857.shp\", \"type\": \"shape\"" + +PROJECT_FILE="/srv/styles/osm-bright-master/osm-bright/osm-bright.osm2pgsql.mml" +# DOWNLOAD STYLES +mkdir /srv/styles +cd /srv/styles +wget $MASTER_STYLE +wget $SIMPLIFIED_POLY +wget $LAND_POLY + +# UNZIP & MOVE +unzip '*.zip' +rm -rf /srv/styles/*.zip +mkdir osm-bright-master/shp +mv land-polygons-split-3857 osm-bright-master/shp/ +mv simplified-land-polygons-complete-3857 osm-bright-master/shp/ + +# INDEX SHAPES +cd osm-bright-master/shp/land-polygons-split-3857 +shapeindex land_polygons.shp +cd ../simplified-land-polygons-complete-3857/ +shapeindex simplified_land_polygons.shp +cd ../.. + +# REPLACE SHAPE FILES & REMOVE POPULATED +sed -i "s|$SIMPLIFIED_SHAPE_OLD|$SIMPLIFIED_SHAPE_NEW|g" $PROJECT_FILE +sed -i "s|$SPLIT_SHAPE_OLD|$SPLIT_SHAPE_NEW|g" $PROJECT_FILE +sed -i '401,413 d' $PROJECT_FILE +# Configure style +cp /srv/styles/osm-bright-master/configure.py.sample /srv/styles/osm-bright-master/configure.py + +sed -i 's/osm\"/gis\"/' /srv/styles/osm-bright-master/configure.py +sed -i 's|~/Documents/MapBox/project|/srv/styles|' srv/styles/osm-bright-master/configure.py + +# Compile style +cd /srv/styles/osm-bright-master/ +./make.py +pushd ../OSMBright +sh -c "carto project.mml > OSMBright.xml" +popd + +# Set permissions +chown -R algogis /srv/styles + diff --git a/pkg/srv/install_scripts/setup_user_postgis.sh b/pkg/srv/install_scripts/setup_user_postgis.sh new file mode 100644 index 0000000..1525c5f --- /dev/null +++ b/pkg/srv/install_scripts/setup_user_postgis.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +DATABASE_NAME="gis" + +# SETUP USER FOR DB +sudo -u postgres createuser algogis +sudo -u postgres createdb -E UTF8 -O algogis gis +useradd -m algogis + +# SETUP DB +sudo -u postgres psql $DATABASE_NAME -c 'CREATE EXTENSION postgis;ALTER TABLE geometry_columns OWNER TO algogis; ALTER TABLE spatial_ref_sys OWNER TO algogis;' diff --git a/rpm.sh b/rpm.sh index 476b1ef..d4a7e8d 100755 --- a/rpm.sh +++ b/rpm.sh @@ -53,7 +53,7 @@ fpm -C pkg \ -t deb \ --name tileserver \ --version 1.0.0 \ - --depends postgresql,postgresql-contrib,postgis,postgresql-9.4-postgis-2.1,apache2,autoconf,apache2-dev,libboost-all-dev,zlib1g-dev,libfreetype6-dev,libharfbuzz-dev,libpng-dev,libproj-dev,libpq-dev \ + --depends postgresql,postgresql-contrib,postgis,postgresql-9.4-postgis-2.1,apache2,autoconf,apache2-dev,libboost-all-dev,zlib1g-dev,libfreetype6-dev,libharfbuzz-dev,libpng-dev,libproj-dev,libpq-dev,node-carto,unifont,ttf-dejavu \ --description "TileServer setup (mapnik, osm2pgsql, mod_tile)" \ --after-install hooks/after-install.sh \ .