Let user be optional in the rsync method.
This commit is contained in:
parent
87b71cc7c9
commit
d749a99fbe
2 changed files with 14 additions and 8 deletions
|
@ -42,10 +42,10 @@ following to `config.rb`:
|
|||
```ruby
|
||||
activate :deploy do |deploy|
|
||||
deploy.method = :rsync
|
||||
deploy.user = "tvaughan"
|
||||
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
|
||||
end
|
||||
|
|
|
@ -49,10 +49,11 @@ extension in config.rb.
|
|||
# To deploy the build directory to a remote host via rsync:
|
||||
activate :deploy do |deploy|
|
||||
deploy.method = :rsync
|
||||
# host, user, and path *must* be set
|
||||
deploy.user = "tvaughan"
|
||||
# host and path *must* be set
|
||||
deploy.host = "www.example.com"
|
||||
deploy.path = "/srv/www/site"
|
||||
# user is optional (no default)
|
||||
deploy.user = "tvaughan"
|
||||
# clean is optional (default is false)
|
||||
deploy.clean = true
|
||||
end
|
||||
|
@ -109,8 +110,8 @@ EOF
|
|||
|
||||
case options.method
|
||||
when :rsync
|
||||
if (!options.host || !options.user || !options.path)
|
||||
print_usage_and_die "The rsync deploy method requires host, user, and path to be set."
|
||||
if (!options.host || !options.path)
|
||||
print_usage_and_die "The rsync deploy method requires host and path to be set."
|
||||
end
|
||||
when :ftp, :sftp
|
||||
if (!options.host || !options.user || !options.password || !options.path)
|
||||
|
@ -124,12 +125,17 @@ EOF
|
|||
def deploy_rsync
|
||||
host = self.deploy_options.host
|
||||
port = self.deploy_options.port
|
||||
user = self.deploy_options.user
|
||||
path = self.deploy_options.path
|
||||
|
||||
puts "## Deploying via rsync to #{user}@#{host}:#{path} port=#{port}"
|
||||
# Append "@" to user if provided.
|
||||
user = self.deploy_options.user
|
||||
user = "#{user}@" if user && !user.empty?
|
||||
|
||||
command = "rsync -avze '" + "ssh -p #{port}" + "' #{self.inst.build_dir}/ #{user}@#{host}:#{path}"
|
||||
dest_url = "#{user}#{host}:#{path}"
|
||||
|
||||
puts "## Deploying via rsync to #{dest_url} port=#{port}"
|
||||
|
||||
command = "rsync -avze '" + "ssh -p #{port}" + "' #{self.inst.build_dir}/ #{dest_url}"
|
||||
|
||||
if self.deploy_options.clean
|
||||
command += " --delete"
|
||||
|
|
Loading…
Reference in a new issue