gearship 0.2.2 → 0.2.3
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.
- checksums.yaml +4 -4
- data/gearship.gemspec +1 -1
- data/lib/gearship/cli.rb +39 -37
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3893ba4345cc9005374a5568012a3ec5ccb5b07c
|
4
|
+
data.tar.gz: d725cd188273a288e3f406ce9ea335d11717cc6a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fd11e99fe1e66d4753ab4a1fe5615800375f563e73d082d60bd618c6d8a3f682c9042828e2483e964ad4ff59357d64dbb5a4eba1ea789325bbfd6d0d26be69ae
|
7
|
+
data.tar.gz: b2f73a0b0a336514bcb9f121b4cb3e48fb20f8a5ac668ceb326e57cd9ecd032a08572640b14e44a95f490de4c3c432d065090be93279c7508c2eaa8b74f5133b
|
data/gearship.gemspec
CHANGED
data/lib/gearship/cli.rb
CHANGED
@@ -8,23 +8,18 @@ module Gearship
|
|
8
8
|
|
9
9
|
desc 'init', 'Initialize gearship project'
|
10
10
|
def init(project = 'gearship')
|
11
|
-
|
11
|
+
init!(project)
|
12
12
|
end
|
13
13
|
|
14
|
-
desc 'go [mission] [--sudo]', 'Send gearship on a mission'
|
14
|
+
desc 'go [mission] [--sudo]', 'Send gearship on a mission with ssh.'
|
15
15
|
method_options :sudo => false
|
16
16
|
def go(target, *args)
|
17
|
-
|
17
|
+
go!(target, *args)
|
18
18
|
end
|
19
|
-
|
19
|
+
|
20
20
|
desc 'compile', 'Compile gearship project for debugging'
|
21
21
|
def compile(mission = nil)
|
22
|
-
|
23
|
-
end
|
24
|
-
|
25
|
-
desc 'version', 'Show gearship version'
|
26
|
-
def version
|
27
|
-
puts Gem.loaded_specs['gearship'].version.to_s
|
22
|
+
compile!(mission)
|
28
23
|
end
|
29
24
|
|
30
25
|
no_tasks do
|
@@ -34,7 +29,7 @@ module Gearship
|
|
34
29
|
File.expand_path('../../',__FILE__)
|
35
30
|
end
|
36
31
|
|
37
|
-
def
|
32
|
+
def init!(project)
|
38
33
|
copy_file 'templates/.dockerignore', ".dockerignore"
|
39
34
|
copy_file 'templates/.gitignore', "#{project}/.gitignore"
|
40
35
|
copy_file 'templates/gearship.yml', "#{project}/gearship.yml"
|
@@ -54,33 +49,39 @@ module Gearship
|
|
54
49
|
copy_file 'templates/cargo/sample.conf', "#{project}/cargo/sample.conf"
|
55
50
|
end
|
56
51
|
|
57
|
-
def
|
52
|
+
def go!(*args)
|
58
53
|
mission = args[0]
|
54
|
+
compile!(mission)
|
55
|
+
sudo = 'sudo ' if options.sudo?
|
59
56
|
|
60
|
-
|
57
|
+
if mission.include? 'local'
|
58
|
+
local_commands = <<-EOS
|
59
|
+
bash compiled/gearship.sh
|
60
|
+
EOS
|
61
|
+
else
|
62
|
+
|
63
|
+
user, host, port = parse_target(@config['attributes']['ssh_target'])
|
64
|
+
endpoint = "#{user}@#{host}"
|
65
|
+
|
66
|
+
# Remove server key from known hosts to avoid mismatch errors when VMs change.
|
67
|
+
`ssh-keygen -R #{host} 2> /dev/null`
|
68
|
+
|
69
|
+
remote_commands = <<-EOS
|
70
|
+
rm -rf ~/gearship &&
|
71
|
+
mkdir ~/gearship &&
|
72
|
+
cd ~/gearship &&
|
73
|
+
tar xz &&
|
74
|
+
#{sudo}bash gearship.sh
|
75
|
+
EOS
|
76
|
+
|
77
|
+
remote_commands.strip! << ' && rm -rf ~/gearship' if @config['preferences'] and @config['preferences']['erase_remote_folder']
|
78
|
+
|
79
|
+
local_commands = <<-EOS
|
80
|
+
cd compiled
|
81
|
+
tar cz . | ssh -o 'StrictHostKeyChecking no' #{endpoint} -p #{port} '#{remote_commands}'
|
82
|
+
EOS
|
83
|
+
end
|
61
84
|
|
62
|
-
sudo = 'sudo ' if options.sudo?
|
63
|
-
user, host, port = parse_target(@config['attributes']['ssh_target'])
|
64
|
-
endpoint = "#{user}@#{host}"
|
65
|
-
|
66
|
-
# Remove server key from known hosts to avoid mismatch errors when VMs change.
|
67
|
-
`ssh-keygen -R #{host} 2> /dev/null`
|
68
|
-
|
69
|
-
remote_commands = <<-EOS
|
70
|
-
rm -rf ~/gearship &&
|
71
|
-
mkdir ~/gearship &&
|
72
|
-
cd ~/gearship &&
|
73
|
-
tar xz &&
|
74
|
-
#{sudo}bash gearship.sh
|
75
|
-
EOS
|
76
|
-
|
77
|
-
remote_commands.strip! << ' && rm -rf ~/gearship' if @config['preferences'] and @config['preferences']['erase_remote_folder']
|
78
|
-
|
79
|
-
local_commands = <<-EOS
|
80
|
-
cd compiled
|
81
|
-
tar cz . | ssh -o 'StrictHostKeyChecking no' #{endpoint} -p #{port} '#{remote_commands}'
|
82
|
-
EOS
|
83
|
-
|
84
85
|
Open3.popen3(local_commands) do |stdin, stdout, stderr|
|
85
86
|
stdin.close
|
86
87
|
t = Thread.new do
|
@@ -94,8 +95,9 @@ module Gearship
|
|
94
95
|
t.join
|
95
96
|
end
|
96
97
|
end
|
97
|
-
|
98
|
-
|
98
|
+
|
99
|
+
|
100
|
+
def compile!(mission)
|
99
101
|
abort_with 'You must be in the gearship folder' unless File.exists?('gearship.yml')
|
100
102
|
abort_with "#{mission} doesn't exist!" if mission and !File.exists?("missions/#{mission}.sh")
|
101
103
|
|