2013-09-03 18:01:12 +00:00
|
|
|
module VagrantPlugins
|
|
|
|
module FileUpload
|
|
|
|
class Provisioner < Vagrant.plugin("2", :provisioner)
|
|
|
|
def provision
|
|
|
|
@machine.communicate.tap do |comm|
|
2014-02-01 04:23:09 +00:00
|
|
|
destination = expand_guest_path(config.destination)
|
|
|
|
|
2013-09-03 18:01:12 +00:00
|
|
|
# Make sure the remote path exists
|
2014-02-01 04:23:09 +00:00
|
|
|
command = "mkdir -p %s" % File.dirname(destination)
|
|
|
|
comm.execute(command)
|
2013-09-03 18:01:12 +00:00
|
|
|
|
|
|
|
# now upload the file
|
2014-02-01 04:23:09 +00:00
|
|
|
comm.upload(File.expand_path(config.source), destination)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
# Expand the guest path if the guest has the capability
|
|
|
|
def expand_guest_path(destination)
|
|
|
|
if machine.guest.capability?(:shell_expand_guest_path)
|
|
|
|
machine.guest.capability(:shell_expand_guest_path, destination)
|
|
|
|
else
|
|
|
|
destination
|
2013-09-03 18:01:12 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|