iisconfig 0.4.1 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,92 +1,92 @@
1
- require 'iis_object'
2
- require 'application'
3
-
4
- module IISConfig
5
-
6
- class FtpSite < IISObject
7
-
8
- def initialize
9
- @bindings = []
10
- @authentication = []
11
- @allow_authorization = []
12
- end
13
-
14
- def name(name = nil)
15
- @name = name unless name.nil?
16
- @name
17
- end
18
-
19
- def binding(binding)
20
- @bindings << binding
21
- end
22
-
23
- def app_pool(pool)
24
- @app_pool = pool
25
- end
26
-
27
- def physical_path(path)
28
- @physical_path = path
29
- end
30
-
31
- def enable_authentication(*authentication)
32
- @authentication += authentication
33
- end
34
-
35
- def allow_authorization(permissions, access)
36
- @allow_authorization << { :permissions => permissions, :access => access }
37
- end
38
-
39
- def allow_ssl
40
- @ssl = :allow
41
- end
42
-
43
- def delete
44
- %W{DELETE SITE #{@name}}
45
- end
46
-
47
- def add
48
- args = []
49
- args << 'ADD'
50
- args << 'SITE'
51
- args << "/name:#{@name}"
52
- args << "/bindings:\"#{@bindings.join('","')}\""
53
- args << "/physicalPath:#{@physical_path.gsub(/\//, '\\')}"
54
-
55
- args
56
- end
57
-
58
- def required_paths
59
- paths = []
60
- paths << @physical_path
61
- paths
62
- end
63
-
64
- def build_commands()
65
- commands = []
66
- commands << delete if exist? :site, @name
67
- commands << add
68
-
69
- commands << %W{SET SITE /site.name:#{@name} /[path='/'].applicationPool:#{@app_pool}} unless @app_pool.nil?
70
-
71
- @allow_authorization.each do |a|
72
- permissions = a[:permissions].map { |p| p.capitalize }.join(',')
73
- roles = a[:access][:roles]
74
- users = a[:access][:users]
75
- commands << %W{SET CONFIG #{@name} /section:system.ftpserver/security/authorization /+[accessType='Allow',permissions='#{permissions}',roles='#{roles}',users='#{users}'] /commit:apphost}
76
- end
77
-
78
- @authentication.each do |a|
79
- commands << %W{SET CONFIG -section:system.applicationHost/sites /[name='#{@name}'].ftpServer.security.authentication.#{a}Authentication.enabled:true}
80
- end
81
-
82
- unless @ssl.nil?
83
- commands << %W{SET CONFIG -section:system.applicationHost/sites /[name='#{@name}'].ftpServer.security.ssl.controlChannelPolicy:"Ssl#{@ssl.capitalize}"}
84
- commands << %W{SET CONFIG -section:system.applicationHost/sites /[name='#{@name}'].ftpServer.security.ssl.dataChannelPolicy:"Ssl#{@ssl.capitalize}"}
85
- end
86
-
87
- commands
88
- end
89
-
90
- end
91
-
1
+ require 'iis_object'
2
+ require 'application'
3
+
4
+ module IISConfig
5
+
6
+ class FtpSite < IISObject
7
+
8
+ def initialize
9
+ @bindings = []
10
+ @authentication = []
11
+ @allow_authorization = []
12
+ end
13
+
14
+ def name(name = nil)
15
+ @name = name unless name.nil?
16
+ @name
17
+ end
18
+
19
+ def binding(binding)
20
+ @bindings << binding
21
+ end
22
+
23
+ def app_pool(pool)
24
+ @app_pool = pool
25
+ end
26
+
27
+ def physical_path(path)
28
+ @physical_path = path
29
+ end
30
+
31
+ def enable_authentication(*authentication)
32
+ @authentication += authentication
33
+ end
34
+
35
+ def allow_authorization(permissions, access)
36
+ @allow_authorization << { :permissions => permissions, :access => access }
37
+ end
38
+
39
+ def allow_ssl
40
+ @ssl = :allow
41
+ end
42
+
43
+ def delete
44
+ %W{DELETE SITE #{@name}}
45
+ end
46
+
47
+ def add
48
+ args = []
49
+ args << 'ADD'
50
+ args << 'SITE'
51
+ args << "/name:#{@name}"
52
+ args << "/bindings:\"#{@bindings.join('","')}\""
53
+ args << "/physicalPath:#{@physical_path.gsub(/\//, '\\')}"
54
+
55
+ args
56
+ end
57
+
58
+ def required_paths
59
+ paths = []
60
+ paths << @physical_path
61
+ paths
62
+ end
63
+
64
+ def build_commands()
65
+ commands = []
66
+ commands << delete if exist? :site, @name
67
+ commands << add
68
+
69
+ commands << %W{SET SITE /site.name:#{@name} /[path='/'].applicationPool:#{@app_pool}} unless @app_pool.nil?
70
+
71
+ @allow_authorization.each do |a|
72
+ permissions = a[:permissions].map { |p| p.capitalize }.join(',')
73
+ roles = a[:access][:roles]
74
+ users = a[:access][:users]
75
+ commands << %W{SET CONFIG #{@name} /section:system.ftpserver/security/authorization /+[accessType='Allow',permissions='#{permissions}',roles='#{roles}',users='#{users}'] /commit:apphost}
76
+ end
77
+
78
+ @authentication.each do |a|
79
+ commands << %W{SET CONFIG -section:system.applicationHost/sites /[name='#{@name}'].ftpServer.security.authentication.#{a}Authentication.enabled:true}
80
+ end
81
+
82
+ unless @ssl.nil?
83
+ commands << %W{SET CONFIG -section:system.applicationHost/sites /[name='#{@name}'].ftpServer.security.ssl.controlChannelPolicy:"Ssl#{@ssl.capitalize}"}
84
+ commands << %W{SET CONFIG -section:system.applicationHost/sites /[name='#{@name}'].ftpServer.security.ssl.dataChannelPolicy:"Ssl#{@ssl.capitalize}"}
85
+ end
86
+
87
+ commands
88
+ end
89
+
90
+ end
91
+
92
92
  end
@@ -1,35 +1,48 @@
1
- require 'runner'
2
-
3
- module IISConfig
4
-
5
- class IISObject
6
-
7
- def exist?(type, name)
8
- args = []
9
- args << 'LIST'
10
- args << type.to_s.upcase
11
- args << '/xml'
12
- result = Runner.execute_command args
13
-
14
- exists = false
15
- doc = REXML::Document.new(result)
16
-
17
- doc.elements.each("appcmd/#{type.to_s.upcase}[@#{type.to_s.upcase}.NAME='#{name}']") do
18
- exists = true
19
- break
20
- end
21
-
22
- exists
23
- end
24
-
25
- protected
26
-
27
- def add_instance(collection, type, block)
28
- instance = type.new
29
- collection << instance
30
- block.call instance if block
31
- end
32
-
33
- end
34
-
35
- end
1
+ require 'runner'
2
+
3
+ module IISConfig
4
+
5
+ class IISObject
6
+
7
+ def exist?(type, name)
8
+ args = []
9
+ args << 'LIST'
10
+ args << type.to_s.upcase
11
+ args << '/xml'
12
+ result = Runner.execute_command args
13
+
14
+ exists = false
15
+ doc = REXML::Document.new(result)
16
+
17
+ doc.elements.each("appcmd/#{type.to_s.upcase}[@#{type.to_s.upcase}.NAME='#{name}']") do
18
+ exists = true
19
+ break
20
+ end
21
+
22
+ exists
23
+ end
24
+
25
+ def start_provider_exist?(name)
26
+ result = Runner.execute_command %W{ LIST CONFIG /section:serviceAutoStartProviders }
27
+ exists = false
28
+ doc = REXML::Document.new(result)
29
+
30
+ doc.each_element("//add[@name='#{name}']") do |e|
31
+ exists = true
32
+ break
33
+ end
34
+
35
+ exists
36
+ end
37
+
38
+ protected
39
+
40
+ def add_instance(collection, type, block)
41
+ instance = type.new
42
+ collection << instance
43
+ block.call instance if block
44
+ end
45
+
46
+ end
47
+
48
+ end
@@ -1,3 +1,3 @@
1
- module IISConfig
2
-
1
+ module IISConfig
2
+
3
3
  end
@@ -1,78 +1,78 @@
1
- module IISConfig
2
-
3
- # Configuration of the Process Model Settings for an Application Pool
4
- # Reference: http://www.iis.net/configreference/system.applicationhost/applicationpools/add/processmodel
5
- #
6
- class ProcessModel
7
-
8
- def initialize
9
- @settings = {}
10
- end
11
-
12
- def identity_type(type = nil)
13
- setting(:identityType, type)
14
- end
15
-
16
- # Specifies how long a worker process should run idle.
17
- def idle_timeout(timeout = nil)
18
- setting(:idleTimeout, timeout)
19
- end
20
-
21
- def load_user_profile(value = nil)
22
- setting(:loadUserProfile, value)
23
- end
24
-
25
- def logon_type(value = nil)
26
- setting(:logonType, value)
27
- end
28
-
29
- def manual_group_membership(value = nil)
30
- setting(:manualGroupMembership, value)
31
- end
32
-
33
- def max_processes(value = nil)
34
- setting(:maxProcesses, value)
35
- end
36
-
37
- def password(value = nil)
38
- setting(:password, value)
39
- end
40
-
41
- def pinging_enabled(value = nil)
42
- setting(:pingingEnabled, value)
43
- end
44
-
45
- def ping_interval(value = nil)
46
- setting(:pingInterval, value)
47
- end
48
-
49
- def ping_response_time(value = nil)
50
- setting(:pingResponseTime, value)
51
- end
52
-
53
- def shutdown_time_limit(value = nil)
54
- setting(:shutdownTimeLimit, value)
55
- end
56
-
57
- def startup_time_limit(value = nil)
58
- setting(:startupTimeLimit, value)
59
- end
60
-
61
- def username(value = nil)
62
- setting(:userName, value)
63
- end
64
-
65
- def settings
66
- @settings
67
- end
68
-
69
- private
70
-
71
- def setting(key, value)
72
- @settings[key] = value unless value.nil?
73
- @settings[key]
74
- end
75
-
76
- end
77
-
1
+ module IISConfig
2
+
3
+ # Configuration of the Process Model Settings for an Application Pool
4
+ # Reference: http://www.iis.net/configreference/system.applicationhost/applicationpools/add/processmodel
5
+ #
6
+ class ProcessModel
7
+
8
+ def initialize
9
+ @settings = {}
10
+ end
11
+
12
+ def identity_type(type = nil)
13
+ setting(:identityType, type)
14
+ end
15
+
16
+ # Specifies how long a worker process should run idle.
17
+ def idle_timeout(timeout = nil)
18
+ setting(:idleTimeout, timeout)
19
+ end
20
+
21
+ def load_user_profile(value = nil)
22
+ setting(:loadUserProfile, value)
23
+ end
24
+
25
+ def logon_type(value = nil)
26
+ setting(:logonType, value)
27
+ end
28
+
29
+ def manual_group_membership(value = nil)
30
+ setting(:manualGroupMembership, value)
31
+ end
32
+
33
+ def max_processes(value = nil)
34
+ setting(:maxProcesses, value)
35
+ end
36
+
37
+ def password(value = nil)
38
+ setting(:password, value)
39
+ end
40
+
41
+ def pinging_enabled(value = nil)
42
+ setting(:pingingEnabled, value)
43
+ end
44
+
45
+ def ping_interval(value = nil)
46
+ setting(:pingInterval, value)
47
+ end
48
+
49
+ def ping_response_time(value = nil)
50
+ setting(:pingResponseTime, value)
51
+ end
52
+
53
+ def shutdown_time_limit(value = nil)
54
+ setting(:shutdownTimeLimit, value)
55
+ end
56
+
57
+ def startup_time_limit(value = nil)
58
+ setting(:startupTimeLimit, value)
59
+ end
60
+
61
+ def username(value = nil)
62
+ setting(:userName, value)
63
+ end
64
+
65
+ def settings
66
+ @settings
67
+ end
68
+
69
+ private
70
+
71
+ def setting(key, value)
72
+ @settings[key] = value unless value.nil?
73
+ @settings[key]
74
+ end
75
+
76
+ end
77
+
78
78
  end
@@ -1,26 +1,27 @@
1
- module IISConfig
2
-
3
- class Runner
4
-
5
- def self.execute_command(args)
6
- args.flatten!
7
- tool = :appcmd
8
-
9
- puts " #{tool.to_s} #{args.join(' ')}"
10
-
11
- unless IISConfiguration.dry_run?
12
- result = `c:/windows/system32/inetsrv/appcmd #{args.join(' ')}"`
13
- raise Exception.new($?.exitstatus) unless $?.success?
14
- result
15
- end
16
- end
17
-
18
- def self.run_commands(commands)
19
- commands.each do |c|
20
- Runner.execute_command c
21
- end
22
- end
23
-
24
- end
25
-
26
- end
1
+ module IISConfig
2
+
3
+ class Runner
4
+
5
+ def self.execute_command(args)
6
+ args.flatten!
7
+ tool = :appcmd
8
+
9
+ puts " #{tool.to_s} #{args.join(' ')}"
10
+
11
+ unless IISConfiguration.dry_run?
12
+ result = `c:/windows/system32/inetsrv/appcmd #{args.join(' ')}"`
13
+ puts result if IISConfiguration.verbose?
14
+ raise Exception.new($?.exitstatus) unless $?.success?
15
+ result
16
+ end
17
+ end
18
+
19
+ def self.run_commands(commands)
20
+ commands.each do |c|
21
+ Runner.execute_command c
22
+ end
23
+ end
24
+
25
+ end
26
+
27
+ end
@@ -1,85 +1,85 @@
1
- require 'iis_object'
2
- require 'application'
3
-
4
- module IISConfig
5
-
6
- class Site < IISObject
7
-
8
- def initialize
9
- @bindings = []
10
- @applications = []
11
- @virtual_directories = []
12
- @path = '/'
13
- end
14
-
15
- def name(name = nil)
16
- @name = name unless name.nil?
17
- @name
18
- end
19
-
20
- def binding(binding)
21
- @bindings << binding
22
- end
23
-
24
- def path(path)
25
- @path = path
26
- end
27
-
28
- def app_pool(pool)
29
- @app_pool = pool
30
- end
31
-
32
- def physical_path(path)
33
- @physical_path = path
34
- end
35
-
36
- def application(&block)
37
- add_instance(@applications, IISConfig::Application, block)
38
- end
39
-
40
- def virtual_directory(&block)
41
- add_instance(@virtual_directories, IISConfig::VirtualDirectory, block)
42
- end
43
-
44
- def delete
45
- %W{DELETE SITE #{@name}}
46
- end
47
-
48
- def add
49
- args = []
50
- args << 'ADD'
51
- args << 'SITE'
52
- args << "/name:#{@name}"
53
- args << "/bindings:\"#{@bindings.join('","')}\""
54
- args << "/physicalPath:#{@physical_path.gsub(/\//, '\\')}"
55
-
56
- args
57
- end
58
-
59
- def required_paths
60
- paths = []
61
- paths << @physical_path
62
- paths
63
- end
64
-
65
- def build_commands()
66
- commands = []
67
- commands << delete if exist? :site, @name
68
- commands << add
69
- commands << %W{SET SITE /site.name:#{@name} /[path='#{@path}'].applicationPool:#{@app_pool}} unless @app_pool.nil?
70
- commands << %W{SET SITE /site.name:#{@name} /[path='#{@path}']} if @app_pool.nil?
71
-
72
- @applications.each do |s|
73
- commands += s.build_commands @name, @app_pool
74
- end
75
-
76
- @virtual_directories.each do |s|
77
- commands += s.build_commands "#{name}/"
78
- end
79
-
80
- commands
81
- end
82
-
83
- end
84
-
1
+ require 'iis_object'
2
+ require 'application'
3
+
4
+ module IISConfig
5
+
6
+ class Site < IISObject
7
+
8
+ def initialize
9
+ @bindings = []
10
+ @applications = []
11
+ @virtual_directories = []
12
+ @path = '/'
13
+ end
14
+
15
+ def name(name = nil)
16
+ @name = name unless name.nil?
17
+ @name
18
+ end
19
+
20
+ def binding(binding)
21
+ @bindings << binding
22
+ end
23
+
24
+ def path(path)
25
+ @path = path
26
+ end
27
+
28
+ def app_pool(pool)
29
+ @app_pool = pool
30
+ end
31
+
32
+ def physical_path(path)
33
+ @physical_path = path
34
+ end
35
+
36
+ def application(&block)
37
+ add_instance(@applications, IISConfig::Application, block)
38
+ end
39
+
40
+ def virtual_directory(&block)
41
+ add_instance(@virtual_directories, IISConfig::VirtualDirectory, block)
42
+ end
43
+
44
+ def delete
45
+ %W{DELETE SITE #{@name}}
46
+ end
47
+
48
+ def add
49
+ args = []
50
+ args << 'ADD'
51
+ args << 'SITE'
52
+ args << "/name:#{@name}"
53
+ args << "/bindings:\"#{@bindings.join('","')}\""
54
+ args << "/physicalPath:#{@physical_path.gsub(/\//, '\\')}"
55
+
56
+ args
57
+ end
58
+
59
+ def required_paths
60
+ paths = []
61
+ paths << @physical_path
62
+ paths
63
+ end
64
+
65
+ def build_commands()
66
+ commands = []
67
+ commands << delete if exist? :site, @name
68
+ commands << add
69
+ commands << %W{SET SITE /site.name:#{@name} /[path='#{@path}'].applicationPool:#{@app_pool}} unless @app_pool.nil?
70
+ commands << %W{SET SITE /site.name:#{@name} /[path='#{@path}']} if @app_pool.nil?
71
+
72
+ @applications.each do |s|
73
+ commands += s.build_commands @name, @app_pool
74
+ end
75
+
76
+ @virtual_directories.each do |s|
77
+ commands += s.build_commands "#{name}/"
78
+ end
79
+
80
+ commands
81
+ end
82
+
83
+ end
84
+
85
85
  end
@@ -1,5 +1,5 @@
1
- module IISConfig
2
-
3
- VERSION = File.read(File.expand_path(File.dirname(File.realpath(__FILE__)) + '/../../VERSION')).strip
4
-
1
+ module IISConfig
2
+
3
+ VERSION = File.read(File.expand_path(File.dirname(File.realpath(__FILE__)) + '/../../VERSION')).strip
4
+
5
5
  end