From c76f7d060f848466fdada6e392ac3e815157db92 Mon Sep 17 00:00:00 2001 From: Joshua Young Date: Mon, 22 Jan 2024 16:27:24 +1000 Subject: [PATCH] Add option for custom ssh config --- README.md | 2 ++ exe/entangler | 4 ++++ lib/entangler/executor/master.rb | 9 +++++++-- lib/entangler/version.rb | 2 +- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index e0bd52b..7234004 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/exe/entangler b/exe/entangler index c27ff8a..e4479fb 100755 --- a/exe/entangler +++ b/exe/entangler @@ -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)") @@ -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] diff --git a/lib/entangler/executor/master.rb b/lib/entangler/executor/master.rb index b8389f5..73199d6 100644 --- a/lib/entangler/executor/master.rb +++ b/lib/entangler/executor/master.rb @@ -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 @@ -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 diff --git a/lib/entangler/version.rb b/lib/entangler/version.rb index ed48e51..05da81d 100644 --- a/lib/entangler/version.rb +++ b/lib/entangler/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Entangler - VERSION = '1.5.0' + VERSION = '1.5.1' end