remote_sh 0.1.7 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/remote_sh/cli.rb +30 -0
- data/lib/remote_sh/file_syncer.rb +25 -4
- data/lib/remote_sh/port_forwarder.rb +2 -0
- data/lib/remote_sh/ssh_helper.rb +5 -0
- data/lib/remote_sh/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 97bb90de5d65095a12854843df61d54b9e08e774c1b2cab1ddf19d289f76319f
|
4
|
+
data.tar.gz: ab9932f0a7c2817c9b55f193e97f22ef71600a23187d8b8929bbb3f00fa3b565
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ccfc0c0500546a57bed1183036c0953ecc7e0ef99c787b1c079bdfa4b862590c04e152b1b50b5190eafb476904db8a35ecaa639dcc8e7e07c6b16e22d222b014
|
7
|
+
data.tar.gz: b8dcd2b9ed962a7a09294f4bbb211d50b7382c53e67e3386b24c946ce2f2ba9e7d53d58b750eb46b2e0a591310e010db0b695ce882db14906d8d539e535244cd
|
data/lib/remote_sh/cli.rb
CHANGED
@@ -33,6 +33,7 @@ module RemoteSh
|
|
33
33
|
ensure
|
34
34
|
File.delete(pid_filename) if @owns_sync
|
35
35
|
end
|
36
|
+
map 'a' => :attach
|
36
37
|
|
37
38
|
desc "sync_down", "synces down remote changes"
|
38
39
|
def sync_down
|
@@ -44,9 +45,38 @@ module RemoteSh
|
|
44
45
|
)
|
45
46
|
end
|
46
47
|
|
48
|
+
desc "sync_up", "synces up local changes"
|
49
|
+
def sync_up
|
50
|
+
RsyncHelper.up(
|
51
|
+
WorkspaceConfiguration::WOKRING_DIR,
|
52
|
+
WorkspaceConfiguration.config["host_path"],
|
53
|
+
WorkspaceConfiguration.host_config["host"],
|
54
|
+
WorkspaceConfiguration.config["ignore"] || []
|
55
|
+
)
|
56
|
+
end
|
57
|
+
|
58
|
+
desc "exec", "executes given command within remote context"
|
59
|
+
def exec(*argv)
|
60
|
+
sync_up
|
61
|
+
host = WorkspaceConfiguration.host_config["host"]
|
62
|
+
host_path = WorkspaceConfiguration.config["host_path"]
|
63
|
+
SshHelper.exec(host, host_path, argv)
|
64
|
+
sync_down
|
65
|
+
end
|
66
|
+
map 'e' => :exec
|
67
|
+
|
47
68
|
desc "init", "inits"
|
48
69
|
def init
|
49
70
|
WorkspaceConfiguration.init!
|
50
71
|
end
|
72
|
+
|
73
|
+
desc "port_forward", "ssh and port_forward"
|
74
|
+
def port_forward
|
75
|
+
host = WorkspaceConfiguration.host_config["host"]
|
76
|
+
host_path = WorkspaceConfiguration.config["host_path"]
|
77
|
+
PortForwarder.start_or_skip(WorkspaceConfiguration.host_config)
|
78
|
+
SshHelper.attach(host, host_path)
|
79
|
+
end
|
80
|
+
map 'pf' => :port_forward
|
51
81
|
end
|
52
82
|
end
|
@@ -20,10 +20,22 @@ module RemoteSh
|
|
20
20
|
Filewatcher.new("#{local_path}/**/{.[^\.]*,*}", interval: 1).watch do |_changes|
|
21
21
|
if @sync_side == :client || @sync_side.nil?
|
22
22
|
mutex.synchronize do
|
23
|
-
@sync_side = :
|
24
|
-
|
23
|
+
@sync_side = :clientA
|
24
|
+
begin
|
25
|
+
RsyncHelper.up(local_path, host_path, host, ignored_files)
|
26
|
+
@up_requested = false
|
27
|
+
rescue
|
28
|
+
@up_requested = true
|
29
|
+
end
|
25
30
|
do_after_timeout(1) do
|
26
|
-
|
31
|
+
begin
|
32
|
+
RsyncHelper.up(local_path, host_path, host, ignored_files) if @up_requested
|
33
|
+
rescue
|
34
|
+
end
|
35
|
+
|
36
|
+
mutex.synchronize do
|
37
|
+
@sync_side = nil
|
38
|
+
end
|
27
39
|
end
|
28
40
|
end
|
29
41
|
end
|
@@ -89,8 +101,17 @@ module RemoteSh
|
|
89
101
|
if @sync_side == :server || @sync_side.nil?
|
90
102
|
mutex.synchronize do
|
91
103
|
@sync_side = :server
|
92
|
-
|
104
|
+
begin
|
105
|
+
RsyncHelper.down(local_path, host_path, host, ignored_files)
|
106
|
+
@down_requested = false
|
107
|
+
rescue
|
108
|
+
@down_requested = true
|
109
|
+
end
|
93
110
|
do_after_timeout(1) do
|
111
|
+
begin
|
112
|
+
RsyncHelper.down(local_path, host_path, host, ignored_files) if @down_requested
|
113
|
+
rescue
|
114
|
+
end
|
94
115
|
mutex.synchronize { @sync_side = nil }
|
95
116
|
end
|
96
117
|
end
|
@@ -38,6 +38,8 @@ module RemoteSh
|
|
38
38
|
)
|
39
39
|
SshHelper.current_ports(host_host, remote_blacklist_ports + local_opened_ports).each { |port| SshHelper.close_port(host_host, port) }
|
40
40
|
current_ports(local_blacklisted_ports + remote_opened_ports).each { |port| SshHelper.close_local_port(host_host, port) }
|
41
|
+
rescue
|
42
|
+
start_or_skip(host_config)
|
41
43
|
ensure
|
42
44
|
SshHelper
|
43
45
|
.current_ports(host_host, remote_blacklist_ports)
|
data/lib/remote_sh/ssh_helper.rb
CHANGED
@@ -9,6 +9,11 @@ module RemoteSh
|
|
9
9
|
system("ssh -t #{host} \"cd #{dir}; exec \$SHELL -l\"")
|
10
10
|
end
|
11
11
|
|
12
|
+
def exec(host, dir, args)
|
13
|
+
cmd = "cd #{dir}; #{args.join(' ')}"
|
14
|
+
system("ssh -t -q #{host} \"#{cmd}\"")
|
15
|
+
end
|
16
|
+
|
12
17
|
def current_ports(host, blacklist_ports)
|
13
18
|
`ssh #{host} "netstat -tuln | grep LISTEN"`
|
14
19
|
.split("\n")
|
data/lib/remote_sh/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: remote_sh
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pavel Egorov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-01-
|
11
|
+
date: 2025-01-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: filewatcher
|