From 94c761fc5eb91fa7b558f0c8e8bdbff4f34e2ac7 Mon Sep 17 00:00:00 2001 From: Sam Pearson Date: Mon, 5 Nov 2018 13:16:10 +0000 Subject: [Vagrant] Check and generate config file if necessary This adds support in `script/setup` for generating a local `general.yml` if it doesn't already exist and is run as the `vagrant` user. This is called from the `Vagrantfile` when using the FixMyStreet Vagrant box. [skip ci] --- CHANGELOG.md | 1 + Vagrantfile | 2 +- docs/install/manual-install.md | 10 ++++++---- script/setup | 16 +++++++++++++++- 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d1f292dd3..4757f2660 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ - Have body.url work in hashref lookup. #2284 - OSM based map types can now override zoom levels #2288 - Clearer name for navigation colours in SCSS. #2080 + - `script/setup` now creates `conf/general.yml` for Vagrant when needed. - Internal things: - Move send-comments code to package for testing. #2109 #2170 - Open311 improvements: diff --git a/Vagrantfile b/Vagrantfile index 6873ace46..0fc6f29cf 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -55,7 +55,7 @@ EOS # This just runs our update script, used on our offical box. $update = <<-EOS chown -R vagrant:vagrant /home/vagrant/.cpanm - su vagrant -c '/home/vagrant/fixmystreet/script/update ; exit $?' + su vagrant -c '/home/vagrant/fixmystreet/script/setup ; exit $?' if [ $? -eq 0 ]; then touch /tmp/success else diff --git a/docs/install/manual-install.md b/docs/install/manual-install.md index fcb65ad41..5ddf8a30f 100644 --- a/docs/install/manual-install.md +++ b/docs/install/manual-install.md @@ -7,10 +7,10 @@ title: Installing

This page describes how to install the FixMyStreet platform manually. - You can use this if you're used to setting up web applications — + You can use this if you're used to setting up web applications — but the other installation options may be easier:

-Note that this is just one of +Note that this is just one of [many ways to install FixMyStreet]({{ "/install/" | relative_url }}) (the other ways are easier!). @@ -129,7 +129,9 @@ and compiles any translation `.mo` files (using `commonlib/bin/gettext-makemo`). The settings for FixMyStreet are defined in `conf/general.yml` using the YAML markup language. There are some defaults in `conf/general.yml-example` which -you should copy to `conf/general.yml`: +you should copy to `conf/general.yml`; note that if you are using the Vagrant +environment, a simple `conf/general.yml` file should already have been +configured for you. {% highlight bash %} $ cp conf/general.yml-example conf/general.yml @@ -151,7 +153,7 @@ Some others you might want to look at, though the defaults are enough for it to * [GEO_CACHE]({{ "/customising/config/#geo_cache" | relative_url }}) -- this is the location where Geolocation data will be cached. It should be accessible by and writeable by the FixMyStreet process. If you are using Bing or Google maps you should also set one of -[BING_MAPS_API_KEY]({{ "/customising/config/#bing_maps_api_key" | relative_url }}) or +[BING_MAPS_API_KEY]({{ "/customising/config/#bing_maps_api_key" | relative_url }}) or [GOOGLE_MAPS_API_KEY]({{ "/customising/config/#google_maps_api_key" | relative_url }}). ### 6. Set up some required data diff --git a/script/setup b/script/setup index 30f375712..badf23744 100755 --- a/script/setup +++ b/script/setup @@ -3,5 +3,19 @@ set -e cd "$(dirname "$0")/.." -# Same as update for now +# If we're running in Vagrant and there isn't a valid config file, set one up. +if [ ! -f conf/general.yml ] && [ "$USER" = "vagrant" ]; then + echo -n "Setting up a default conf/general.yml file for Vagrant..." + sed -r \ + -e "s,^( *FMS_DB_HOST:).*,\\1 ''," \ + -e "s,^( *FMS_DB_NAME:).*,\\1 'fixmystreet'," \ + -e "s,^( *FMS_DB_USER:).*,\\1 'vagrant'," \ + -e "s,^( *BASE_URL:).*,\\1 'http://127.0.0.1.xip.io:3000'," \ + -e "s,^( *EMAIL_DOMAIN:).*,\\1 '127.0.0.1.xip.io'," \ + -e "s,^( *CONTACT_EMAIL:).*,\\1 'help@127.0.0.1.xip.io'," \ + -e "s,^( *DO_NOT_REPLY_EMAIL:).*,\\1 'help@127.0.0.1.xip.io'," \ + conf/general.yml-example > conf/general.yml +fi + +# The rest should be the same as update for now script/update -- cgit v1.2.3