exec_remote 0.0.1 → 0.0.2
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.
- data/CHANGELOG.rdoc +7 -0
- data/Manifest +1 -0
- data/Rakefile +1 -1
- data/exec_remote.gemspec +3 -3
- data/lib/exec_remote/cli.rb +13 -7
- data/lib/exec_remote/configuration.rb +31 -4
- data/lib/exec_remote/remote_executor.rb +3 -0
- metadata +3 -3
data/CHANGELOG.rdoc
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
== 0.0.2 / October 2, 2009
|
2
|
+
|
3
|
+
* Syncing the standard output, so that the output if flushed imediately. No need to wait for the line to complete.
|
4
|
+
* Moved rsync as an option, which can be disabled in config file.
|
5
|
+
* Also rsync ignore pattern can be modified in the config file.
|
6
|
+
* Added password option in the config file, so that password can be added once and no need to give password for every command. [Still password will be prompted on rsync.]
|
7
|
+
|
1
8
|
== 0.0.1 / October 2, 2009
|
2
9
|
|
3
10
|
* Some of the basic functionality.
|
data/Manifest
CHANGED
data/Rakefile
CHANGED
data/exec_remote.gemspec
CHANGED
@@ -2,17 +2,17 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{exec_remote}
|
5
|
-
s.version = "0.0.
|
5
|
+
s.version = "0.0.2"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Selvakumar Natesan"]
|
9
|
-
s.date = %q{2009-10-
|
9
|
+
s.date = %q{2009-10-04}
|
10
10
|
s.default_executable = %q{exec_remote}
|
11
11
|
s.description = %q{Exec Remote is a simple utility to run tests/build against your development code in a remote machine without checking in to a repository. It sync ups your code in local and remote machine with rsync and the commands are executed in remote machine via SSH}
|
12
12
|
s.email = %q{k.n.selvakumar@gmail.com}
|
13
13
|
s.executables = ["exec_remote"]
|
14
14
|
s.extra_rdoc_files = ["CHANGELOG.rdoc", "README.rdoc", "lib/exec_remote.rb", "lib/exec_remote/cli.rb", "lib/exec_remote/configuration.rb", "lib/exec_remote/remote_executor.rb", "lib/exec_remote/shell.rb"]
|
15
|
-
s.files = ["CHANGELOG.rdoc", "Manifest", "README.rdoc", "Rakefile", "bin/exec_remote", "lib/exec_remote.rb", "lib/exec_remote/cli.rb", "lib/exec_remote/configuration.rb", "lib/exec_remote/remote_executor.rb", "lib/exec_remote/shell.rb", "spec/functional/basic_spec.rb"
|
15
|
+
s.files = ["CHANGELOG.rdoc", "Manifest", "README.rdoc", "Rakefile", "bin/exec_remote", "exec_remote.gemspec", "lib/exec_remote.rb", "lib/exec_remote/cli.rb", "lib/exec_remote/configuration.rb", "lib/exec_remote/remote_executor.rb", "lib/exec_remote/shell.rb", "spec/functional/basic_spec.rb"]
|
16
16
|
s.homepage = %q{https://github.com/selvakn/exec_remote}
|
17
17
|
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Exec_remote", "--main", "README.rdoc"]
|
18
18
|
s.require_paths = ["lib"]
|
data/lib/exec_remote/cli.rb
CHANGED
@@ -8,11 +8,12 @@ module ExecRemote
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def self.execute
|
11
|
+
$stdout.sync = true
|
11
12
|
begin
|
12
13
|
puts "Exec Remote Shell"
|
13
14
|
puts "================="
|
14
15
|
|
15
|
-
rsync
|
16
|
+
rsync if config.rsync?
|
16
17
|
|
17
18
|
puts "Enter your commands now"
|
18
19
|
shell = Shell.new
|
@@ -28,7 +29,7 @@ module ExecRemote
|
|
28
29
|
def self.process_command(command)
|
29
30
|
if command[0,1] == "!"
|
30
31
|
command = command[1..-1]
|
31
|
-
print "again
|
32
|
+
print "again "
|
32
33
|
rsync
|
33
34
|
end
|
34
35
|
|
@@ -39,14 +40,19 @@ module ExecRemote
|
|
39
40
|
def self.exec_remote(command)
|
40
41
|
command = command.to_s.strip
|
41
42
|
command_to_exec = "cd #{config.my_current_project_dir_on_remote} && #{command}"
|
42
|
-
RemoteExecutor.connect_and_execute(command_to_exec, config.remote_host, config.remote_user) unless command.empty?
|
43
|
+
RemoteExecutor.connect_and_execute(command_to_exec, config.remote_host, config.remote_user, config.remote_password) unless command.empty?
|
44
|
+
rescue Net::SSH::AuthenticationFailed => e
|
45
|
+
puts "Either add your public key to server 'authorized_hosts' or provide password in the '.exec_remote.yml' file"
|
43
46
|
end
|
44
47
|
|
45
48
|
def self.rsync
|
46
|
-
|
47
|
-
rsync -r
|
48
|
-
|
49
|
-
|
49
|
+
# FixMe: Read password from config if available
|
50
|
+
rsync_command = ["rsync -r"]
|
51
|
+
rsync_command << "--exclude=#{config.rsync_ignore_pattern}" if config.rsync_ignore_pattern
|
52
|
+
rsync_command << "#{config.current_dir} #{config.remote_user}@#{config.remote_host}:#{config.my_dir_on_remote}"
|
53
|
+
puts "rsyncing.."
|
54
|
+
cmd = rsync_command.join(' ')
|
55
|
+
`#{cmd}`
|
50
56
|
puts "Done"
|
51
57
|
end
|
52
58
|
end
|
@@ -6,7 +6,11 @@ module ExecRemote
|
|
6
6
|
updated_config = update_config_from_user(config.dup)
|
7
7
|
|
8
8
|
return config if config == updated_config
|
9
|
-
File.open(config_file, "w")
|
9
|
+
File.open(config_file, "w") do |f|
|
10
|
+
config_to_write = default_config.merge updated_config
|
11
|
+
f.puts config_to_write.to_yaml
|
12
|
+
puts "Config written to '.exec_remote.yml'. Add this file to version control ignore list."
|
13
|
+
end
|
10
14
|
exec_config
|
11
15
|
end
|
12
16
|
|
@@ -25,6 +29,18 @@ module ExecRemote
|
|
25
29
|
def remote_user
|
26
30
|
exec_config["user"]
|
27
31
|
end
|
32
|
+
|
33
|
+
def remote_password
|
34
|
+
exec_config["password"]
|
35
|
+
end
|
36
|
+
|
37
|
+
def rsync?
|
38
|
+
exec_config["rsync"]
|
39
|
+
end
|
40
|
+
|
41
|
+
def rsync_ignore_pattern
|
42
|
+
exec_config["rsync_ignore_pattern"]
|
43
|
+
end
|
28
44
|
|
29
45
|
def my_dir_on_remote
|
30
46
|
File.join(exec_config["base_location"], exec_config["location"])
|
@@ -37,14 +53,13 @@ module ExecRemote
|
|
37
53
|
private
|
38
54
|
def config_from_file
|
39
55
|
return {} unless File.exists?(config_file)
|
40
|
-
YAML.load_file
|
56
|
+
YAML.load_file(config_file) || {}
|
41
57
|
end
|
42
58
|
|
43
59
|
def update_config_from_user(config = {})
|
44
60
|
config = check_and_update_config(config, "host", "the remote hostname/ip")
|
45
61
|
config = check_and_update_config(config, "user", "the remote host username")
|
46
|
-
config = check_and_update_config(config, "location", "your location on remote host",
|
47
|
-
config["base_location"] ||= "data"
|
62
|
+
config = check_and_update_config(config, "location", "your location on remote host", host_name)
|
48
63
|
config
|
49
64
|
end
|
50
65
|
|
@@ -65,5 +80,17 @@ module ExecRemote
|
|
65
80
|
str = string.strip
|
66
81
|
str.empty? ? nil : str
|
67
82
|
end
|
83
|
+
|
84
|
+
def host_name
|
85
|
+
`hostname`.split(".").first
|
86
|
+
end
|
87
|
+
|
88
|
+
def default_config
|
89
|
+
{
|
90
|
+
"base_location" => "data",
|
91
|
+
"rsync" => true,
|
92
|
+
"rsync_ignore_pattern" => ".git",
|
93
|
+
}
|
94
|
+
end
|
68
95
|
end
|
69
96
|
end
|
@@ -15,6 +15,9 @@ module ExecRemote
|
|
15
15
|
::Net::SSH.start(host, user, :password => password, :config=>false, :paranoid=>false) do |ssh|
|
16
16
|
yield(ssh)
|
17
17
|
end
|
18
|
+
rescue Net::SSH::AuthenticationFailed => error
|
19
|
+
puts "Authentication with server failed."
|
20
|
+
raise error
|
18
21
|
end
|
19
22
|
|
20
23
|
def self.execute(ssh_connection, command)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: exec_remote
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Selvakumar Natesan
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-10-
|
12
|
+
date: 2009-10-04 00:00:00 +05:30
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -42,13 +42,13 @@ files:
|
|
42
42
|
- README.rdoc
|
43
43
|
- Rakefile
|
44
44
|
- bin/exec_remote
|
45
|
+
- exec_remote.gemspec
|
45
46
|
- lib/exec_remote.rb
|
46
47
|
- lib/exec_remote/cli.rb
|
47
48
|
- lib/exec_remote/configuration.rb
|
48
49
|
- lib/exec_remote/remote_executor.rb
|
49
50
|
- lib/exec_remote/shell.rb
|
50
51
|
- spec/functional/basic_spec.rb
|
51
|
-
- exec_remote.gemspec
|
52
52
|
has_rdoc: true
|
53
53
|
homepage: https://github.com/selvakn/exec_remote
|
54
54
|
licenses: []
|