X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/3c1371adaf8cd9f2f67fd5e2be3b66c3fa42b56a..df283287e69c7941e111072ec4a4ea83e48b76f6:/script/vagrant/setup/provision.sh?ds=sidebyside diff --git a/script/vagrant/setup/provision.sh b/script/vagrant/setup/provision.sh index 21d5daf59..47534b84d 100644 --- a/script/vagrant/setup/provision.sh +++ b/script/vagrant/setup/provision.sh @@ -35,13 +35,28 @@ pushd /srv/openstreetmap-website # do bundle install as a convenience sudo -u vagrant -H bundle install # create user and database for openstreetmap-website -sudo -u postgres createuser -s vagrant -sudo -u vagrant -H createdb -E UTF-8 -O vagrant openstreetmap -sudo -u vagrant -H createdb -E UTF-8 -O vagrant osm_test -# add btree_gist extension -sudo -u vagrant -H psql -c "create extension btree_gist" openstreetmap -# TODO: build and set up postgres extensions +db_user_exists=`sudo -u postgres psql postgres -tAc "select 1 from pg_roles where rolname='vagrant'"` +if [ "$db_user_exists" != "1" ]; then + sudo -u postgres createuser -s vagrant + sudo -u vagrant -H createdb -E UTF-8 -O vagrant openstreetmap + sudo -u vagrant -H createdb -E UTF-8 -O vagrant osm_test + # add btree_gist extension + sudo -u vagrant -H psql -c "create extension btree_gist" openstreetmap + sudo -u vagrant -H psql -c "create extension btree_gist" osm_test +fi +# build and set up postgres extensions +pushd db/functions +sudo -u vagrant make +sudo -u vagrant psql openstreetmap -c "drop function if exists maptile_for_point(int8, int8, int4)" +sudo -u vagrant psql openstreetmap -c "CREATE FUNCTION maptile_for_point(int8, int8, int4) RETURNS int4 AS '/srv/openstreetmap-website/db/functions/libpgosm.so', 'maptile_for_point' LANGUAGE C STRICT" +popd # set up sample configs -sudo -u vagrant cp config/example.database.yml config/database.yml -sudo -u vagrant cp config/example.application.yml config/application.yml +if [ ! -f config/database.yml ]; then + sudo -u vagrant cp config/example.database.yml config/database.yml +fi +if [ ! -f config/application.yml ]; then + sudo -u vagrant cp config/example.application.yml config/application.yml +fi +# migrate the database to the latest version +sudo -u vagrant rake db:migrate popd