Skip to content

Commit

Permalink
Moving the cookbook to the top level
Browse files Browse the repository at this point in the history
  • Loading branch information
bigfleet committed Jul 11, 2009
1 parent c1e37ea commit c90a16e
Show file tree
Hide file tree
Showing 6 changed files with 181 additions and 0 deletions.
7 changes: 7 additions & 0 deletions browsercms/files/default/blank_rails_template.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
run "rm public/index.html"
gem "browser_cms"
run "cp /var/www/browsercms/database.yml config/database.yml"
rake("db:create")
route "map.routes_for_browser_cms"
generate(:browser_cms)
rake("db:migrate")
8 changes: 8 additions & 0 deletions browsercms/files/default/demo_rails_template.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
run "rm public/index.html"
gem "browser_cms"
run "cp /var/www/browsercms/database.yml config/database.yml"
rake("db:create")
route "map.routes_for_browser_cms"
generate(:browser_cms)
generate(:browser_cms_demo_site)
rake("db:migrate")
99 changes: 99 additions & 0 deletions browsercms/recipes/default.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
#
# Cookbook Name:: browsercms
# Recipe:: default
#
# Copyright 2009, Kane Reid Securities Group, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

include_recipe 'mysql'
include_recipe 'apache2'
include_recipe 'passenger'
include_recipe 'gems'

browsercms = node[:browsercms]
user = node[:user]

execute "download-browsercms" do
command "cd /home/#{user}; git clone git://github.com/browsermedia/browsercms.git"
creates "/home/#{user}/browsercms"
action :run
end

execute "install-browsercms" do
command "cd /home/#{user}/browsercms; rake cms:install"
creates "/usr/lib/ruby/gems/1.8/gems/browser_cms_blog_module-3.0.0"
action :run
end


directory "/var/log/browsercms" do
action :create
owner "root"
group "admin"
mode 0775
end

directory "/var/www/browsercms" do
action :create
owner user
group "www-data"
mode 0775
end

directory "/var/www/browsercms/site" do
action :create
owner user
group "www-data"
mode 0775
end

template "/var/www/browsercms/database.yml" do
owner node[:user]
mode 0644
source "database.yml.erb"
variables({
:name => "browsercms",
:passwd => "J4LZE1XYTX30QYL"
})
end

execute "setup-browsercms" do
command "umask 002 && rails site -d mysql -m /var/chef/cookbooks/browsercms/files/default/#{browsercms["style"]}_rails_template.rb > results.txt"
creates "/var/www/browsercms/site/public/"
group "www-data"
cwd "/var/www/browsercms"
user "www-data"
action :run
end

passenger_app "public-site" do
conf( {:env => "production",
:server_name => browsercms["server_name"],
:template => "public.conf.erb",
:docroot => browsercms["docroot"],
:enable => true
} )
end

passenger_app "admin-site" do
conf( {:env => "production",
:server_name => browsercms["server_name"],
:template => "admin.conf.erb",
:docroot => browsercms["docroot"],
:enable => true
} )
end

# append config.action_controller.page_cache_directory = RAILS_ROOT + "/public/cache/" to config/environments/production.rb
24 changes: 24 additions & 0 deletions browsercms/templates/default/admin.conf.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<VirtualHost *:80>
ServerName cms.<%= @server_name %>
DocumentRoot <%= @docroot %>
RailsAllowModRewrite on
RailsBaseURI /
RailsMaxPoolSize <%= @max_pool_size %>
RailsPoolIdleTime 3600
RailsEnv 'production'

ErrorLog /var/log/browsercms/admin_site_error.log
CustomLog /var/log/browsercms/admin_site_access.log combined

ErrorDocument 404 /404.html
ErrorDocument 500 /500.html

RewriteEngine On

<Directory <%= @docroot %>>
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
13 changes: 13 additions & 0 deletions browsercms/templates/default/database.yml.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
defaults: &defaults
adapter: mysql
host: localhost
username: root
password: <%= @passwd %>

production:
database: browsercms
<<: *defaults

development:
database: browsercms
<<: *defaults
30 changes: 30 additions & 0 deletions browsercms/templates/default/public.conf.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<VirtualHost *:80>
ServerName <%= @server_name %>
DocumentRoot <%= @docroot %>
RailsAllowModRewrite on
RailsBaseURI /
RailsMaxPoolSize <%= @max_pool_size %>
RailsPoolIdleTime 3600
RailsEnv 'production'

ErrorLog /var/log/browsercms/public_site_error.log
CustomLog /var/log/browsercms/public_site_access.log combined

ErrorDocument 404 /404.html
ErrorDocument 500 /500.html

RewriteEngine On

# Uncomment for rewrite debugging
#RewriteLog /var/sites/mysite/log/rewrite.log
#RewriteLogLevel 9

#apache should serve cached pages
RewriteRule ^/$ /cache/index.html [QSA]
RewriteRule ^([^.]+)$ /cache/$1.html [QSA]

<Directory <%= @docroot %>>
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

0 comments on commit c90a16e

Please sign in to comment.