Skip to content

Commit

Permalink
Allow passing options to SSH command in rsync mode
Browse files Browse the repository at this point in the history
The same method you use to pass flags to the rsync command itself whould
be useful to the ssh command passed to rsync as the `-e ssh` flag.
  • Loading branch information
rwillrich committed Aug 17, 2015
1 parent 243ab38 commit 5040244
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@ activate :deploy do |deploy|
deploy.host = 'www.example.com'
deploy.path = '/srv/www/site'
# Optional Settings
# deploy.user = 'tvaughan' # no default
# deploy.port = 5309 # ssh port, default: 22
# deploy.clean = true # remove orphaned files on remote host, default: false
# deploy.flags = '-rltgoDvzO --no-p --del' # add custom flags, default: -avz
# deploy.user = 'tvaughan' # no default
# deploy.port = 5309 # ssh port, default: 22
# deploy.clean = true # remove orphaned files on remote host, default: false
# deploy.flags = '-rltgoDvzO --no-p --del' # add custom flags, default: -avz
# deploy.ssh_flags = '-o UserKnownHostsFile=~/.ssh/known_hosts' # add custom ssh flags, no default
end
```

Expand Down
1 change: 1 addition & 0 deletions lib/middleman-deploy/extension.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class Extension < Extension
option :build_before, nil
option :flags, nil
option :commit_message, nil
option :ssh_flags, nil

def initialize(app, options_hash = {}, &block)
super
Expand Down
15 changes: 8 additions & 7 deletions lib/middleman-deploy/methods/rsync.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ class Rsync < Base
def initialize(server_instance, options = {})
super(server_instance, options)

@clean = self.options.clean
@flags = self.options.flags
@host = self.options.host
@path = self.options.path
@port = self.options.port
@user = self.options.user
@clean = self.options.clean
@flags = self.options.flags
@host = self.options.host
@path = self.options.path
@port = self.options.port
@user = self.options.user
@ssh_flags = self.options.ssh_flags
end

def process
Expand All @@ -21,7 +22,7 @@ def process

dest_url = "#{user}#{host}:#{path}"
flags = self.flags || '-avz'
command = "rsync #{flags} '-e ssh -p #{port}' #{build_dir}/ #{dest_url}"
command = "rsync #{flags} '-e ssh -p #{port} #{@ssh_flags}' #{build_dir}/ #{dest_url}"

command += ' --delete' if clean

Expand Down

0 comments on commit 5040244

Please sign in to comment.