3 # set locale to UTF-8 compatible. apologies to non-english speakers...
4 update-locale LANG=en_GB.utf8 LC_ALL=en_GB.utf8
7 export LC_ALL=en_GB.utf8
9 # make sure we have up-to-date packages
12 # upgrade all packages
15 # install packages as explained in INSTALL.md
16 apt-get install -y ruby2.0 libruby2.0 ruby2.0-dev \
17 libmagickwand-dev libxml2-dev libxslt1-dev nodejs \
18 apache2 apache2-threaded-dev build-essential git-core \
19 postgresql postgresql-contrib libpq-dev postgresql-server-dev-all \
20 libsasl2-dev imagemagick
21 gem2.0 install bundler
23 ## install the bundle necessary for openstreetmap-website
24 pushd /srv/openstreetmap-website
25 # do bundle install as a convenience
26 sudo -u vagrant -H bundle install
27 # create user and database for openstreetmap-website
28 db_user_exists=`sudo -u postgres psql postgres -tAc "select 1 from pg_roles where rolname='vagrant'"`
29 if [ "$db_user_exists" != "1" ]; then
30 sudo -u postgres createuser -s vagrant
31 sudo -u vagrant -H createdb -E UTF-8 -O vagrant openstreetmap
32 sudo -u vagrant -H createdb -E UTF-8 -O vagrant osm_test
33 # add btree_gist extension
34 sudo -u vagrant -H psql -c "create extension btree_gist" openstreetmap
35 sudo -u vagrant -H psql -c "create extension btree_gist" osm_test
37 # build and set up postgres extensions
40 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"
41 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"
42 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"
44 # set up sample configs
45 if [ ! -f config/database.yml ]; then
46 sudo -u vagrant cp config/example.database.yml config/database.yml
48 if [ ! -f config/application.yml ]; then
49 sudo -u vagrant cp config/example.application.yml config/application.yml
51 # migrate the database to the latest version
52 sudo -u vagrant rake db:migrate