= _F_ree_G_eek _D_ata_B_ase in _R_u_B_y
== Introduction
This webapp is meant to keep track of two main areas:
* volunteers and the time they work
* gizmos and their flow through our organization
In the near future we hope to add:
* classes and who has completed them
* projects (such as building and testing a computer) and who has worked on them
== Dependencies
* git-core
* libjs-prototype
* rails (2.1)
* postgresql
* libpgsql-ruby
* irb
* libxml-ruby
* xmlstarlet
* thin
* ruby1.8-dev
* rubygems
* build-essential
* libgnuplot-ruby
== Installing dependencies on Ubuntu Hardy
The following process works to install the dependencies on Ubuntu Hardy:
sudo apt-get install rubygems git-core postgresql irb libxml-ruby xmlstarlet build-essential libgnuplot-ruby
# It's also necessary install a package from Intrepid:
wget http://mirrors.kernel.org/ubuntu/pool/universe/libp/libpgsql-ruby/libpgsql-ruby1.8_0.7.9.2008.03.18-1_i386.deb
sudo dpkg -i libpgsql-ruby1.8_0.7.9.2008.03.18-1_i386.deb
sudo gem install thin
( Select thin 1.0.0 and eventmachine 0.12.6 )
sudo gem install -v=2.1.0 rails
sudo thin install
sudo /usr/sbin/update-rc.d -f thin defaults
== Installing dependencies on Debian Lenny.
Add my repo (required to install thin) to your sources.list:
$> (wget http://packages.ryan52.info/keyring.gpg && sudo apt-key add keyring.gpg); rm -f keyring.gpg
$> echo "deb http://repos.ryan52.info/thin/ sid main" >> /etc/apt/sources.list.d/ryan52.list
$> apt-get update
$> apt-get install git-core ruby postgresql libpgsql-ruby irb libxml-ruby xmlstarlet thin libgnuplot-ruby
$> apt-get install rails #version 2.1
$> ln -s /usr/share/rails vendor/rails
== Downloading fgdb.rb
$> git clone git://git.ryan52.info/git/fgdb.rb
$> cd fgdb.rb
== Reality Check
check if things are installed, and find out what you need to install:
$> ./script/do_i_have_everything_installed_right
== Database Setup
you need to create and configure the databases:
$> sudo su - postgres -c psql
# now you are in a psql prompt:
=# create user fgdb;
=# create database fgdb_production with owner fgdb;
=# create database fgdb_test with owner fgdb;
=# create database fgdb_development with owner fgdb;
=# \q
# edit config/database.yml-example to your database settings
$> cp config/database.yml-sample config/database.yml
At this point you need to make sure the current Linux has access to databases
you just set up. Considerations for database security are beyond the scope of this document,
but here's how you could set up PostgreSQL to trust any connections made over a local connection
using the fgdb or postgres PostgreSQL user and connecting to one of these database.
Open your "pg_hba.conf" as root and add these lines as the first uncommented lines.
local fgdb_test postgres trust
local fgdb_development postgres trust
local fgdb_production postgres trust
local fgdb_test fgdb trust
local fgdb_development fgdb trust
local fgdb_production fgdb trust
Then reload the database:
sudo /etc/init.d/postgresql-8.3 reload
$> export RAILS_ENV=production
$> export PGUSER=fgdb
$> rake db:schema:load
choose one of the following: skeletal metadata (for production databases), or full test data (for development databases):
$> PGUSER=postgres rake db:metadata:load
$> ./script/make_admin # create the admin user (should only be used to create a contact for yourself, and turn yourself into an admin)
:OR:
$> wget http://dev.freegeek.org/~ryan52/devel_data.sql.gz -O db/devel_data.sql.gz && ./script/load_devel_data # the admin user's password is 'secret'
migrate the database:
$> rake db:migrate
run some tests to see if things look okay:
$> rake db:test:purge
$> rake
if you see any failures or errors,
something is wrong that you should fix or tell us about.
then start the server and browse in to see things working:
# Enter your RAILS_ENV here
$> thin -e production &
$> x-www-browser http://localhost:3000
for a production server running nginx and thin,
continue with the following:
$> apt-get install nginx
$> ln -fs $(readlink -f doc/examples/web/fgdb.conf) /etc/nginx/sites-enabled/fgdb.conf
$> ln -fs $(readlink -f doc/examples/web/fgdb.yml) /etc/thin/
$> rm /etc/nginx/sites-enabled/default
$> chown -R www-data:www-data tmp log public
$> invoke-rc.d nginx restart
$> invoke-rc.d thin restart
::: modify configs to taste :::
::: edit config/environment.rb to say "ENV['RAILS_ENV'] ||= 'production'" :::
== Customizing defaults for new Free Geek locations
The database table 'defaults' holds details which identify a Free Geek location.
These details are initially automatically loaded from the file: db/metadata/defaults.sql
== Upgrading to newest sprint
To upgrade to the newest sprint release:
$> mv current/public/_release.html current/public/release.html
$> invoke-rc.d thin stop
$> mr -c config update
$> cd current
$> RAILS_ENV=production rake db:migrate
$> invoke-rc.d thin start
$> mv public/release.html public/_release.html
== THANKS
in chronological order of commits:
* Martin Chase <mchase@freegeek.org>
* Jeff Schwaber
* Gordon Pederson
* Richard Seymour <rfs@freegeek.org>
* Tim Bauman
* Eric Davis
* Lantz Moore
* Mark Stosberg
* Ryan Niebur <RyanRyan52@gmail.com>