6 # set locale to UTF-8 compatible. apologies to non-english speakers...
8 update-locale LANG=en_GB.utf8 LC_ALL=en_GB.utf8
10 export LC_ALL=en_GB.utf8
12 # make sure we have up-to-date packages
15 # upgrade all packages
18 # install packages as explained in INSTALL.md
19 apt-get install -y ruby2.5 libruby2.5 ruby2.5-dev \
20 libmagickwand-dev libxml2-dev libxslt1-dev nodejs \
21 apache2 apache2-dev build-essential git-core phantomjs \
22 postgresql postgresql-contrib libpq-dev postgresql-server-dev-all \
23 libsasl2-dev imagemagick libffi-dev libgd-dev libarchive-dev libbz2-dev
25 gem2.5 install --version "~> 1.16.2" bundler
27 ## install the bundle necessary for openstreetmap-website
28 pushd /srv/openstreetmap-website
29 # do bundle install as a convenience
30 bundle install --retry=10 --jobs=2
31 # create user and database for openstreetmap-website
32 db_user_exists=`sudo -u postgres psql postgres -tAc "select 1 from pg_roles where rolname='vagrant'"`
33 if [ "$db_user_exists" != "1" ]; then
34 sudo -u postgres createuser -s vagrant
35 sudo -u vagrant createdb -E UTF-8 -O vagrant openstreetmap
36 sudo -u vagrant createdb -E UTF-8 -O vagrant osm_test
37 # add btree_gist extension
38 sudo -u vagrant psql -c "create extension btree_gist" openstreetmap
39 sudo -u vagrant psql -c "create extension btree_gist" osm_test
41 # build and set up postgres extensions
44 sudo -u vagrant psql openstreetmap -c "CREATE OR REPLACE FUNCTION maptile_for_point(int8, int8, int4) RETURNS int4 AS '/srv/openstreetmap-website/db/functions/libpgosm.so', 'maptile_for_point' LANGUAGE C STRICT"
45 sudo -u vagrant psql openstreetmap -c "CREATE OR REPLACE FUNCTION tile_for_point(int4, int4) RETURNS int8 AS '/srv/openstreetmap-website/db/functions/libpgosm.so', 'tile_for_point' LANGUAGE C STRICT"
46 sudo -u vagrant psql openstreetmap -c "CREATE OR REPLACE FUNCTION xid_to_int4(xid) RETURNS int4 AS '/srv/openstreetmap-website/db/functions/libpgosm.so', 'xid_to_int4' LANGUAGE C STRICT"
48 # set up sample configs
49 if [ ! -f config/database.yml ]; then
50 sudo -u vagrant cp config/example.database.yml config/database.yml
52 touch config/settings.local.yml
53 # migrate the database to the latest version
54 sudo -u vagrant rake db:migrate