From b111cb6392a4362463dcf762f61e0dc08c72f642 Mon Sep 17 00:00:00 2001 From: Tore Darell Date: Sat, 11 May 2013 16:11:57 +0200 Subject: [PATCH] Emit 'vagrant-mounted' on Ubuntu in mount_virtualbox_shared_folder capability Also includes the same, but commented out, for mount_nfs capability --- plugins/guests/ubuntu/cap/mount_nfs.rb | 18 ++++++++++++++++++ .../cap/mount_virtualbox_shared_folder.rb | 14 ++++++++++++++ plugins/guests/ubuntu/plugin.rb | 11 +++++++++++ 3 files changed, 43 insertions(+) create mode 100644 plugins/guests/ubuntu/cap/mount_nfs.rb create mode 100644 plugins/guests/ubuntu/cap/mount_virtualbox_shared_folder.rb diff --git a/plugins/guests/ubuntu/cap/mount_nfs.rb b/plugins/guests/ubuntu/cap/mount_nfs.rb new file mode 100644 index 000000000..917be8e56 --- /dev/null +++ b/plugins/guests/ubuntu/cap/mount_nfs.rb @@ -0,0 +1,18 @@ +require_relative '../../linux/cap/mount_nfs' + +module VagrantPlugins + module GuestUbuntu + module Cap + class MountNFS < GuestLinux::Cap::MountNFS + def self.mount_nfs_folder(machine, ip, folders) + super + # Emit an upstart events if upstart is available + folders.each do |name, opts| + real_guestpath = machine.guest.capability(:shell_expand_guest_path, opts[:guestpath]) + machine.communicate.sudo("[ -x /sbin/initctl ] && /sbin/initctl emit vagrant-mounted MOUNTPOINT=#{real_guestpath}") + end + end + end + end + end +end diff --git a/plugins/guests/ubuntu/cap/mount_virtualbox_shared_folder.rb b/plugins/guests/ubuntu/cap/mount_virtualbox_shared_folder.rb new file mode 100644 index 000000000..d72786535 --- /dev/null +++ b/plugins/guests/ubuntu/cap/mount_virtualbox_shared_folder.rb @@ -0,0 +1,14 @@ +require_relative '../../linux/cap/mount_virtualbox_shared_folder' + +module VagrantPlugins + module GuestUbuntu + module Cap + class MountVirtualBoxSharedFolder < GuestLinux::Cap::MountVirtualBoxSharedFolder + def self.mount_virtualbox_shared_folder(machine, name, guestpath, options) + super + machine.communicate.sudo("[ -x /sbin/initctl ] && /sbin/initctl emit vagrant-mounted MOUNTPOINT=#{guestpath}") + end + end + end + end +end diff --git a/plugins/guests/ubuntu/plugin.rb b/plugins/guests/ubuntu/plugin.rb index 38e054972..40927f00b 100644 --- a/plugins/guests/ubuntu/plugin.rb +++ b/plugins/guests/ubuntu/plugin.rb @@ -15,6 +15,17 @@ module VagrantPlugins require_relative "cap/change_host_name" Cap::ChangeHostName end + + guest_capability("ubuntu", "mount_virtualbox_shared_folder") do + require_relative "cap/mount_virtualbox_shared_folder" + Cap::MountVirtualBoxSharedFolder + end + + #I don't know if this works or not + #guest_capability("linux", "mount_nfs_folder") do + # require_relative "cap/mount_nfs" + # Cap::MountNFS + #end end end end