== Cheese

Cheese is a set of ruby scripts supplied with all Written Path
Virtual Cheesey Servers but available to all under the MIT license.
They reduce the steps needed to administrate a web server.

Currently this script is executed server side, but we're looking
into using Capistrano to manage it instead.

Cheese Tools can:

* Add nginx virtual hosts
* Replace nginx virtual hosts
* Remove nginx virtual hosts
* Create subversion repositories
* Remove subversion repositories
* Set access rights on subversion repositories
* Create mysql/pgsql databases
* Delete mysql/pgsql databases

Cheese Tools will be able to:

* Configure monit to watch your sites and svnserve
* Configure a scheduled backup of your sites and source to s3


== Requirements

Gems:
* Rubygems
* OptionParser
* Highline

Nginx Config
If you are using this on an existing nginx.conf file, you must wrap your vhosts like so:

#### VHOST something.com BEGIN ####
server ...

#### VHOST something.com END ####

#### PROXY something.com BEGIN ####
upstream something_com_mongrel ...

#### PROXY something.com END ####

and the proxies that each use like so:


This is temporary until I improve my regex skills somewhat, or someone
changes it for me.

== Setup

Before you can use Cheese you need to run cheese --setup, you will be
notified of this if you forget, however, this can be re-run if you
wish to change any options you have previously set.

The Cheese setup utility:

* Asks what type of setup you have (out of the supported sets)
* Saves a default source code management username and password



== Switches

-L or --list-vhosts
List the vhosts contained in the /etc/nginx/nginx.conf file

--setup
Run the setup utility which saves preferences to /etc/cheese/cheese.conf

--domain domain-name.com
Set the domain name to use
--mongrel-threads
Let Cheese Tools know how many threads you want to run

--remove
Remove this vhost and the subversion repository

--svn-read-all
Set svnserve to allow anonymous read on the subversion repository

--pgsql
Use PostgreSQL instead of MySQL which is the default

--skip-nginx
Don't add a vhost or restart nginx
--skip-svn
Don't create a subversion repository or attempt to add files to one
--skip-mongrel-config
Don't create a mongrel_cluster.yml config file
--skip-database
Don't create the database
--only-nginx
Only add/replace a vhost and restart nginx
--only-svn
Only create a subversion repository and standard file structure
--only-mongrel-config
Only create a mongrel_cluster.yml config file
--only-database
Only create the database

== Usage

To create a new web application with a subversion repository which stores
the source and a mongrel_cluster config:

./cheese --domain candidmush.com --mongrel-threads 2

The steps cheese will take are:

* Add a vhost to /etc/nginx/nginx.conf
* Add a mongrel proxy declaration to /etc/nginx/nginx.conf
* Create a subversion repository in /var/src/candidmush.com
* The standard structure of branches/tags/trunk will be added
* Add a Cap config file to trunk/config/deploy.rb
* Add a mongrel_cluster config to trunk/config/mongrel_cluster.yml
* Start mongrel_cluster for this server
* Restart nginx


== Details

The port range to use for mongrel_cluster will be determined by finding
the highest port range used by other vhosts and incrementing it by 10.

If the vhost in nginx for the domain you are adding already exists,
Cheese Tools will replace it rather than add another.