]> git.openstreetmap.org Git - rails.git/blob - script/vagrant/setup/provision.sh
Merge pull request #31 from zerebubuth/routing-ui-tweaks-2
[rails.git] / script / vagrant / setup / provision.sh
1 #!/usr/bin/env bash
2
3 # set locale to UTF-8 compatible. apologies to non-english speakers...
4 update-locale LANG=en_GB.utf8 LC_ALL=en_GB.utf8
5 locale-gen
6 export LANG=en_GB.utf8
7 export LC_ALL=en_GB.utf8
8
9 # make sure we have up-to-date packages
10 apt-get update
11
12 ## vagrant grub-pc fix from: https://gist.github.com/jrnickell/6289943
13 # parameters
14 echo "grub-pc grub-pc/kopt_extracted boolean true" | debconf-set-selections
15 echo "grub-pc grub2/linux_cmdline string" | debconf-set-selections
16 echo "grub-pc grub-pc/install_devices multiselect /dev/sda" | debconf-set-selections
17 echo "grub-pc grub-pc/install_devices_failed_upgrade boolean true" | debconf-set-selections
18 echo "grub-pc grub-pc/install_devices_disks_changed multiselect /dev/sda" | debconf-set-selections
19 # vagrant grub fix
20 dpkg-reconfigure -f noninteractive grub-pc
21
22 # upgrade all packages
23 apt-get upgrade -y
24
25 # install packages as explained in INSTALL.md
26 apt-get install -y ruby1.9.1 libruby1.9.1 ruby1.9.1-dev ri1.9.1 \
27     libmagickwand-dev libxml2-dev libxslt1-dev nodejs \
28     apache2 apache2-threaded-dev build-essential git-core \
29     postgresql postgresql-contrib libpq-dev postgresql-server-dev-all \
30     libsasl2-dev
31 gem1.9.1 install bundle
32
33 ## install the bundle necessary for openstreetmap-website
34 pushd /srv/openstreetmap-website
35 # do bundle install as a convenience
36 sudo -u vagrant -H bundle install
37 # create user and database for openstreetmap-website
38 db_user_exists=`sudo -u postgres psql postgres -tAc "select 1 from pg_roles where rolname='vagrant'"`
39 if [ "$db_user_exists" != "1" ]; then
40                 sudo -u postgres createuser -s vagrant
41                 sudo -u vagrant -H createdb -E UTF-8 -O vagrant openstreetmap
42                 sudo -u vagrant -H createdb -E UTF-8 -O vagrant osm_test
43                 # add btree_gist extension
44                 sudo -u vagrant -H psql -c "create extension btree_gist" openstreetmap
45                 sudo -u vagrant -H psql -c "create extension btree_gist" osm_test
46 fi
47 # build and set up postgres extensions
48 pushd db/functions
49 sudo -u vagrant make
50 sudo -u vagrant psql openstreetmap -c "drop function if exists maptile_for_point(int8, int8, int4)"
51 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"
52 popd
53 # set up sample configs
54 if [ ! -f config/database.yml ]; then
55                 sudo -u vagrant cp config/example.database.yml config/database.yml
56 fi
57 if [ ! -f config/application.yml ]; then
58                 sudo -u vagrant cp config/example.application.yml config/application.yml
59 fi
60 # migrate the database to the latest version
61 sudo -u vagrant rake db:migrate
62 popd