Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow passing options to SSH command in rsync mode #94

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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