capricorn 0.2.25 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (139) hide show
  1. data/LICENSE +19 -0
  2. data/README.md +1 -0
  3. data/bin/capricorn-app-scaffolder +27 -0
  4. data/bin/capricorn-gem-spec +33 -0
  5. data/bin/capricornctl +12 -0
  6. data/bin/capricornd +31 -0
  7. data/erlang/lib/bert/doc/overview.edoc +4 -0
  8. data/erlang/lib/bert/ebin/bert.app +9 -0
  9. data/erlang/lib/bert/rebar.config +3 -0
  10. data/erlang/lib/bert/src/bert.erl +69 -0
  11. data/erlang/lib/bertio/doc/overview.edoc +4 -0
  12. data/erlang/lib/bertio/ebin/bertio.app +9 -0
  13. data/erlang/lib/bertio/rebar.config +3 -0
  14. data/erlang/lib/bertio/src/bertio.erl +28 -0
  15. data/erlang/lib/bertrpc/doc/overview.edoc +4 -0
  16. data/erlang/lib/bertrpc/ebin/bertrpc.app +12 -0
  17. data/erlang/lib/bertrpc/include/bertrpc.hrl +1 -0
  18. data/erlang/lib/bertrpc/rebar.config +5 -0
  19. data/erlang/lib/bertrpc/src/bertrpc.erl +471 -0
  20. data/erlang/lib/bertrpc/src/bertrpc_hello_world.erl +148 -0
  21. data/erlang/lib/bertrpc/src/fd_tcp.erl +376 -0
  22. data/erlang/lib/capricorn/doc/overview.edoc +4 -0
  23. data/erlang/lib/capricorn/ebin/capricorn.app +56 -0
  24. data/erlang/lib/capricorn/include/capricorn.hrl +76 -0
  25. data/erlang/lib/capricorn/rebar.config +3 -0
  26. data/erlang/lib/capricorn/src/cap_application.erl +170 -0
  27. data/erlang/lib/capricorn/src/cap_cluster.erl +121 -0
  28. data/erlang/lib/capricorn/src/cap_cluster_gems.erl +422 -0
  29. data/erlang/lib/capricorn/src/cap_config.erl +25 -0
  30. data/erlang/lib/capricorn/src/cap_dets_updater.erl +26 -0
  31. data/erlang/lib/capricorn/src/cap_event_sup.erl +35 -0
  32. data/erlang/lib/capricorn/src/cap_events.erl +24 -0
  33. data/erlang/lib/capricorn/src/cap_external_api.erl +87 -0
  34. data/erlang/lib/capricorn/src/cap_external_apps_api.erl +125 -0
  35. data/erlang/lib/capricorn/src/cap_external_gems_api.erl +85 -0
  36. data/erlang/lib/capricorn/src/cap_external_machines_api.erl +18 -0
  37. data/erlang/lib/capricorn/src/cap_gem_utils.erl +111 -0
  38. data/erlang/lib/capricorn/src/cap_internal_api.erl +69 -0
  39. data/erlang/lib/capricorn/src/cap_internal_apps_api.erl +38 -0
  40. data/erlang/lib/capricorn/src/cap_log.erl +113 -0
  41. data/erlang/lib/capricorn/src/cap_machine.erl +338 -0
  42. data/erlang/lib/capricorn/src/cap_machine_apps.erl +410 -0
  43. data/erlang/lib/capricorn/src/cap_machine_apps_sup.erl +57 -0
  44. data/erlang/lib/capricorn/src/cap_sup.erl +200 -0
  45. data/erlang/lib/capricorn/src/cap_util.erl +278 -0
  46. data/erlang/lib/capricorn/src/capricorn.erl +45 -0
  47. data/erlang/lib/capricorn/src/capricorn_app.erl +36 -0
  48. data/erlang/lib/emq/ebin/emq.app +17 -0
  49. data/erlang/lib/emq/src/emq.erl +261 -0
  50. data/erlang/lib/emq/src/emq_app.erl +11 -0
  51. data/erlang/lib/emq/src/emq_pool.erl +178 -0
  52. data/erlang/lib/emq/src/emq_queue.erl +332 -0
  53. data/erlang/lib/emq/src/emq_status.erl +148 -0
  54. data/erlang/lib/emq/src/emq_sup.erl +132 -0
  55. data/erlang/lib/gcd/ebin/gcd.app +18 -0
  56. data/erlang/lib/gcd/include/gcd.hrl +5 -0
  57. data/erlang/lib/gcd/rebar.config +3 -0
  58. data/erlang/lib/gcd/src/gcd.erl +51 -0
  59. data/erlang/lib/gcd/src/gcd_app.erl +13 -0
  60. data/erlang/lib/gcd/src/gcd_event.erl +39 -0
  61. data/erlang/lib/gcd/src/gcd_server.erl +30 -0
  62. data/erlang/lib/gcd/src/gcd_srv.erl +186 -0
  63. data/erlang/lib/gcd/src/gcd_sup.erl +18 -0
  64. data/erlang/rebar +0 -0
  65. data/erlang/rebar.config +9 -0
  66. data/erlang/rel/overlay/bin/capricornd +146 -0
  67. data/erlang/rel/overlay/erts-vsn/bin/erl +34 -0
  68. data/erlang/rel/overlay/erts-vsn/bin/nodetool +80 -0
  69. data/erlang/rel/overlay/etc/capricorn/app.config +59 -0
  70. data/erlang/rel/overlay/etc/capricorn/cluster-vm.args +21 -0
  71. data/erlang/rel/overlay/etc/capricorn/machine-vm.args +21 -0
  72. data/erlang/rel/reltool.config +43 -0
  73. data/ext/Makefile +2 -0
  74. data/ext/extconf.rb +1 -0
  75. data/lib/capricorn-client.rb +86 -0
  76. data/lib/capricorn-client/cli/applications.rb +256 -0
  77. data/lib/capricorn-client/cli/gems.rb +57 -0
  78. data/lib/capricorn-client/cli/machines.rb +9 -0
  79. data/lib/capricorn-client/helpers.rb +62 -0
  80. data/lib/capricorn.rb +5 -99
  81. data/lib/capricorn/driver.rb +86 -0
  82. data/lib/capricorn/recipes/apache-debian.rb +112 -0
  83. data/lib/capricorn/recipes/centos-plesk.rb +162 -0
  84. data/lib/capricorn/recipes/macports.rb +54 -0
  85. data/lib/capricorn/system_context.rb +49 -0
  86. data/lib/capricorn/version.rb +5 -0
  87. metadata +233 -74
  88. data/app_generators/engine/engine_generator.rb +0 -40
  89. data/app_generators/engine/templates/Gmfile +0 -20
  90. data/app_generators/engine/templates/MIT-LICENSE.txt +0 -20
  91. data/app_generators/engine/templates/README.rdoc +0 -7
  92. data/app_generators/engine/templates/config/initializers/rails_init.rb +0 -1
  93. data/app_generators/engine/templates/config/routes.rb +0 -2
  94. data/app_generators/engine/templates/gitignore +0 -9
  95. data/app_generators/engine/templates/init.rb +0 -1
  96. data/app_generators/engine/templates/lib/engine.rb +0 -4
  97. data/app_generators/engine/templates/rails/init.rb +0 -1
  98. data/app_generators/engine/templates/tasks/engine_tasks.rake +0 -4
  99. data/bin/capricorn +0 -20
  100. data/lib/capricorn/actor.rb +0 -23
  101. data/lib/capricorn/actor/actions.rb +0 -76
  102. data/lib/capricorn/actors/apache_actor.rb +0 -56
  103. data/lib/capricorn/actors/base_actor.rb +0 -335
  104. data/lib/capricorn/actors/host_file_actor.rb +0 -77
  105. data/lib/capricorn/actors/mysql_actor.rb +0 -20
  106. data/lib/capricorn/actors/passenger_actor.rb +0 -28
  107. data/lib/capricorn/actors/plesk_actor.rb +0 -228
  108. data/lib/capricorn/actors/sqlite3_actor.rb +0 -44
  109. data/lib/capricorn/app_runner.rb +0 -108
  110. data/lib/capricorn/apps/dev.rb +0 -15
  111. data/lib/capricorn/apps/engines.rb +0 -33
  112. data/lib/capricorn/apps/jobs.rb +0 -35
  113. data/lib/capricorn/apps/satellite.rb +0 -68
  114. data/lib/capricorn/apps/server.rb +0 -73
  115. data/lib/capricorn/client.rb +0 -48
  116. data/lib/capricorn/client/auth_token.rb +0 -98
  117. data/lib/capricorn/daemon.rb +0 -81
  118. data/lib/capricorn/exception_handler.rb +0 -79
  119. data/lib/capricorn/extentions/rubygems_plugin.rb +0 -27
  120. data/lib/capricorn/extentions/thor_extentions.rb +0 -32
  121. data/lib/capricorn/job_queue.rb +0 -203
  122. data/lib/capricorn/satellite.rb +0 -52
  123. data/lib/capricorn/satellite/actions.rb +0 -55
  124. data/lib/capricorn/satellite/dependency_loader.rb +0 -82
  125. data/lib/capricorn/satellite/persistence.rb +0 -50
  126. data/lib/capricorn/server.rb +0 -144
  127. data/lib/capricorn/server/daemon.rb +0 -83
  128. data/lib/capricorn/server/proxy.rb +0 -25
  129. data/lib/capricorn/server/security.rb +0 -120
  130. data/lib/capricorn/system.rb +0 -218
  131. data/lib/capricorn/system/config.rb +0 -49
  132. data/lib/capricorn/system/helper.rb +0 -21
  133. data/lib/capricorn/system/options.rb +0 -79
  134. data/lib/capricorn/system/process_user.rb +0 -73
  135. data/lib/capricorn/system/satellites.rb +0 -44
  136. data/lib/capricorn/system/shell.rb +0 -80
  137. data/lib/rubygems_plugin.rb +0 -1
  138. data/spec/actor/actions_spec.rb +0 -13
  139. data/spec/spec_helper.rb +0 -1
@@ -1,82 +0,0 @@
1
-
2
-
3
- module Capricorn
4
- class Satellite
5
- class DependencyLoader
6
-
7
- attr_reader :names, :specs, :engines
8
-
9
- def self.load_for(engines)
10
- dependency_loader = self.new(engines)
11
- dependency_loader.add_dependecies!
12
- dependency_loader.order_by_dependecies!
13
-
14
- return dependency_loader
15
- end
16
-
17
- def initialize(engines)
18
- original_paths = [Gem.path].flatten
19
- Gem.refresh
20
- Gem.send(:set_paths, original_paths.compact.join(File::PATH_SEPARATOR))
21
-
22
- specs = engines.collect do |k,r|
23
- s = Gem.source_index.find_name(k, Gem::Requirement.new(r[:version] || ">= 0.0.0"))
24
- s.last
25
- end.compact
26
-
27
- @names = specs.collect { |spec| spec.name }
28
- @specs = specs.inject({}) { |h, spec| h[spec.name] = spec ; h }
29
- @engines = engines
30
- end
31
-
32
- def add_dependecies!
33
- @specs.values.each do |spec|
34
- add_dependecies_for spec
35
- end
36
- end
37
-
38
- def order_by_dependecies!
39
- @names = tsort
40
- end
41
-
42
- def each
43
- @names.each do |name|
44
- yield(@specs[name])
45
- end
46
- end
47
-
48
- def reverse_each
49
- @names.reverse.each do |name|
50
- yield(@specs[name])
51
- end
52
- end
53
-
54
- private
55
-
56
- include TSort
57
-
58
- def add_dependecies_for(spec)
59
- engine_dependencies = spec.engine_dependencies || {}
60
- engine_dependencies.each do |name, options|
61
- gems = Gem.source_index.find_name(name, [options[:version]].compact)
62
- next unless gem = gems.last
63
- next if @names.include?(name) and gem.version <= @specs[gem.name].version
64
- @specs[gem.name] = gem
65
- @names.push(gem.name)
66
- add_dependecies_for(gem)
67
- end
68
- @engines = @engines.merge(engine_dependencies)
69
- end
70
-
71
- def tsort_each_node(&block)
72
- @names.each(&block)
73
- end
74
-
75
- def tsort_each_child(node, &block)
76
- engine_dependencies = @specs[node].engine_dependencies || {}
77
- engine_dependencies.keys.each(&block)
78
- end
79
-
80
- end
81
- end
82
- end
@@ -1,50 +0,0 @@
1
- require 'yaml'
2
-
3
- module Capricorn
4
- class Satellite
5
- module Persistence
6
-
7
- def self.included(base)
8
- base.extend Capricorn::Satellite::Persistence::ClassMethods
9
- end
10
-
11
- module ClassMethods
12
-
13
- def load(data)
14
- Capricorn::Satellite.new(YAML.load(data))
15
- end
16
-
17
- def load_file(path)
18
- return nil unless File.exist?(path)
19
- Capricorn::Satellite.new(YAML.load_file(path))
20
- end
21
-
22
- end
23
-
24
- def dump(io=nil)
25
- data = {}
26
-
27
- private_vars = %w( basedomain subdomain )
28
- instance_variables.each do |ivar_name|
29
- ivar_name = ivar_name.to_s
30
- ivar_name =~ /^@(.+)$/
31
- name = $1
32
- unless private_vars.include? name
33
- data[name] = instance_variable_get(ivar_name.to_sym)
34
- end
35
- end
36
-
37
- if io
38
- io.write YAML.dump(data)
39
- else
40
- YAML.dump(data)
41
- end
42
- end
43
-
44
- def dump_file(path)
45
- File.open(path, 'w+') { |f| dump(f) }
46
- end
47
-
48
- end
49
- end
50
- end
@@ -1,144 +0,0 @@
1
-
2
- module Capricorn
3
-
4
- # the Server is supposed to be a simple DRb interface to the System.
5
- class Server < Capricorn::Daemon::Base
6
- include DRbUndumped
7
-
8
- autoload :Proxy, File.dirname(__FILE__)+'/server/proxy'
9
- autoload :Daemon, File.dirname(__FILE__)+'/server/daemon'
10
- autoload :Security, File.dirname(__FILE__)+'/server/security'
11
-
12
- include Capricorn::Server::Daemon
13
- include Capricorn::Server::Security
14
-
15
- def self.shared
16
- @shared ||= new
17
- end
18
-
19
- def self.proxy
20
- @proxy ||= Capricorn::Server::Proxy.new(self.shared)
21
- end
22
-
23
- def stop_server
24
- Capricorn.log "stopping the server..."
25
- $exitstatus = Capricorn::STOP_STATUS
26
- DRb.stop_service
27
- end
28
-
29
- def restart_server
30
- Capricorn.log "restarting the server..."
31
- $exitstatus = Capricorn::RESTART_STATUS
32
- DRb.stop_service
33
- end
34
-
35
- def reload_server
36
- Capricorn.log "reloading the server..."
37
- $exitstatus = Capricorn::RELOAD_STATUS
38
- DRb.stop_service
39
- end
40
-
41
- def server_version
42
- Capricorn.version
43
- end
44
-
45
- def update_server
46
- if Capricorn.system.gem_update('capricorn', :user => 'root')
47
- reload_server
48
- end
49
- end
50
-
51
- def update_gems
52
- Capricorn.system.gem_update(:all)
53
- end
54
-
55
- def install_satellite(domain, immediate)
56
- Capricorn.system.install_satellite(domain, immediate)
57
- end
58
-
59
- def relink_satellite(domain, immediate)
60
- satellite = Capricorn.system.find_satellite(domain)
61
- if satellite
62
- Capricorn.system.relink_satellite(satellite, immediate)
63
- else
64
- Capricorn.log "Satellite not found (#{domain})"
65
- end
66
- end
67
-
68
- def update_satellite(domain, immediate)
69
- satellite = Capricorn.system.find_satellite(domain)
70
- if satellite
71
- Capricorn.system.update_satellite(satellite, immediate)
72
- else
73
- Capricorn.log "Satellite not found (#{domain})"
74
- end
75
- end
76
-
77
- def uninstall_satellite(domain, immediate)
78
- satellite = Capricorn.system.find_satellite(domain)
79
- if satellite
80
- Capricorn.system.uninstall_satellite(satellite, immediate)
81
- else
82
- Capricorn.log "Satellite not found (#{domain})"
83
- end
84
- end
85
-
86
- def make_development_satellite(domain, name)
87
- satellite = Capricorn.system.find_satellite(domain)
88
- if satellite
89
- Capricorn.system.make_development_satellite(satellite, name)
90
- else
91
- Capricorn.log "Satellite not found (#{domain})"
92
- end
93
- end
94
-
95
- def install_engine(domain, name, options, immediate)
96
- satellite = Capricorn.system.find_satellite(domain)
97
- if satellite
98
- Capricorn.system.install_engine(satellite, name, options, immediate)
99
- else
100
- Capricorn.log "Satellite not found (#{domain})"
101
- end
102
- end
103
-
104
- def update_engine(domain, name, options, immediate)
105
- satellite = Capricorn.system.find_satellite(domain)
106
- if satellite
107
- Capricorn.system.update_engine(satellite, name, options, immediate)
108
- else
109
- Capricorn.log "Satellite not found (#{domain})"
110
- end
111
- end
112
-
113
- def uninstall_engine(domain, name, immediate)
114
- satellite = Capricorn.system.find_satellite(domain)
115
- if satellite
116
- Capricorn.system.uninstall_engine(satellite, name, immediate)
117
- else
118
- Capricorn.log "Satellite not found (#{domain})"
119
- end
120
- end
121
-
122
- def satellites
123
- Capricorn.system.satellites
124
- end
125
-
126
- def queued_jobs
127
- queued_jobs = []
128
- Capricorn.system.queue.each do |job, canceled, immediated|
129
- job_delay = job.delay
130
- queued_jobs.push([job.id, job.name, canceled, immediated, job.running?, job.waiting?, job_delay])
131
- end
132
- queued_jobs
133
- end
134
-
135
- def cancel_job(id)
136
- Capricorn.system.queue.cancel(id)
137
- end
138
-
139
- def immediate_job(id)
140
- Capricorn.system.queue.immediate(id)
141
- end
142
-
143
- end
144
- end
@@ -1,83 +0,0 @@
1
-
2
- module Capricorn
3
- class Server
4
-
5
- module Daemon # :nodoc:
6
-
7
- def self.included(base)
8
- base.extend Capricorn::Server::Daemon::ClassMethods
9
- end
10
-
11
- # all a daemon needs to run
12
- module ClassMethods
13
-
14
- # construct a Capricorn uri from a DRb uri
15
- def construct_uri(uri)
16
- uri = URI.parse(uri)
17
- uri.scheme = ( Capricorn.system.use_ssl? ? 'ssl+capricorn' : 'capricorn')
18
- uri.to_s
19
- end
20
-
21
- # stop the server
22
- def stop
23
- Capricorn.client.stop_server
24
- end
25
-
26
- # start the server
27
- def start
28
- start_with_failsafe
29
- end
30
-
31
- # start the failsafe runner.
32
- def start_with_failsafe
33
- $master = true
34
- retries = 0
35
- loop do
36
- pid = self.run_server
37
- return unless pid
38
- Process.waitpid(pid, 0)
39
-
40
- case $?.exitstatus
41
- when Capricorn::STOP_STATUS
42
- return
43
- when Capricorn::RESTART_STATUS
44
- retries = 0
45
- when Capricorn::RELOAD_STATUS
46
- Capricorn::Daemon::PidFile.destroy
47
- Capricorn.system.run %{#{Capricorn::BIN_PATH} #{ORIGINAL_ARGV.join(' ')}}
48
- return
49
- else
50
- retries += 1
51
- return if retries >= 3
52
- end
53
-
54
- sleep(2)
55
- end
56
- end
57
-
58
- # start the actual DRb server
59
- def run_server
60
- Process.fork do
61
- $master = false
62
- Dir.chdir(Capricorn.system.root)
63
-
64
- Capricorn.log "Server started"
65
- uri = "druby://#{Capricorn.system.server_hostname}:#{Capricorn.system.server_port}"
66
- DRb.start_service uri, self.proxy, self.options_for_server
67
- Capricorn.log "listening at #{self.construct_uri(uri)}"
68
- make_client_cert_public!
69
-
70
- at_exit do
71
- Capricorn.system.queue.stop!
72
- Capricorn.log "Server stopped"
73
- end
74
-
75
- DRb.thread.join
76
- exit($exitstatus || Capricorn::STOP_STATUS)
77
- end
78
- end
79
-
80
- end
81
- end
82
- end
83
- end
@@ -1,25 +0,0 @@
1
-
2
- module Capricorn
3
- class Server
4
- # the proxy object hides all the server internals from the clients.
5
- class Proxy
6
-
7
- def initialize(server)
8
- @server = server
9
- end
10
-
11
- def self.allow(*methods)
12
- methods.each do |method|
13
- module_eval %{ def #{method}(*args,&block) ; @server.#{method}(*args,&block) ; end }
14
- end
15
- end
16
-
17
- allow :stop_server, :restart_server, :reload_server, :server_version, :update_server, :install_satellite, :uninstall_satellite, :install_engine, :update_engine, :uninstall_engine, :satellites, :queued_jobs, :cancel_job, :immediate_job, :make_development_satellite, :update_gems, :relink_satellite, :update_satellite
18
-
19
- class << self
20
- undef_method :allow
21
- end
22
-
23
- end
24
- end
25
- end
@@ -1,120 +0,0 @@
1
-
2
- module Capricorn
3
- class Server
4
- module Security # :nodoc:
5
-
6
- def self.included(base)
7
- base.extend Capricorn::Server::Security::ClassMethods
8
- end
9
-
10
- module ClassMethods
11
-
12
- def options_for_server
13
-
14
- config = {}
15
- if Capricorn.system.use_ssl?
16
- install_quick_cert!
17
- dump_quick_cert_config!
18
- run_quick_cert!
19
-
20
- keypair = Capricorn.system.path('quick_cert', 'capricorn', 'capricorn_keypair.pem')
21
- cert = Capricorn.system.path('quick_cert', 'capricorn', 'cert_capricorn.pem')
22
-
23
- config = {
24
- :SSLPrivateKey => OpenSSL::PKey::RSA.new(File.read(keypair)),
25
- :SSLCertificate => OpenSSL::X509::Certificate.new(File.read(cert)),
26
- :SSLVerifyMode => OpenSSL::SSL::VERIFY_PEER | OpenSSL::SSL::VERIFY_FAIL_IF_NO_PEER_CERT,
27
- :SSLCACertificateFile => Capricorn.system.path('quick_cert', 'CA', 'cacert.pem')
28
- }
29
- end
30
-
31
- config
32
- end
33
-
34
- def install_quick_cert!
35
- unless Capricorn.system.find_bin('QuickCert')
36
- FileUtils.mkdir_p('/tmp/quick_cert')
37
- File.chmod(0700, '/tmp/quick_cert')
38
-
39
- download_quick_cert!
40
- build_quick_cert!
41
-
42
- FileUtils.rm_rf('/tmp/quick_cert')
43
- end
44
- end
45
-
46
- def download_quick_cert!
47
- Dir.chdir('/tmp/quick_cert') do
48
- Capricorn.system.run "curl -O #{Capricorn::QUICK_CERT}"
49
- Capricorn.system.run "tar xzf QuickCert-1.0.2.tar.gz"
50
- end
51
- end
52
-
53
- def build_quick_cert!
54
- Dir.chdir('/tmp/quick_cert/QuickCert-1.0.2') do
55
- Capricorn.system.run "#{Capricorn.system.ruby_path} ./setup.rb config"
56
- Capricorn.system.run "#{Capricorn.system.ruby_path} ./setup.rb setup"
57
- Capricorn.system.run "#{Capricorn.system.ruby_path} ./setup.rb install"
58
- end
59
- end
60
-
61
- def dump_quick_cert_config!
62
- return if File.file? Capricorn.system.path('quick_cert', 'qc_config')
63
-
64
- config = %{
65
- full_hostname = `hostname`.strip
66
- domainname = full_hostname.split('.')[1..-1].join('.')
67
- hostname = full_hostname.split('.')[0]
68
-
69
- CA[:hostname] = hostname
70
- CA[:domainname] = domainname
71
- CA[:CA_dir] = File.join Dir.pwd, "CA"
72
- CA[:password] = '#{rand(100_000)}'
73
-
74
- CERTS << {
75
- :type => 'server',
76
- :hostname => 'capricorn',
77
- # :password => '#{rand(100_000)}',
78
- }
79
-
80
- CERTS << {
81
- :type => 'client',
82
- :user => 'core',
83
- :email => 'core@mrhenry.be',
84
- }
85
- }
86
- FileUtils.mkdir_p(Capricorn.system.path('quick_cert'))
87
- File.chmod(0700, Capricorn.system.path('quick_cert'))
88
- File.open(Capricorn.system.path('quick_cert', 'qc_config'), 'w+') { |f| f.write config }
89
- end
90
-
91
- def run_quick_cert!
92
- return if File.directory? Capricorn.system.path('quick_cert', 'CA')
93
-
94
- Dir.chdir(Capricorn.system.path('quick_cert')) do
95
- Capricorn.system.run Capricorn.system.find_bin('QuickCert')
96
- end
97
- end
98
-
99
- def make_client_cert_public!
100
- token = nil
101
- if Capricorn.system.use_ssl?
102
- token = Capricorn::Client::AuthToken.new(
103
- :target_uri => self.construct_uri(DRb.uri),
104
- :verify_mode => OpenSSL::SSL::VERIFY_PEER,
105
- :private_key_data => File.read(Capricorn.system.path('quick_cert', 'core', 'core_keypair.pem')),
106
- :certificate_data => File.read(Capricorn.system.path('quick_cert', 'core', 'cert_core.pem')),
107
- :ca_certificate_data => File.read(Capricorn.system.path('quick_cert', 'CA', 'cacert.pem'))
108
- )
109
- else
110
- token = Capricorn::Client::AuthToken.new(
111
- :target_uri => self.construct_uri(DRb.uri))
112
- end
113
- token.dump_file(Capricorn.system.path('core.token'))
114
- FileUtils.chmod_R(0775, Capricorn.system.path('core.token'))
115
- end
116
-
117
- end
118
- end
119
- end
120
- end