apacheconf 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/History.txt +3 -0
- data/Manifest.txt +10 -0
- data/README.txt +56 -0
- data/Rakefile +17 -0
- data/bin/apacheconf +3 -0
- data/lib/add_apache_site.rb +44 -0
- data/lib/apacheconf.rb +38 -0
- data/lib/example_site.yml +5 -0
- data/lib/vhost.erb +10 -0
- data/test/test_apacheconf.rb +36 -0
- metadata +89 -0
- metadata.gz.sig +0 -0
data.tar.gz.sig
ADDED
Binary file
|
data/History.txt
ADDED
data/Manifest.txt
ADDED
data/README.txt
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
apacheconf
|
2
|
+
by Alastair Brunton
|
3
|
+
http://www.iformis.com
|
4
|
+
http://www.simplyexcited.co.uk
|
5
|
+
|
6
|
+
== DESCRIPTION:
|
7
|
+
|
8
|
+
This is a simple apache configuration generator for making it easier to setup and enable sites
|
9
|
+
within the ubuntu / debian apache configuration structure.
|
10
|
+
|
11
|
+
== FEATURES/PROBLEMS:
|
12
|
+
|
13
|
+
* Ability to add a virtual host from a YAML file.
|
14
|
+
* Enable / Disable the virtual host and reload the web server.
|
15
|
+
|
16
|
+
== SYNOPSIS:
|
17
|
+
|
18
|
+
config.yml.example includes example of what can be defined.
|
19
|
+
|
20
|
+
apachconf site.yml
|
21
|
+
apacheconf --overwrite site.yml (overwrites a configuration if it already exists)
|
22
|
+
apacheconf --enable site.yml (enables the virtual host and reloads apache)
|
23
|
+
apacheconf --disable site.yml (disables the virtual host and reloads apache)
|
24
|
+
|
25
|
+
== REQUIREMENTS:
|
26
|
+
|
27
|
+
* Apache2 installed and configured to load vhosts using the sites-available and sites-enabled directories.
|
28
|
+
|
29
|
+
== INSTALL:
|
30
|
+
|
31
|
+
* sudo gem install apacheconf
|
32
|
+
|
33
|
+
== LICENSE:
|
34
|
+
|
35
|
+
(The MIT License)
|
36
|
+
|
37
|
+
Copyright (c) 2007 Alastair Brunton
|
38
|
+
|
39
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
40
|
+
a copy of this software and associated documentation files (the
|
41
|
+
'Software'), to deal in the Software without restriction, including
|
42
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
43
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
44
|
+
permit persons to whom the Software is furnished to do so, subject to
|
45
|
+
the following conditions:
|
46
|
+
|
47
|
+
The above copyright notice and this permission notice shall be
|
48
|
+
included in all copies or substantial portions of the Software.
|
49
|
+
|
50
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
51
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
52
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
53
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
54
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
55
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
56
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'hoe'
|
5
|
+
require './lib/apacheconf.rb'
|
6
|
+
|
7
|
+
Hoe.new('apacheconf', Apacheconf::VERSION) do |p|
|
8
|
+
p.rubyforge_name = 'apacheconf'
|
9
|
+
p.author = 'Alastair Brunton'
|
10
|
+
p.email = 'info@simplyexcited.co.uk'
|
11
|
+
p.summary = 'Simple config generator for apache the debian way.'
|
12
|
+
# p.description = p.paragraphs_of('README.txt', 2..5).join("\n\n")
|
13
|
+
# p.url = p.paragraphs_of('README.txt', 0).first.split(/\n/)[1..-1]
|
14
|
+
p.changes = p.paragraphs_of('History.txt', 0..1).join("\n\n")
|
15
|
+
end
|
16
|
+
|
17
|
+
# vim: syntax=Ruby
|
data/bin/apacheconf
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# This is the main meat of the apache config generator
|
3
|
+
# Author: Alastair Brunton
|
4
|
+
|
5
|
+
%w(erb yaml).each &method(:require)
|
6
|
+
|
7
|
+
require "#{File.dirname(__FILE__)}/apacheconf"
|
8
|
+
include ApacheHelper
|
9
|
+
|
10
|
+
if ARGV.include? '--example'
|
11
|
+
example = file:'example.yml'
|
12
|
+
error open(example).read
|
13
|
+
end
|
14
|
+
|
15
|
+
error "Usage: add_apache_site [options] [config file]" if ARGV.empty?
|
16
|
+
|
17
|
+
# pretty cool overwrite thing here
|
18
|
+
overwrite = !(%w(-y -o -f --force --overwrite) & ARGV).empty?
|
19
|
+
should_enable = !(%w(--enable --on) & ARGV).empty?
|
20
|
+
should_disable = !(%w(--disable --off) & ARGV).empty?
|
21
|
+
|
22
|
+
config = YAML.load_file(ARGV.pop || 'vhost.yml')
|
23
|
+
template = file:'vhost.erb'
|
24
|
+
|
25
|
+
if should_enable
|
26
|
+
enable(config)
|
27
|
+
reload_apache
|
28
|
+
error "=> #{config['site_name']} enabled"
|
29
|
+
end
|
30
|
+
|
31
|
+
if should_disable
|
32
|
+
disable(config)
|
33
|
+
reload_apache
|
34
|
+
error "=> #{config['site_name']} disabled"
|
35
|
+
end
|
36
|
+
|
37
|
+
if File.exists?(out_file = get_out_file(config)) && !overwrite
|
38
|
+
error "=> #{out_file} already exists, won't overwrite it. Quitting."
|
39
|
+
else
|
40
|
+
open(out_file, 'w+').write(ERB.new(File.read(template), nil, '>').result(binding))
|
41
|
+
puts "=> Wrote #{out_file} successfully."
|
42
|
+
end
|
43
|
+
|
44
|
+
|
data/lib/apacheconf.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
class Apacheconf
|
2
|
+
VERSION = '1.0.0'
|
3
|
+
end
|
4
|
+
|
5
|
+
module ApacheHelper
|
6
|
+
|
7
|
+
DEFAULT_APACHE = '/etc/apache2'
|
8
|
+
|
9
|
+
def error(message) puts(message) || exit end
|
10
|
+
|
11
|
+
# Great way to solve the problem of different file paths.
|
12
|
+
def file(file) "#{File.dirname(__FILE__)}/#{file}" end
|
13
|
+
|
14
|
+
# Get the file where apache will write the vhost configuration.
|
15
|
+
def get_out_file(config)
|
16
|
+
config['apache_dir'] ||= DEFAULT_APACHE
|
17
|
+
"#{config['apache_dir']}/sites-available/#{config['site_name']}"
|
18
|
+
end
|
19
|
+
|
20
|
+
# Enable the vhost (run with the --enable or --on flag)
|
21
|
+
def enable(config)
|
22
|
+
config['apache_dir'] ||= DEFAULT_APACHE
|
23
|
+
`sudo ln -s #{config['apache_dir']}/sites-available/#{config['site_name']} #{config['apache_dir']}/sites-enabled/#{config['site_name']}`
|
24
|
+
end
|
25
|
+
|
26
|
+
# Disable the vhost (run with --disable or --off flag)
|
27
|
+
def disable(config)
|
28
|
+
config['apache_dir'] ||= DEFAULT_APACHE
|
29
|
+
`sudo rm #{config['apache_dir']}/sites-enabled/#{config['site_name']}`
|
30
|
+
end
|
31
|
+
|
32
|
+
|
33
|
+
# This reloads apache assuming that this script exists for controlling it!
|
34
|
+
def reload_apache
|
35
|
+
`sudo /etc/init.d/apache2 reload`
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
data/lib/vhost.erb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# Tests for the apacheconf generator.
|
2
|
+
# Need to think about how best to do this.
|
3
|
+
require 'test/unit'
|
4
|
+
require File.dirname(__FILE__) + "/../lib/apacheconf"
|
5
|
+
class TestApacheconf < Test::Unit::TestCase
|
6
|
+
|
7
|
+
include ApacheHelper
|
8
|
+
|
9
|
+
|
10
|
+
def test_out_file
|
11
|
+
out_file = get_out_file(get_test_config)
|
12
|
+
assert_equal('/etc/apache2/sites-available/funsite', out_file)
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_no_args
|
16
|
+
exec_path = get_exec_path
|
17
|
+
op = `ruby #{exec_path}`
|
18
|
+
assert_equal("Usage: add_apache_site [options] [config file]\n", op)
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def get_test_config
|
24
|
+
{
|
25
|
+
'site_name' => 'funsite',
|
26
|
+
'document_root' => '/var/www/apps/funsite',
|
27
|
+
'server_name' => 'funsite.com',
|
28
|
+
'server_alias' => 'www.funsite.com'
|
29
|
+
}
|
30
|
+
end
|
31
|
+
|
32
|
+
def get_exec_path
|
33
|
+
File.dirname(__FILE__) + '/../bin/apacheconf'
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
metadata
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
rubygems_version: 0.9.4
|
3
|
+
specification_version: 1
|
4
|
+
name: apacheconf
|
5
|
+
version: !ruby/object:Gem::Version
|
6
|
+
version: 1.0.0
|
7
|
+
date: 2007-09-27 00:00:00 +01:00
|
8
|
+
summary: Simple config generator for apache the debian way.
|
9
|
+
require_paths:
|
10
|
+
- lib
|
11
|
+
email: info@simplyexcited.co.uk
|
12
|
+
homepage: http://www.zenspider.com/ZSS/Products/apacheconf/
|
13
|
+
rubyforge_project: apacheconf
|
14
|
+
description: The author was too lazy to write a description
|
15
|
+
autorequire:
|
16
|
+
default_executable:
|
17
|
+
bindir: bin
|
18
|
+
has_rdoc: true
|
19
|
+
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">"
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.0.0
|
24
|
+
version:
|
25
|
+
platform: ruby
|
26
|
+
signing_key:
|
27
|
+
cert_chain:
|
28
|
+
- |
|
29
|
+
-----BEGIN CERTIFICATE-----
|
30
|
+
MIIDYDCCAkigAwIBAgIBADANBgkqhkiG9w0BAQUFADBWMQ0wCwYDVQQDDARpbmZv
|
31
|
+
MR0wGwYKCZImiZPyLGQBGRYNc2ltcGx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tmVjU+vg/G/Bfl5nXuHjbVFm95SDohYyXyZjRjumCLZGxh5SQSXgQ+ddo2Xz2
|
47
|
+
vE995UihOI18WiXfm9QrgBPOhxIcU5274MKP2YaqcjRQJ6nj1E3gfYrJrgnB9TPe
|
48
|
+
hono1A==
|
49
|
+
-----END CERTIFICATE-----
|
50
|
+
|
51
|
+
post_install_message:
|
52
|
+
authors:
|
53
|
+
- Alastair Brunton
|
54
|
+
files:
|
55
|
+
- History.txt
|
56
|
+
- Manifest.txt
|
57
|
+
- README.txt
|
58
|
+
- Rakefile
|
59
|
+
- bin/apacheconf
|
60
|
+
- lib/add_apache_site.rb
|
61
|
+
- lib/apacheconf.rb
|
62
|
+
- lib/example_site.yml
|
63
|
+
- lib/vhost.erb
|
64
|
+
- test/test_apacheconf.rb
|
65
|
+
test_files:
|
66
|
+
- test/test_apacheconf.rb
|
67
|
+
rdoc_options:
|
68
|
+
- --main
|
69
|
+
- README.txt
|
70
|
+
extra_rdoc_files:
|
71
|
+
- History.txt
|
72
|
+
- Manifest.txt
|
73
|
+
- README.txt
|
74
|
+
executables:
|
75
|
+
- apacheconf
|
76
|
+
extensions: []
|
77
|
+
|
78
|
+
requirements: []
|
79
|
+
|
80
|
+
dependencies:
|
81
|
+
- !ruby/object:Gem::Dependency
|
82
|
+
name: hoe
|
83
|
+
version_requirement:
|
84
|
+
version_requirements: !ruby/object:Gem::Version::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: 1.3.0
|
89
|
+
version:
|
metadata.gz.sig
ADDED
Binary file
|