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
|
```ruby
|
||||||
activate :deploy do |deploy|
|
activate :deploy do |deploy|
|
||||||
deploy.method = :rsync
|
deploy.method = :rsync
|
||||||
deploy.user = "tvaughan"
|
|
||||||
deploy.host = "www.example.com"
|
deploy.host = "www.example.com"
|
||||||
deploy.path = "/srv/www/site"
|
deploy.path = "/srv/www/site"
|
||||||
# Optional Settings
|
# Optional Settings
|
||||||
|
# deploy.user = "tvaughan" # no default
|
||||||
# deploy.port = 5309 # ssh port, default: 22
|
# deploy.port = 5309 # ssh port, default: 22
|
||||||
# deploy.clean = true # remove orphaned files on remote host, default: false
|
# deploy.clean = true # remove orphaned files on remote host, default: false
|
||||||
end
|
end
|
||||||
|
|
|
@ -49,10 +49,11 @@ extension in config.rb.
|
||||||
# To deploy the build directory to a remote host via rsync:
|
# To deploy the build directory to a remote host via rsync:
|
||||||
activate :deploy do |deploy|
|
activate :deploy do |deploy|
|
||||||
deploy.method = :rsync
|
deploy.method = :rsync
|
||||||
# host, user, and path *must* be set
|
# host and path *must* be set
|
||||||
deploy.user = "tvaughan"
|
|
||||||
deploy.host = "www.example.com"
|
deploy.host = "www.example.com"
|
||||||
deploy.path = "/srv/www/site"
|
deploy.path = "/srv/www/site"
|
||||||
|
# user is optional (no default)
|
||||||
|
deploy.user = "tvaughan"
|
||||||
# clean is optional (default is false)
|
# clean is optional (default is false)
|
||||||
deploy.clean = true
|
deploy.clean = true
|
||||||
end
|
end
|
||||||
|
@ -109,8 +110,8 @@ EOF
|
||||||
|
|
||||||
case options.method
|
case options.method
|
||||||
when :rsync
|
when :rsync
|
||||||
if (!options.host || !options.user || !options.path)
|
if (!options.host || !options.path)
|
||||||
print_usage_and_die "The rsync deploy method requires host, user, and path to be set."
|
print_usage_and_die "The rsync deploy method requires host and path to be set."
|
||||||
end
|
end
|
||||||
when :ftp, :sftp
|
when :ftp, :sftp
|
||||||
if (!options.host || !options.user || !options.password || !options.path)
|
if (!options.host || !options.user || !options.password || !options.path)
|
||||||
|
@ -124,12 +125,17 @@ EOF
|
||||||
def deploy_rsync
|
def deploy_rsync
|
||||||
host = self.deploy_options.host
|
host = self.deploy_options.host
|
||||||
port = self.deploy_options.port
|
port = self.deploy_options.port
|
||||||
user = self.deploy_options.user
|
|
||||||
path = self.deploy_options.path
|
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
|
if self.deploy_options.clean
|
||||||
command += " --delete"
|
command += " --delete"
|
||||||
|
|
Loading…
Reference in a new issue