]> git.openstreetmap.org Git - rails.git/blob - script/vagrant/setup/provision.sh
Merge remote-tracking branch 'upstream/pull/4705'
[rails.git] / script / vagrant / setup / provision.sh
1 #!/usr/bin/env bash
2
3 # abort on error
4 set -e
5
6 # set locale to UTF-8 compatible. apologies to non-english speakers...
7 locale-gen en_GB.utf8
8 update-locale LANG=en_GB.utf8 LC_ALL=en_GB.utf8
9 export LANG=en_GB.utf8
10 export LC_ALL=en_GB.utf8
11
12 # make sure we have up-to-date packages
13 apt-get update
14
15 # upgrade all packages
16 apt-get upgrade -y
17
18 # install packages as explained in INSTALL.md
19 apt-get install -y ruby ruby-dev ruby-bundler \
20                      libxml2-dev libxslt1-dev nodejs npm \
21                      build-essential git-core \
22                      postgresql postgresql-contrib libpq-dev libvips-dev libyaml-dev \
23                      libsasl2-dev libffi-dev libgd-dev libarchive-dev libbz2-dev
24 npm install --global yarn
25
26 ## install the bundle necessary for openstreetmap-website
27 pushd /srv/openstreetmap-website
28 # do bundle install as a convenience
29 bundle install --retry=10 --jobs=2
30 # do yarn install as a convenience
31 bundle exec bin/yarn install
32 # create user and database for openstreetmap-website
33 db_user_exists=`sudo -u postgres psql postgres -tAc "select 1 from pg_roles where rolname='vagrant'"`
34 if [ "$db_user_exists" != "1" ]; then
35     sudo -u postgres createuser -s vagrant
36 fi
37
38 # set up sample configs
39 if [ ! -f config/database.yml ]; then
40     sudo -u vagrant cp config/example.database.yml config/database.yml
41 fi
42 if [ ! -f config/storage.yml ]; then
43     cp config/example.storage.yml config/storage.yml
44 fi
45 touch config/settings.local.yml
46 # create the databases
47 sudo -u vagrant bundle exec rails db:create
48 # migrate the database to the latest version
49 sudo -u vagrant bundle exec rails db:migrate
50 popd