diff --git a/lib/vagrant-sshfs/cap/guest/freebsd/sshfs_client.rb b/lib/vagrant-sshfs/cap/guest/freebsd/sshfs_client.rb new file mode 100644 index 0000000..bf0e0fa --- /dev/null +++ b/lib/vagrant-sshfs/cap/guest/freebsd/sshfs_client.rb @@ -0,0 +1,22 @@ +module VagrantPlugins + module GuestFreeBSD + module Cap + class SSHFSClient + def self.sshfs_install(machine) + machine.communicate.sudo("pkg install -y fusefs-sshfs") + machine.communicate.sudo("kldload fuse") + end + + def self.sshfs_installed(machine) + installed = machine.communicate.test("pkg info fusefs-sshfs") + if installed + # fuse may not get loaded at boot, so check if it's loaded otherwise force load it + machine.communicate.sudo("kldstat -m fuse || kldload fuse") + end + + installed + end + end + end + end +end diff --git a/lib/vagrant-sshfs/cap/guest/freebsd/sshfs_forward_mount.rb b/lib/vagrant-sshfs/cap/guest/freebsd/sshfs_forward_mount.rb new file mode 100644 index 0000000..34ac8ba --- /dev/null +++ b/lib/vagrant-sshfs/cap/guest/freebsd/sshfs_forward_mount.rb @@ -0,0 +1,13 @@ +require_relative "../linux/sshfs_forward_mount" + +module VagrantPlugins + module GuestFreeBSD + module Cap + class MountSSHFS < VagrantPlugins::GuestLinux::Cap::MountSSHFS + def self.list_mounts_command + "mount -p" + end + end + end + end +end diff --git a/lib/vagrant-sshfs/cap/guest/linux/sshfs_forward_mount.rb b/lib/vagrant-sshfs/cap/guest/linux/sshfs_forward_mount.rb index 0e55d61..cf73497 100644 --- a/lib/vagrant-sshfs/cap/guest/linux/sshfs_forward_mount.rb +++ b/lib/vagrant-sshfs/cap/guest/linux/sshfs_forward_mount.rb @@ -16,6 +16,10 @@ class MountSSHFS extend Vagrant::Util::Retryable @@logger = Log4r::Logger.new("vagrant::synced_folders::sshfs_mount") + def self.list_mounts_command + "cat /proc/mounts" + end + def self.sshfs_forward_is_folder_mounted(machine, opts) mounted = false guest_path = opts[:guestpath] @@ -31,7 +35,7 @@ def self.sshfs_forward_is_folder_mounted(machine, opts) :sshfs_get_absolute_path, guest_path) # consult /proc/mounts to see if it is mounted or not - machine.communicate.execute("cat /proc/mounts") do |type, data| + machine.communicate.execute(self.list_mounts_command) do |type, data| if type == :stdout data.each_line do |line| if line.split()[1] == absolute_guest_path diff --git a/lib/vagrant-sshfs/plugin.rb b/lib/vagrant-sshfs/plugin.rb index 3ab61ad..28f754c 100644 --- a/lib/vagrant-sshfs/plugin.rb +++ b/lib/vagrant-sshfs/plugin.rb @@ -120,6 +120,35 @@ class Plugin < Vagrant.plugin("2") VagrantPlugins::GuestSUSE::Cap::SSHFSClient end + guest_capability("freebsd", "sshfs_forward_mount_folder") do + require_relative "cap/guest/freebsd/sshfs_forward_mount" + VagrantPlugins::GuestFreeBSD::Cap::MountSSHFS + end + + guest_capability("freebsd", "sshfs_forward_unmount_folder") do + require_relative "cap/guest/freebsd/sshfs_forward_mount" + VagrantPlugins::GuestFreeBSD::Cap::MountSSHFS + end + + guest_capability("freebsd", "sshfs_forward_is_folder_mounted") do + require_relative "cap/guest/freebsd/sshfs_forward_mount" + VagrantPlugins::GuestFreeBSD::Cap::MountSSHFS + end + + guest_capability("freebsd", "sshfs_get_absolute_path") do + require_relative "cap/guest/linux/sshfs_get_absolute_path" + VagrantPlugins::GuestLinux::Cap::SSHFSGetAbsolutePath + end + + guest_capability("freebsd", "sshfs_install") do + require_relative "cap/guest/freebsd/sshfs_client" + VagrantPlugins::GuestFreeBSD::Cap::SSHFSClient + end + + guest_capability("freebsd", "sshfs_installed") do + require_relative "cap/guest/freebsd/sshfs_client" + VagrantPlugins::GuestFreeBSD::Cap::SSHFSClient + end end end end