simonmenke-capricorn 0.2.03 → 0.2.07
Sign up to get free protection for your applications and to get access to all the features.
- data/app_generators/engine/templates/lib/engine.rb +3 -0
- data/lib/capricorn/actors/base_actor.rb +1 -1
- data/lib/capricorn/actors/host_file_actor.rb +77 -0
- data/lib/capricorn/actors/passenger_actor.rb +1 -1
- data/lib/capricorn/apps/satellite.rb +6 -1
- data/lib/capricorn/satellite/dependency_loader.rb +4 -0
- data/lib/capricorn.rb +1 -0
- metadata +3 -2
@@ -0,0 +1,77 @@
|
|
1
|
+
|
2
|
+
module Capricorn
|
3
|
+
module Actors # :nodoc:
|
4
|
+
class HostFileActor < Capricorn::Actor
|
5
|
+
|
6
|
+
on_install_satellite :add_host_name
|
7
|
+
on_uninstall_satellite :remove_host_name
|
8
|
+
|
9
|
+
# addthe fost form the host file
|
10
|
+
def add_host_name
|
11
|
+
content = load_file
|
12
|
+
content[:capricorn]['127.0.0.1'] ||= []
|
13
|
+
content[:capricorn]['127.0.0.1'].push satellite.domain
|
14
|
+
dump_file(content)
|
15
|
+
end
|
16
|
+
|
17
|
+
# remove the fost form the host file
|
18
|
+
def remove_host_name
|
19
|
+
content = load_file
|
20
|
+
content[:capricorn]['127.0.0.1'] ||= []
|
21
|
+
content[:capricorn]['127.0.0.1'].delete satellite.domain
|
22
|
+
dump_file(content)
|
23
|
+
end
|
24
|
+
|
25
|
+
SEPERATOR = '### the content below this line is managed by capricorn'
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def load_file
|
30
|
+
content = File.read(system.host_file_path)
|
31
|
+
content_parts = content.split(Capricorn::Actors::HostFileActor::SEPERATOR)
|
32
|
+
|
33
|
+
user_hosts = content_parts[0] || ''
|
34
|
+
host_lines = content_parts[1] || ''
|
35
|
+
host_lines = host_lines.split(/\n/)
|
36
|
+
host_lines = host_lines.inject({}) do |m, host_line|
|
37
|
+
next if host_line.nil?
|
38
|
+
host_line = host_line.strip
|
39
|
+
next if host_line[0,1] == '#'
|
40
|
+
next if host_line == ''
|
41
|
+
|
42
|
+
host_line = host_line.split(/\s+/)
|
43
|
+
ip = host_line.shift
|
44
|
+
m[ip] ||= []
|
45
|
+
m[ip].concat(host_line)
|
46
|
+
|
47
|
+
m
|
48
|
+
end
|
49
|
+
|
50
|
+
{
|
51
|
+
:user => user_hosts,
|
52
|
+
:capricorn => host_lines
|
53
|
+
}
|
54
|
+
end
|
55
|
+
|
56
|
+
def dump_file(content)
|
57
|
+
File.open(system.host_file_path, 'w+') do |f|
|
58
|
+
f.puts content[:user].strip
|
59
|
+
f.puts Capricorn::Actors::HostFileActor::SEPERATOR
|
60
|
+
content[:capricorn].each do |ip, hosts|
|
61
|
+
f.puts "#{ip} #{hosts.join(' ')}"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
module Config
|
67
|
+
|
68
|
+
# path to the hosts file.
|
69
|
+
def host_file_path(&block)
|
70
|
+
option(:host_file_path, block) { |v| v or '/etc/hosts' }
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -18,7 +18,7 @@ module Capricorn
|
|
18
18
|
|
19
19
|
# set the passneger restart file.
|
20
20
|
def passenger_restart_txt(&block)
|
21
|
-
satellite_option(:passenger_restart_txt, block) { |v
|
21
|
+
satellite_option(:passenger_restart_txt, block) { |s, v| v || File.join(satellite_root, 'tmp', 'restart.txt') }
|
22
22
|
end
|
23
23
|
|
24
24
|
end
|
@@ -7,12 +7,17 @@ module Capricorn
|
|
7
7
|
desc 'list', 'show all managed satellites'
|
8
8
|
method_options :token => :optional
|
9
9
|
def list
|
10
|
-
Capricorn.client(options[:token]).satellites
|
10
|
+
satellites = Capricorn.client(options[:token]).satellites
|
11
|
+
satellites.size.times do |i|
|
12
|
+
sat = satellites[i]
|
11
13
|
puts sat.domain
|
12
14
|
sat.engines.each do |name, options|
|
13
15
|
puts "- #{name} #{options.inspect}"
|
14
16
|
end
|
15
17
|
end
|
18
|
+
rescue => e
|
19
|
+
p e
|
20
|
+
puts e.backtrace
|
16
21
|
end
|
17
22
|
|
18
23
|
desc 'install DOMAIN', 'install a satellite'
|
@@ -15,6 +15,10 @@ module Capricorn
|
|
15
15
|
end
|
16
16
|
|
17
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
|
+
|
18
22
|
specs = engines.collect do |k,r|
|
19
23
|
s = Gem.source_index.find_name(k, Gem::Requirement.new(r[:version] || ">= 0.0.0"))
|
20
24
|
s.last
|
data/lib/capricorn.rb
CHANGED
@@ -30,6 +30,7 @@ module Capricorn
|
|
30
30
|
autoload :PleskActor, (base+'/capricorn/actors/plesk_actor')
|
31
31
|
autoload :ApacheActor, (base+'/capricorn/actors/apache_actor')
|
32
32
|
autoload :Sqlite3Actor, (base+'/capricorn/actors/sqlite3_actor')
|
33
|
+
autoload :HostFileActor, (base+'/capricorn/actors/host_file_actor')
|
33
34
|
autoload :PassengerActor, (base+'/capricorn/actors/passenger_actor')
|
34
35
|
end
|
35
36
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simonmenke-capricorn
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.07
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Simon Menke
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-06-
|
12
|
+
date: 2009-06-18 00:00:00 -07:00
|
13
13
|
default_executable: capricorn
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -29,6 +29,7 @@ files:
|
|
29
29
|
- lib/capricorn/actor.rb
|
30
30
|
- lib/capricorn/actors/apache_actor.rb
|
31
31
|
- lib/capricorn/actors/base_actor.rb
|
32
|
+
- lib/capricorn/actors/host_file_actor.rb
|
32
33
|
- lib/capricorn/actors/mysql_actor.rb
|
33
34
|
- lib/capricorn/actors/passenger_actor.rb
|
34
35
|
- lib/capricorn/actors/plesk_actor.rb
|