Sha256: 9e34b027dbded9311a389b98313e20390522a76fdca8e13a3d6e8ac686db2494

Contents?: true

Size: 1.37 KB

Versions: 23

Compression:

Stored size: 1.37 KB

Contents

class Capistrano::Configuration
  def execute(command, failure_message = "Command failed")
    puts "Executing: #{command}"
    system(command) || raise(failure_message)
  end
end

Capistrano::Configuration.instance(:must_exist).load do
  namespace :rsync do
    desc <<-DESC
    use rsync to sync assets locally or between servers
    DESC
    task :pull_shared , :roles => :app do
      servers = find_servers :roles => :app, :except => { :no_release => true }
      server = servers.first
      if server
        symlink_dirs.each do |share|
          `echo '#{password}' | /usr/bin/pbcopy`
          execute( "rsync -P -a -h -e 'ssh -p #{server.port || 22}' #{user}@#{server.host}:#{shared_path}/#{share}/* #{share}", "unable to run rsync files")
        end
      else
        puts 'no server found'
      end
    end

    desc <<-DESC
    use rsync to sync assets locally or between servers
    DESC
    task :push_shared , :roles => :app do
      servers = find_servers :roles => :app, :except => { :no_release => true }
      server = servers.first
      if server
        symlink_dirs.each do |share|
          `echo '#{password}' | /usr/bin/pbcopy`
          execute( "rsync -P -a -h -e 'ssh -p #{server.port || 22}' #{share}/* #{user}@#{server.host}:#{shared_path}/#{share}/", "unable to run rsync files")
        end
      else
        puts 'no server found'
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 2 rubygems

Version Path
fdlcap-0.3.30 lib/fdlcap/recipes/rsync.rb
fdlcap-0.3.29 lib/fdlcap/recipes/rsync.rb
fdlcap-0.3.28 lib/fdlcap/recipes/rsync.rb