2014-01-11 01:51:44 +00:00
|
|
|
module VagrantPlugins
|
|
|
|
module GuestLinux
|
|
|
|
module Cap
|
|
|
|
class RSync
|
2014-01-31 03:26:43 +00:00
|
|
|
def self.rsync_installed(machine)
|
|
|
|
machine.communicate.test("which rsync")
|
|
|
|
end
|
|
|
|
|
2014-03-13 16:47:34 +00:00
|
|
|
def self.rsync_pre(machine, opts)
|
2014-01-11 01:51:44 +00:00
|
|
|
username = machine.ssh_info[:username]
|
|
|
|
|
|
|
|
machine.communicate.tap do |comm|
|
2014-03-13 16:47:34 +00:00
|
|
|
comm.sudo("mkdir -p '#{opts[:guestpath]}'")
|
2014-03-13 16:48:22 +00:00
|
|
|
comm.sudo("find '#{opts[:guestpath]}' ! -user #{username} -print0 | " +
|
2014-03-13 16:47:34 +00:00
|
|
|
"xargs -0 -r chown -v #{username}:")
|
2014-01-11 01:51:44 +00:00
|
|
|
end
|
|
|
|
end
|
2014-03-13 01:43:59 +00:00
|
|
|
|
|
|
|
def self.rsync_post(machine, opts)
|
|
|
|
machine.communicate.tap do |comm|
|
2014-04-09 18:03:24 +00:00
|
|
|
comm.sudo("find '#{opts[:guestpath]}' ! -user #{opts[:owner]} -or ! -group #{opts[:group]} -print0 | " +
|
2014-03-13 16:47:34 +00:00
|
|
|
"xargs -0 -r chown -v #{opts[:owner]}:#{opts[:group]}")
|
2014-03-13 01:43:59 +00:00
|
|
|
end
|
|
|
|
end
|
2014-01-11 01:51:44 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|