Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Rob Lingle committed May 20, 2009
0 parents commit ea54566
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 0 deletions.
14 changes: 14 additions & 0 deletions README.rdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
= Moonshine_Xsendfile

=== A plugin for Moonshine[http://github.com/railsmachine/moonshine]

A plugin for installing and managing mod_xsendfile[http://tn123.ath.cx/mod_xsendfile] for Apache.

=== Instructions

* <tt>script/plugin install git://github.com/railsmachine/moonshine_xsendfile.git</tt>
* Configure settings if needed (it probably isn't)
configure(:xsendfile => {:x_send_file_allow_above => 'off'})
* Include the plugin and recipe(s) in your Moonshine manifest
plugin :xsendfile
recipe :xsendfile
47 changes: 47 additions & 0 deletions lib/xsendfile.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
module Xsendfile

# Define options for this plugin via the <tt>configure</tt> method
# in your application manifest:
#
# configure(:xsendfile => {:x_send_file_allow_above => 'off'})
#
# Then include the plugin and call the recipe(s) you need:
#
# plugin :xsendfile
# recipe :xsendfile
def xsendfile(options = {})

package 'apache2-threaded-dev', :ensure => :installed

exec 'install_xsendfile',
:cwd => '/tmp',
:command => [
'wget http://tn123.ath.cx/mod_xsendfile/mod_xsendfile.c',
'apxs2 -ci mod_xsendfile.c'
].join(' && '),
:require => package('apache2-threaded-dev'),
:before => service('apache2'),
:creates => '/usr/lib/apache2/modules/mod_xsendfile.so'

file '/etc/apache2/mods-available/xsendfile.conf',
:alias => 'xsendfile_conf',
:content => """
XSendFile #{ options[:x_send_file] || 'on'}
XSendFileAllowAbove #{ options[:x_send_file_allow_above] || 'on'}
#{options[:extra] || ''}
""",
:mode => '644',
:notify => service('apache2')

file '/etc/apache2/mods-available/xsendfile.load',
:alias => 'load_xsendfile',
:content => 'LoadModule xsendfile_module /usr/lib/apache2/modules/mod_xsendfile.so',
:mode => '644',
:require => file('xsendfile_conf'),
:notify => service('apache2')

a2enmod 'xsendfile', :require => file('load_xsendfile')

end

end
3 changes: 3 additions & 0 deletions moonshine/init.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
require "#{File.dirname(__FILE__)}/../lib/xsendfile.rb"

include Xsendfile
8 changes: 8 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
require 'rubygems'
ENV['RAILS_ENV'] = 'test'
ENV['RAILS_ROOT'] ||= File.dirname(__FILE__) + '/../../../..'

require File.join(File.dirname(__FILE__), '..', '..', 'moonshine', 'lib', 'moonshine.rb')
require File.join(File.dirname(__FILE__), '..', 'lib', 'xsendfile.rb')

require 'shadow_puppet/test'
24 changes: 24 additions & 0 deletions spec/xsendfile_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
require File.join(File.dirname(__FILE__), 'spec_helper.rb')

class XsendfileManifest < Moonshine::Manifest
plugin :xsendfile
end

describe "A manifest with the Xsendfile plugin" do

before do
@manifest = XsendfileManifest.new
@manifest.xsendfile
end

it "should be executable" do
@manifest.should be_executable
end

#it "should provide packages/services/files" do
# @manifest.packages.keys.should include 'foo'
# @manifest.files['/etc/foo.conf'].content.should match /foo=true/
# @manifest.execs['newaliases'].refreshonly.should be_true
#end

end

0 comments on commit ea54566

Please sign in to comment.