diff --git a/README b/README deleted file mode 100644 index e69de29..0000000 diff --git a/README.md b/README.md new file mode 100644 index 0000000..61d238c --- /dev/null +++ b/README.md @@ -0,0 +1,33 @@ +# Apache Config Generator + +Programmatically construct your Apache configuration using a powerful DSL built in Ruby. + +## Installation + +`gem install apache-config-generator` + +## Usage + +Run `apache-configurator ` to create a new directory to hold your config files. +A Rakefile and config.yml file will also be generated. + +## Building a config file + +Configs center around the Apache::Config.build method: + + Apache::Config.build('sites-available/my-site.conf') do + server_name 'my-cool-website.cool.wow' + document_root '/var/www/my-cool-website' + + directory '/' do + options :follow_sym_links, :indexes + allow_from_all + end + + location_match %r{^/secret} do + deny_from_all + + basic_authentication "My secret", '/etc/apache2/users/global.users', :user => :john + satisfy :any + end + end diff --git a/bin/apache-configurator b/bin/apache-configurator new file mode 100755 index 0000000..6905871 --- /dev/null +++ b/bin/apache-configurator @@ -0,0 +1,12 @@ +#!/usr/bin/env ruby + +require 'fileutils' + +if File.directory? ARGV[0] + puts "You can't overwrite an existing directory." + exit 1 +end + +FileUtils.cp_r File.expand_path(File.join(File.dirname(__FILE__), '..', 'skel')), ARGV[0] +FileUtils.mkdir_p File.join(ARGV[0], 'source') +FileUtils.mkdir_p File.join(ARGV[0], 'conf.d') diff --git a/skel/Rakefile b/skel/Rakefile new file mode 100644 index 0000000..ce47e50 --- /dev/null +++ b/skel/Rakefile @@ -0,0 +1,4 @@ +require 'rubygems' + +require 'apache-config-generator' +require 'apache/rake/create' diff --git a/skel/config.yml b/skel/config.yml new file mode 100644 index 0000000..725c336 --- /dev/null +++ b/skel/config.yml @@ -0,0 +1,3 @@ +source: "source" +destination: "conf.d" +rotate_logs_path: '/path/to/apache/bin/rotatelogs'