Skip to content

Commit

Permalink
Updated base vagrant box. added full provisioning of HRPG env.
Browse files Browse the repository at this point in the history
  • Loading branch information
thepeopleseason committed Apr 11, 2014
1 parent c1a2193 commit 326b65a
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 35 deletions.
55 changes: 41 additions & 14 deletions VAGRANT.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## Vagrant ##
# Vagrant #

Vagrant is a system to create reproducible and portable development
environments. Because of the variety of systems used for HabitRPG
Expand All @@ -8,37 +8,64 @@ minimal dependencies on the developer's local platform.

To use Vagrant, go to [their downloads
page](http://www.vagrantup.com/downloads.html) and download and install
the software appropriate for your system.
the software appropriate for your system. Using HabitRPG's vagrant image
requires a minimum of Vagrant version 1.5.

Once Vagrant has been installed, issue the following commands to get the
environment up and running:

1. Fork and Clone the HabitRPG git repository
2. Boot up the box:
2. Create a config file from the sample config:

`vagrant up`
`cp config.json.example config.json`

3. Login to the environment:
3. Edit the `ADMIN_EMAIL`, `SMTP_USER`, `SMTP_PASS`, and `SMTP_SERVICE` values in config.json.

`vagrant ssh`
4. Boot up the box:

4. Once you're on the vagrant machine, change to your working directory:
`vagrant up`

`cd /vagrant`
This step may take a while, and you may see various warnings scroll up
your screen. If you encounter failures at step 6 or 7, make a note of
any failures, and submit them as a bug (see below)

You should see all the files from the git repository here.
5. Login to the environment:

`vagrant ssh`

5. Start the system:
6. Once you're on the vagrant machine, start the system:

`npm start`

7. Open a browser to `http://localhost:3000`

If you encounter any difficulties getting your Vagrant environment up
and running, [file a bug on
Github](https://github.com/HabitRPG/habitrpg/issues/new) and mention
'@thepeopleseason' in the body of your bug report.

## Automatic Startup ##

You can opt to have the initial `vagrant up` command start the entire
system. If you choose to do so, edit the file Vagrantfile in your
HabitRPG directory, and remove the '#' in front of the
HabitRPG directory, and remove the '#' in front of the line

> # autostart_habitrpg
Once the system is up and running, you will need to open another shell
to run `vagrant ssh`, and you won't be able to interactively reload the
server. Because of these deficiencies, you should only autostart the
server if you know what you're doing.

## Notes ##

> `#config.vm.provision :shell, :path => "vagrant.sh"`
By default, running the HabitRPG server will show up on your local
machine on port 3000. If you already have port 3000 mapped to another
service, however, vagrant will use another port between 3000 and 3050 to
forward traffic to the virtual machine.

Once the system is up and running, you will need to open another shell to run
`vagrant ssh`
In creating the vagrant environment, a configuration option
automatically changes the working directory to /vagrant (the location of
the HabitRPG source) on login. If you do not wish to login to vagrant
with that default directory, edit /home/vagrant/.bashrc to remove the
final line ('cd /vagrant').
17 changes: 9 additions & 8 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :

# The vagrant config for HabitRPG. Requires vagrant on your local machine.
# The box fetched will be precise64 located:
# http://files.vagrantup.com/precise64.box
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "thepeopleseason/habitrpg"
config.ssh.forward_agent = true

Vagrant.configure("2") do |config|
config.vm.box = "habitrpg"
config.vm.box_url = "http://dl.dropboxusercontent.com/u/4309797/devel/habitrpg/habitrpg.box"
config.vm.hostname = "habitrpg"
config.vm.network "forwarded_port", guest: 3000, host: 3000
#config.vm.provision :shell, :path => "vagrant.sh"
config.vm.network "forwarded_port", guest: 3000, host: 3000, auto_correct: true
config.vm.usable_port_range = (3000..3050)
config.vm.provision :shell, :path => "vagrant.sh"
end
63 changes: 50 additions & 13 deletions vagrant.sh
Original file line number Diff line number Diff line change
@@ -1,20 +1,57 @@
#!/usr/bin/env bash
#
# HabitRPG provisioning script

update_config=$'Please update config.json with your values\nfor ADMIN_EMAIL, SMTP_USER, SMTP_PASS and SMTP_SERVICE,\nthen run "vagrant reload --provision"'
# function for autostart
function autostart_habitrpg {
update_config=$'Please update config.json with your values\nfor ADMIN_EMAIL, SMTP_USER, SMTP_PASS and SMTP_SERVICE,\nthen run "vagrant reload --provision"'

cd /vagrant
# check if config.json exists, then check if the defaults are still in place
if [ -e config.json ];
then
if grep -Fq 'ADMIN_EMAIL": "[email protected]' config.json;
# check if config.json exists, then check if the defaults are still in place
if [ -e config.json ];
then
if grep -Fq 'ADMIN_EMAIL": "[email protected]' config.json;
then
echo "$update_config";
exit;
else
npm start
fi
else
cp config.json.example config.json;
echo "$update_config";
exit;
else
npm start
fi
else
cp config.json.example config.json;
echo "$update_config";
exit;
fi
}

# Main provisioning
echo Setting up HabitRPG...
echo cd /vagrant >> /home/vagrant/.bashrc

apt-get update -qq

echo Installing Mongodb...
apt-get install -qq mongodb

echo Installing Git...
apt-get install -qq git

echo Installing npm...
apt-get install -qq python-software-properties
apt-add-repository -y ppa:chris-lea/node.js
apt-get update -qq
apt-get install -qq nodejs

cd /vagrant

echo Installing grunt/bower...
npm install -g grunt-cli bower

echo Installing HabitRPG
npm install

echo Seeding Mongodb...
node ./src/seed.js

# Uncomment this line to autostart the habitrpg server when provisioning
# autostart_habitrpg

0 comments on commit 326b65a

Please sign in to comment.