remote_sh 0.1.7 → 0.1.8
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/lib/remote_sh/cli.rb +19 -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: 67423d9a51157d17c0945130089f3a92504d3c3748fc9fcff1342fec5fe1c84e
|
4
|
+
data.tar.gz: 65e267157add7333bc4cbb95404f0e68c2b0a423252223b315a292de7b1ce3a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4893611c20ccd6f49f65b97cdd6a68e02d20b2818df22e4b2204076d545061eb42feab92fb3536023adf5ef76576923cd3f0fec48a1e0772ae458e385f103523
|
7
|
+
data.tar.gz: 3145547a5e731b1dd2d03128be41eadf9123c24622e4ff4020c9b8ffc8ae6898917129652ef569252c733f806fed3b27e692dd52b98ecb87f7469df15fc740ae
|
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,6 +45,24 @@ 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
|
+
host = WorkspaceConfiguration.host_config["host"]
|
61
|
+
host_path = WorkspaceConfiguration.config["host_path"]
|
62
|
+
SshHelper.exec(host, host_path, argv)
|
63
|
+
end
|
64
|
+
map 'e' => :exec
|
65
|
+
|
47
66
|
desc "init", "inits"
|
48
67
|
def init
|
49
68
|
WorkspaceConfiguration.init!
|
@@ -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.8
|
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-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: filewatcher
|