Permalink
Browse files

initial commit

  • Loading branch information...
0 parents commit ea5456694f70394424096ede42fdf05506feeab6 Rob Lingle committed May 20, 2009
Showing with 96 additions and 0 deletions.
  1. +14 −0 README.rdoc
  2. +47 −0 lib/xsendfile.rb
  3. +3 −0 moonshine/init.rb
  4. +8 −0 spec/spec_helper.rb
  5. +24 −0 spec/xsendfile_spec.rb
@@ -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
@@ -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
@@ -0,0 +1,3 @@
+require "#{File.dirname(__FILE__)}/../lib/xsendfile.rb"
+
+include Xsendfile
@@ -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'
@@ -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.