grsync 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/grsync +48 -54
- data/grsync.gemspec +1 -2
- data/lib/grsync/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: de99ffe827d1c73cbf2cecb80105944f169372f8
|
4
|
+
data.tar.gz: d9b4eabba343b0cf73b1153a1f8b3c001ffeb373
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da04bdd002f65a2ddd4814b76c36a08bcb40d7d793dd9a1d14501de0c2f1f2d295db36a051e93789389e8198e91f43a03178673e1db45c5d3c8416eb84aa977c
|
7
|
+
data.tar.gz: 8e5d2ff12d81960f4711f5bd3d179d0d88987703fd1179d7968910396db005f504a5b9dd97d933243ea51fe9ead68d82ffe1d84a25163feac47cfac3a5fc909d
|
data/bin/grsync
CHANGED
@@ -14,66 +14,60 @@ require 'grsync/logger'
|
|
14
14
|
# --passwd barabara
|
15
15
|
# --port 2222
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
opt :port, 'port for ssh login', :default => 22
|
26
|
-
opt :save, 'save this synchronization link'
|
27
|
-
end
|
17
|
+
# parse arguments
|
18
|
+
opts = Trollop::options do
|
19
|
+
opt :local, 'local source git repository(e.g. /path/to/repo)', :type => :string
|
20
|
+
opt :remote, 'remote destination git repository(e.g. username@host:/path/to/repo)', :type => :string
|
21
|
+
opt :passwd, 'password for ssh login', :type => :string
|
22
|
+
opt :port, 'port for ssh login', :default => 22
|
23
|
+
opt :save, 'save this synchronization link'
|
24
|
+
end
|
28
25
|
|
29
|
-
|
30
|
-
|
26
|
+
local = opts[:local]
|
27
|
+
remote_full = opts[:remote] # location with username, host and path
|
31
28
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
29
|
+
# since save feature is unimplemented
|
30
|
+
# both local and remote option have to be specified for an explicit synchronization
|
31
|
+
Trollop::die :local, 'must be specified' if local.nil?
|
32
|
+
Trollop::die :remote, 'must be specified' if remote_full.nil?
|
36
33
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
34
|
+
# local dir must exist
|
35
|
+
# always check existence asap
|
36
|
+
unless Dir.exist?(File.expand_path(local))
|
37
|
+
$Log.error "Local directory #{local} doesn't exist"
|
38
|
+
abort
|
39
|
+
end
|
43
40
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
41
|
+
# extract remote, user_name and host from dest_full
|
42
|
+
login_str, remote = remote_full.split ':'
|
43
|
+
if login_str.split('@').size == 2
|
44
|
+
user_name, host = login_str.split('@')
|
45
|
+
else
|
46
|
+
host = login_str
|
47
|
+
user_name = nil
|
48
|
+
end
|
52
49
|
|
53
|
-
|
54
|
-
|
55
|
-
|
50
|
+
# optional options for login
|
51
|
+
passwd = opts[:passwd] || ''
|
52
|
+
port = opts[:port]
|
56
53
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
end
|
63
|
-
rescue Net::SSH::AuthenticationFailed
|
64
|
-
login_info = {
|
65
|
-
host: host,
|
66
|
-
user_name: user_name,
|
67
|
-
port: port,
|
68
|
-
passwd: passwd
|
69
|
-
}
|
70
|
-
$Log.error "Authentication failed. Please check whether the following login information is correct: #{login_info}"
|
71
|
-
abort
|
72
|
-
rescue Exception => ex
|
73
|
-
$Log.error "#{ex.class.name} -- #{ex}"
|
74
|
-
abort
|
75
|
-
end
|
54
|
+
# ssh login
|
55
|
+
begin
|
56
|
+
Net::SSH.start(host, user_name, :password => passwd, :port => port) do |ssh|
|
57
|
+
syncer = GRSync::Syncer.new ssh, local, remote
|
58
|
+
syncer.sync
|
76
59
|
end
|
60
|
+
rescue Net::SSH::AuthenticationFailed
|
61
|
+
login_info = {
|
62
|
+
host: host,
|
63
|
+
user_name: user_name,
|
64
|
+
port: port,
|
65
|
+
passwd: passwd
|
66
|
+
}
|
67
|
+
$Log.error "Authentication failed. Please check whether the following login information is correct: #{login_info}"
|
68
|
+
abort
|
69
|
+
rescue Exception => ex
|
70
|
+
$Log.error "#{ex.class.name} -- #{ex}"
|
71
|
+
abort
|
77
72
|
end
|
78
73
|
|
79
|
-
|
data/grsync.gemspec
CHANGED
@@ -20,6 +20,5 @@ Gem::Specification.new do |spec|
|
|
20
20
|
spec.add_dependency 'trollop', '~> 2.1'
|
21
21
|
spec.add_dependency 'net-ssh', '~> 3.1'
|
22
22
|
spec.add_dependency 'log4r', '~> 1.1'
|
23
|
-
|
24
|
-
spec.add_development_dependency 'bundler', '~> 1.10'
|
23
|
+
spec.add_dependency 'bundler', '~> 1.10'
|
25
24
|
end
|
data/lib/grsync/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: grsync
|
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
|
- luminocean
|
@@ -59,7 +59,7 @@ dependencies:
|
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '1.10'
|
62
|
-
type: :
|
62
|
+
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|