20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
# File 'lib/sunzi/command.rb', line 20
def deploy(target, role, options)
compile(role)
sudo = 'sudo ' if options.sudo?
endpoint = Endpoint.new(target)
`ssh-keygen -R #{endpoint.host} 2> /dev/null`
remote_commands = <<-EOS
rm -rf ~/sunzi &&
mkdir ~/sunzi &&
cd ~/sunzi &&
tar xz &&
#{sudo}bash install.sh
EOS
remote_commands.strip! << ' && rm -rf ~/sunzi' if config.preferences.erase_remote_folder
local_commands = <<-EOS
cd compiled
tar cz . | ssh -o 'StrictHostKeyChecking no' #{endpoint.user}@#{endpoint.host} -p #{endpoint.port} '#{remote_commands}'
EOS
Open3.popen3(local_commands) do |stdin, stdout, stderr|
stdin.close
t = Thread.new do
while (line = stderr.gets)
print line.color(:red)
end
end
while (line = stdout.gets)
print line.color(:green)
end
t.join
end
end
|