tomahawk 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/apache2.conf +233 -0
- data/lib/tomahawk/config_parser.rb +3 -3
- data/lib/tomahawk/directive_groups.rb +6 -1
- data/lib/tomahawk/directive_groups/base.rb +5 -1
- data/lib/tomahawk/directive_groups/generic_directive_group.rb +13 -0
- data/lib/tomahawk/generators.rb +2 -1
- data/lib/tomahawk/generators/base.rb +3 -3
- data/lib/tomahawk/generators/generic_directive_group.rb +9 -0
- data/lib/tomahawk/version.rb +1 -1
- data/spec/lib/tomahawk/directive_groups_spec.rb +6 -2
- metadata +21 -25
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 28d52482bb38d14c3b4afd0b304c9971b4bcac2b
|
4
|
+
data.tar.gz: 7764226f5dbd0ac2eb73d34818671cf42a596373
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a55c7f7762b1cc6995f8e5b404caed5576aa0a06b3af342b1689a4648f248d72614bff1c39d8382c5dd709292b2f7832dc7368bbad13869d2bb7bd602bcd207c
|
7
|
+
data.tar.gz: d830a6c4cb45e48feb5489f3c294887ff1cbad3a31324ee64c148b0b565e8d643fa44b391b91b39ff2888447184f5898e9e3607aad84b8935f81721f07ed0ec7
|
data/apache2.conf
ADDED
@@ -0,0 +1,233 @@
|
|
1
|
+
#
|
2
|
+
# Based upon the NCSA server configuration files originally by Rob McCool.
|
3
|
+
#
|
4
|
+
# This is the main Apache server configuration file. It contains the
|
5
|
+
# configuration directives that give the server its instructions.
|
6
|
+
# See http://httpd.apache.org/docs/2.2/ for detailed information about
|
7
|
+
# the directives.
|
8
|
+
#
|
9
|
+
# Do NOT simply read the instructions in here without understanding
|
10
|
+
# what they do. They're here only as hints or reminders. If you are unsure
|
11
|
+
# consult the online docs. You have been warned.
|
12
|
+
#
|
13
|
+
# The configuration directives are grouped into three basic sections:
|
14
|
+
# 1. Directives that control the operation of the Apache server process as a
|
15
|
+
# whole (the 'global environment').
|
16
|
+
# 2. Directives that define the parameters of the 'main' or 'default' server,
|
17
|
+
# which responds to requests that aren't handled by a virtual host.
|
18
|
+
# These directives also provide default values for the settings
|
19
|
+
# of all virtual hosts.
|
20
|
+
# 3. Settings for virtual hosts, which allow Web requests to be sent to
|
21
|
+
# different IP addresses or hostnames and have them handled by the
|
22
|
+
# same Apache server process.
|
23
|
+
#
|
24
|
+
# Configuration and logfile names: If the filenames you specify for many
|
25
|
+
# of the server's control files begin with "/" (or "drive:/" for Win32), the
|
26
|
+
# server will use that explicit path. If the filenames do *not* begin
|
27
|
+
# with "/", the value of ServerRoot is prepended -- so "foo.log"
|
28
|
+
# with ServerRoot set to "/etc/apache2" will be interpreted by the
|
29
|
+
# server as "/etc/apache2/foo.log".
|
30
|
+
#
|
31
|
+
|
32
|
+
### Section 1: Global Environment
|
33
|
+
#
|
34
|
+
# The directives in this section affect the overall operation of Apache,
|
35
|
+
# such as the number of concurrent requests it can handle or where it
|
36
|
+
# can find its configuration files.
|
37
|
+
#
|
38
|
+
|
39
|
+
#
|
40
|
+
# ServerRoot: The top of the directory tree under which the server's
|
41
|
+
# configuration, error, and log files are kept.
|
42
|
+
#
|
43
|
+
# NOTE! If you intend to place this on an NFS (or otherwise network)
|
44
|
+
# mounted filesystem then please read the LockFile documentation (available
|
45
|
+
# at <URL:http://httpd.apache.org/docs/2.2/mod/mpm_common.html#lockfile>);
|
46
|
+
# you will save yourself a lot of trouble.
|
47
|
+
#
|
48
|
+
# Do NOT add a slash at the end of the directory path.
|
49
|
+
#
|
50
|
+
#ServerRoot "/etc/apache2"
|
51
|
+
|
52
|
+
#
|
53
|
+
# The accept serialization lock file MUST BE STORED ON A LOCAL DISK.
|
54
|
+
#
|
55
|
+
LockFile ${APACHE_LOCK_DIR}/accept.lock
|
56
|
+
|
57
|
+
#
|
58
|
+
# PidFile: The file in which the server should record its process
|
59
|
+
# identification number when it starts.
|
60
|
+
# This needs to be set in /etc/apache2/envvars
|
61
|
+
#
|
62
|
+
PidFile ${APACHE_PID_FILE}
|
63
|
+
|
64
|
+
#
|
65
|
+
# Timeout: The number of seconds before receives and sends time out.
|
66
|
+
#
|
67
|
+
Timeout 15
|
68
|
+
|
69
|
+
#
|
70
|
+
# KeepAlive: Whether or not to allow persistent connections (more than
|
71
|
+
# one request per connection). Set to "Off" to deactivate.
|
72
|
+
#
|
73
|
+
KeepAlive On
|
74
|
+
|
75
|
+
#
|
76
|
+
# MaxKeepAliveRequests: The maximum number of requests to allow
|
77
|
+
# during a persistent connection. Set to 0 to allow an unlimited amount.
|
78
|
+
# We recommend you leave this number high, for maximum performance.
|
79
|
+
#
|
80
|
+
MaxKeepAliveRequests 10
|
81
|
+
|
82
|
+
#
|
83
|
+
# KeepAliveTimeout: Number of seconds to wait for the next request from the
|
84
|
+
# same client on the same connection.
|
85
|
+
#
|
86
|
+
KeepAliveTimeout 2
|
87
|
+
|
88
|
+
##
|
89
|
+
## Server-Pool Size Regulation (MPM specific)
|
90
|
+
##
|
91
|
+
|
92
|
+
# prefork MPM
|
93
|
+
# StartServers: number of server processes to start
|
94
|
+
# MinSpareServers: minimum number of server processes which are kept spare
|
95
|
+
# MaxSpareServers: maximum number of server processes which are kept spare
|
96
|
+
# MaxClients: maximum number of server processes allowed to start
|
97
|
+
# MaxRequestsPerChild: maximum number of requests a server process serves
|
98
|
+
<IfModule mpm_prefork_module>
|
99
|
+
StartServers 5
|
100
|
+
MinSpareServers 5
|
101
|
+
MaxSpareServers 10
|
102
|
+
MaxClients 90
|
103
|
+
MaxRequestsPerChild 200
|
104
|
+
</IfModule>
|
105
|
+
|
106
|
+
# worker MPM
|
107
|
+
# StartServers: initial number of server processes to start
|
108
|
+
# MaxClients: maximum number of simultaneous client connections
|
109
|
+
# MinSpareThreads: minimum number of worker threads which are kept spare
|
110
|
+
# MaxSpareThreads: maximum number of worker threads which are kept spare
|
111
|
+
# ThreadLimit: ThreadsPerChild can be changed to this maximum value during a
|
112
|
+
# graceful restart. ThreadLimit can only be changed by stopping
|
113
|
+
# and starting Apache.
|
114
|
+
# ThreadsPerChild: constant number of worker threads in each server process
|
115
|
+
# MaxRequestsPerChild: maximum number of requests a server process serves
|
116
|
+
<IfModule mpm_worker_module>
|
117
|
+
StartServers 2
|
118
|
+
MinSpareThreads 25
|
119
|
+
MaxSpareThreads 75
|
120
|
+
ThreadLimit 64
|
121
|
+
ThreadsPerChild 25
|
122
|
+
MaxClients 100
|
123
|
+
MaxRequestsPerChild 0
|
124
|
+
</IfModule>
|
125
|
+
|
126
|
+
# event MPM
|
127
|
+
# StartServers: initial number of server processes to start
|
128
|
+
# MaxClients: maximum number of simultaneous client connections
|
129
|
+
# MinSpareThreads: minimum number of worker threads which are kept spare
|
130
|
+
# MaxSpareThreads: maximum number of worker threads which are kept spare
|
131
|
+
# ThreadsPerChild: constant number of worker threads in each server process
|
132
|
+
# MaxRequestsPerChild: maximum number of requests a server process serves
|
133
|
+
<IfModule mpm_event_module>
|
134
|
+
StartServers 2
|
135
|
+
MaxClients 150
|
136
|
+
MinSpareThreads 25
|
137
|
+
MaxSpareThreads 75
|
138
|
+
ThreadLimit 64
|
139
|
+
ThreadsPerChild 25
|
140
|
+
MaxRequestsPerChild 0
|
141
|
+
</IfModule>
|
142
|
+
|
143
|
+
# These need to be set in /etc/apache2/envvars
|
144
|
+
User ${APACHE_RUN_USER}
|
145
|
+
Group ${APACHE_RUN_GROUP}
|
146
|
+
|
147
|
+
#
|
148
|
+
# AccessFileName: The name of the file to look for in each directory
|
149
|
+
# for additional configuration directives. See also the AllowOverride
|
150
|
+
# directive.
|
151
|
+
#
|
152
|
+
|
153
|
+
AccessFileName .htaccess
|
154
|
+
|
155
|
+
#
|
156
|
+
# The following lines prevent .htaccess and .htpasswd files from being
|
157
|
+
# viewed by Web clients.
|
158
|
+
#
|
159
|
+
<Files ~ "^\.ht">
|
160
|
+
Order allow,deny
|
161
|
+
Deny from all
|
162
|
+
Satisfy all
|
163
|
+
</Files>
|
164
|
+
|
165
|
+
#
|
166
|
+
# DefaultType is the default MIME type the server will use for a document
|
167
|
+
# if it cannot otherwise determine one, such as from filename extensions.
|
168
|
+
# If your server contains mostly text or HTML documents, "text/plain" is
|
169
|
+
# a good value. If most of your content is binary, such as applications
|
170
|
+
# or images, you may want to use "application/octet-stream" instead to
|
171
|
+
# keep browsers from trying to display binary files as though they are
|
172
|
+
# text.
|
173
|
+
#
|
174
|
+
DefaultType text/plain
|
175
|
+
|
176
|
+
|
177
|
+
#
|
178
|
+
# HostnameLookups: Log the names of clients or just their IP addresses
|
179
|
+
# e.g., www.apache.org (on) or 204.62.129.132 (off).
|
180
|
+
# The default is off because it'd be overall better for the net if people
|
181
|
+
# had to knowingly turn this feature on, since enabling it means that
|
182
|
+
# each client request will result in AT LEAST one lookup request to the
|
183
|
+
# nameserver.
|
184
|
+
#
|
185
|
+
HostnameLookups Off
|
186
|
+
|
187
|
+
# ErrorLog: The location of the error log file.
|
188
|
+
# If you do not specify an ErrorLog directive within a <VirtualHost>
|
189
|
+
# container, error messages relating to that virtual host will be
|
190
|
+
# logged here. If you *do* define an error logfile for a <VirtualHost>
|
191
|
+
# container, that host's errors will be logged there and not here.
|
192
|
+
#
|
193
|
+
ErrorLog ${APACHE_LOG_DIR}/error.log
|
194
|
+
|
195
|
+
#
|
196
|
+
# LogLevel: Control the number of messages logged to the error_log.
|
197
|
+
# Possible values include: debug, info, notice, warn, error, crit,
|
198
|
+
# alert, emerg.
|
199
|
+
#
|
200
|
+
LogLevel warn
|
201
|
+
|
202
|
+
# Include module configuration:
|
203
|
+
Include mods-enabled/*.load
|
204
|
+
Include mods-enabled/*.conf
|
205
|
+
|
206
|
+
# Include ports listing
|
207
|
+
Include ports.conf
|
208
|
+
|
209
|
+
#
|
210
|
+
# The following directives define some format nicknames for use with
|
211
|
+
# a CustomLog directive (see below).
|
212
|
+
# If you are behind a reverse proxy, you might want to change %h into %{X-Forwarded-For}i
|
213
|
+
#
|
214
|
+
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
|
215
|
+
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
|
216
|
+
LogFormat "%h %l %u %t \"%r\" %>s %O" common
|
217
|
+
LogFormat "%{Referer}i -> %U" referer
|
218
|
+
LogFormat "%{User-agent}i" agent
|
219
|
+
|
220
|
+
# Include of directories ignores editors' and dpkg's backup files,
|
221
|
+
# see README.Debian for details.
|
222
|
+
|
223
|
+
# Include generic snippets of statements
|
224
|
+
Include conf.d/
|
225
|
+
|
226
|
+
# Include the virtual host configurations:
|
227
|
+
Include sites-enabled/
|
228
|
+
|
229
|
+
|
230
|
+
#UseCanonicalName Off
|
231
|
+
#VirtualDocumentRoot /websites/%-2.0.%-1/
|
232
|
+
|
233
|
+
ExtendedStatus On
|
@@ -14,10 +14,10 @@ module Tomahawk
|
|
14
14
|
private
|
15
15
|
|
16
16
|
def parse
|
17
|
-
|
17
|
+
|
18
18
|
directive_groups = [Tomahawk::DirectiveGroups::HTTPd.new]
|
19
19
|
|
20
|
-
@config_lines.each do |line|
|
20
|
+
@config_lines.grep(/^\s*[^#]/).each do |line|
|
21
21
|
|
22
22
|
is_end_tag?(line) do
|
23
23
|
directive_groups.pop
|
@@ -72,4 +72,4 @@ module Tomahawk
|
|
72
72
|
false
|
73
73
|
end
|
74
74
|
end
|
75
|
-
end
|
75
|
+
end
|
@@ -2,6 +2,7 @@ require_relative 'directive_groups/base'
|
|
2
2
|
require_relative 'directive_groups/httpd'
|
3
3
|
require_relative 'directive_groups/virtual_host'
|
4
4
|
require_relative 'directive_groups/directory'
|
5
|
+
require_relative 'directive_groups/generic_directive_group'
|
5
6
|
|
6
7
|
module Tomahawk
|
7
8
|
module DirectiveGroups
|
@@ -11,6 +12,10 @@ module Tomahawk
|
|
11
12
|
directive_group_name = String(directive_group_name)
|
12
13
|
|
13
14
|
Tomahawk::DirectiveGroups.const_get(directive_group_name)
|
15
|
+
rescue NameError
|
16
|
+
Class.new(Tomahawk::DirectiveGroups::GenericDirectiveGroup) do
|
17
|
+
define_method(:name) { directive_group_name }
|
18
|
+
end
|
14
19
|
end
|
15
20
|
end
|
16
|
-
end
|
21
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Tomahawk
|
2
|
+
module DirectiveGroups
|
3
|
+
class GenericDirectiveGroup < Base
|
4
|
+
def to_str(generator = Generators::GenericDirectiveGroup)
|
5
|
+
generator.new(self).to_s
|
6
|
+
end
|
7
|
+
|
8
|
+
def name
|
9
|
+
raise NameError, "Generic directive group found, but no name set – don't know how to proceed"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/lib/tomahawk/generators.rb
CHANGED
@@ -2,6 +2,7 @@ require_relative 'generators/base'
|
|
2
2
|
require_relative 'generators/httpd'
|
3
3
|
require_relative 'generators/virtual_host'
|
4
4
|
require_relative 'generators/directory'
|
5
|
+
require_relative 'generators/generic_directive_group'
|
5
6
|
|
6
7
|
module Tomahawk
|
7
8
|
module Generators
|
@@ -9,4 +10,4 @@ module Tomahawk
|
|
9
10
|
"\n %s %s" % [directive.to_s.split('_').map(&:capitalize).join, value]
|
10
11
|
end
|
11
12
|
end
|
12
|
-
end
|
13
|
+
end
|
@@ -11,7 +11,7 @@ module Tomahawk
|
|
11
11
|
config = "\n<#{directive_group_name} #{@directive_group.parameters}>\n"
|
12
12
|
|
13
13
|
@directive_group.directives.each do |directive, value|
|
14
|
-
config += generate_directive(directive, value)
|
14
|
+
config += generate_directive(directive, value)
|
15
15
|
end
|
16
16
|
|
17
17
|
@directive_group.groups.each do |group|
|
@@ -25,7 +25,7 @@ module Tomahawk
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def directive_group_name
|
28
|
-
@directive_group.
|
28
|
+
@directive_group.name
|
29
29
|
end
|
30
30
|
end
|
31
|
-
end
|
31
|
+
end
|
data/lib/tomahawk/version.rb
CHANGED
@@ -1,9 +1,13 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Tomahawk::DirectiveGroups do
|
4
|
-
describe '.DirectiveGroup' do
|
4
|
+
describe '.DirectiveGroup' do
|
5
5
|
it 'returns corresponding DirectiveGroup if String given' do
|
6
6
|
expect(Tomahawk::DirectiveGroups.DirectiveGroup('VirtualHost')).to eq(Tomahawk::DirectiveGroups::VirtualHost)
|
7
7
|
end
|
8
|
+
|
9
|
+
it "returns GenericDirectiveGroup if directive group is unknown" do
|
10
|
+
expect(Tomahawk::DirectiveGroups.DirectiveGroup('Foobar').ancestors).to include(Tomahawk::DirectiveGroups::GenericDirectiveGroup)
|
11
|
+
end
|
8
12
|
end
|
9
|
-
end
|
13
|
+
end
|
metadata
CHANGED
@@ -1,62 +1,55 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tomahawk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.5
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Christian Schell
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2016-08-07 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: rake
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - ">="
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: 10.0.0
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - ">="
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: 10.0.0
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: bundler
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- - ~>
|
31
|
+
- - "~>"
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '1.5'
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- - ~>
|
38
|
+
- - "~>"
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: '1.5'
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: rspec
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- -
|
45
|
+
- - ">="
|
52
46
|
- !ruby/object:Gem::Version
|
53
47
|
version: '0'
|
54
48
|
type: :development
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- -
|
52
|
+
- - ">="
|
60
53
|
- !ruby/object:Gem::Version
|
61
54
|
version: '0'
|
62
55
|
description: ''
|
@@ -66,25 +59,28 @@ executables: []
|
|
66
59
|
extensions: []
|
67
60
|
extra_rdoc_files: []
|
68
61
|
files:
|
69
|
-
- .gitignore
|
70
|
-
- .rspec
|
71
|
-
- .ruby-version
|
72
|
-
- .travis.yml
|
62
|
+
- ".gitignore"
|
63
|
+
- ".rspec"
|
64
|
+
- ".ruby-version"
|
65
|
+
- ".travis.yml"
|
73
66
|
- Gemfile
|
74
67
|
- LICENSE.txt
|
75
68
|
- README.md
|
76
69
|
- Rakefile
|
70
|
+
- apache2.conf
|
77
71
|
- lib/tomahawk.rb
|
78
72
|
- lib/tomahawk/config.rb
|
79
73
|
- lib/tomahawk/config_parser.rb
|
80
74
|
- lib/tomahawk/directive_groups.rb
|
81
75
|
- lib/tomahawk/directive_groups/base.rb
|
82
76
|
- lib/tomahawk/directive_groups/directory.rb
|
77
|
+
- lib/tomahawk/directive_groups/generic_directive_group.rb
|
83
78
|
- lib/tomahawk/directive_groups/httpd.rb
|
84
79
|
- lib/tomahawk/directive_groups/virtual_host.rb
|
85
80
|
- lib/tomahawk/generators.rb
|
86
81
|
- lib/tomahawk/generators/base.rb
|
87
82
|
- lib/tomahawk/generators/directory.rb
|
83
|
+
- lib/tomahawk/generators/generic_directive_group.rb
|
88
84
|
- lib/tomahawk/generators/httpd.rb
|
89
85
|
- lib/tomahawk/generators/virtual_host.rb
|
90
86
|
- lib/tomahawk/version.rb
|
@@ -100,27 +96,26 @@ files:
|
|
100
96
|
homepage: https://github.com/Sophisticates/tomahawk
|
101
97
|
licenses:
|
102
98
|
- MIT
|
99
|
+
metadata: {}
|
103
100
|
post_install_message:
|
104
101
|
rdoc_options: []
|
105
102
|
require_paths:
|
106
103
|
- lib
|
107
104
|
required_ruby_version: !ruby/object:Gem::Requirement
|
108
|
-
none: false
|
109
105
|
requirements:
|
110
|
-
- -
|
106
|
+
- - ">="
|
111
107
|
- !ruby/object:Gem::Version
|
112
108
|
version: '0'
|
113
109
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
114
|
-
none: false
|
115
110
|
requirements:
|
116
|
-
- -
|
111
|
+
- - ">="
|
117
112
|
- !ruby/object:Gem::Version
|
118
113
|
version: '0'
|
119
114
|
requirements: []
|
120
115
|
rubyforge_project:
|
121
|
-
rubygems_version:
|
116
|
+
rubygems_version: 2.4.5
|
122
117
|
signing_key:
|
123
|
-
specification_version:
|
118
|
+
specification_version: 4
|
124
119
|
summary: Tomahawk parses and generates Apache 2 configuration files.
|
125
120
|
test_files:
|
126
121
|
- spec/lib/tomahawk/config_parser_spec.rb
|
@@ -131,3 +126,4 @@ test_files:
|
|
131
126
|
- spec/lib/tomahawk/generators/httpd_spec.rb
|
132
127
|
- spec/lib/tomahawk_spec.rb
|
133
128
|
- spec/spec_helper.rb
|
129
|
+
has_rdoc:
|