Skip to content

Commit

Permalink
Add option for custom ssh config (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuay03 committed Jan 23, 2024
1 parent 0b870b9 commit d966d3a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ Options:
All paths should be relative to the base sync directory.
-p, --port PORT Overwrite the SSH port (usually 22)
(doesn't do anything in slave mode)
-c, --config PATH Use a custom SSH config (usually $HOME/.ssh/config)
(doesn't do anything in slave mode)
--force-polling Forces the use of the listen polling adapter
(works cross-platform, generally slower, doesn't do anything in slave mode)
--no-rvm Skip attempting to load RVM on remote
Expand Down
4 changes: 4 additions & 0 deletions exe/entangler
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ OptionParser.new do |opts|
value_opt(options, opts, :port, '-p', '--port PORT', 'Overwrite the SSH port (usually 22)',
"(doesn't do anything in slave mode)")

value_opt(options, opts, :config, '-c', '--config PATH', 'Use a custom SSH config (usually $HOME/.ssh/config)',
"(doesn't do anything in slave mode)")

bool_opt(options, opts, :force_polling, '--force-polling',
'Forces the use of the listen polling adapter',
"(works cross-platform, generally slower, doesn't do anything in slave mode)")
Expand Down Expand Up @@ -124,6 +127,7 @@ if options[:ignore]
end
end

opts[:config] = options[:config]
opts[:force_polling] = options[:force_polling]
opts[:no_rvm] = options[:no_rvm]
opts[:quiet] = options[:quiet]
Expand Down
9 changes: 7 additions & 2 deletions lib/entangler/executor/master.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ def generate_ssh_command(cmd, source_rvm: false)
cmd
end

"ssh -q #{remote_hostname} -p #{@opts[:remote_port]} -C \"#{prefixed_cmd}\""
ssh = "ssh -q #{remote_hostname} -p #{@opts[:remote_port]}"
ssh += " -F #{@opts[:config]}" if @opts[:config]
ssh + " -C \"#{prefixed_cmd}\""
end

def remote_hostname
Expand All @@ -83,7 +85,10 @@ def rsync_cmd_string(rsync_ignores_file_path)
remote_path += "#{@opts[:remote_base_dir]}/"

cmd = "rsync -azv --exclude-from #{rsync_ignores_file_path}"
cmd += " -e \"ssh -p #{@opts[:remote_port]}\"" if @opts[:remote_mode]
if @opts[:remote_mode]
config = @opts[:config] ? "-F #{@opts[:config]}" : ''
cmd += " -e \"ssh -p #{@opts[:remote_port]} #{config}\""
end
cmd + " --delete #{base_dir}/ #{remote_path}"
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/entangler/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module Entangler
VERSION = '1.5.0'
VERSION = '1.5.1'
end

0 comments on commit d966d3a

Please sign in to comment.