2014-01-16 15:25:40 +01:00
|
|
|
module Middleman
|
|
|
|
module Deploy
|
|
|
|
module Methods
|
|
|
|
class Rsync < Base
|
|
|
|
|
|
|
|
attr_reader :clean, :flags, :host, :path, :port, :user
|
|
|
|
|
|
|
|
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
|
|
|
|
end
|
|
|
|
|
|
|
|
def process
|
|
|
|
# Append "@" to user if provided.
|
|
|
|
user = "#{self.user}@" if self.user && !self.user.empty?
|
|
|
|
|
|
|
|
dest_url = "#{user}#{self.host}:#{self.path}"
|
2014-02-23 15:26:27 +01:00
|
|
|
flags = self.flags || '-avz'
|
|
|
|
command = "rsync #{flags} '-e ssh -p #{self.port}' #{self.server_instance.build_dir}/ #{dest_url}"
|
2014-01-16 15:25:40 +01:00
|
|
|
|
|
|
|
if self.clean
|
|
|
|
command += " --delete"
|
|
|
|
end
|
|
|
|
|
|
|
|
puts "## Deploying via rsync to #{dest_url} port=#{self.port}"
|
2014-02-26 12:04:08 +01:00
|
|
|
exec command
|
2014-01-16 15:25:40 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|