2014-01-11 01:40:29 +00:00
|
|
|
require "log4r"
|
|
|
|
|
|
|
|
require "vagrant/util/subprocess"
|
|
|
|
require "vagrant/util/which"
|
|
|
|
|
2014-01-13 19:01:50 +00:00
|
|
|
require_relative "helper"
|
|
|
|
|
2014-01-11 01:40:29 +00:00
|
|
|
module VagrantPlugins
|
|
|
|
module SyncedFolderRSync
|
|
|
|
class SyncedFolder < Vagrant.plugin("2", :synced_folder)
|
|
|
|
include Vagrant::Util
|
|
|
|
|
|
|
|
def initialize(*args)
|
|
|
|
super
|
|
|
|
|
|
|
|
@logger = Log4r::Logger.new("vagrant::synced_folders::rsync")
|
|
|
|
end
|
|
|
|
|
|
|
|
def usable?(machine, raise_error=false)
|
|
|
|
rsync_path = Which.which("rsync")
|
|
|
|
return true if rsync_path
|
|
|
|
return false if !raise_error
|
|
|
|
raise Vagrant::Errors::RSyncNotFound
|
|
|
|
end
|
|
|
|
|
|
|
|
def prepare(machine, folders, opts)
|
|
|
|
# Nothing is necessary to do before VM boot.
|
|
|
|
end
|
|
|
|
|
|
|
|
def enable(machine, folders, opts)
|
|
|
|
ssh_info = machine.ssh_info
|
|
|
|
|
2014-01-11 04:37:11 +00:00
|
|
|
if ssh_info[:private_key_path].empty? && ssh_info[:password]
|
|
|
|
machine.ui.warn(I18n.t("vagrant.rsync_ssh_password"))
|
|
|
|
end
|
|
|
|
|
2014-01-11 01:40:29 +00:00
|
|
|
folders.each do |id, folder_opts|
|
2014-01-13 19:01:50 +00:00
|
|
|
RsyncHelper.rsync_single(machine, ssh_info, folder_opts)
|
2014-01-11 01:40:29 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|