Skip to content

Commit

Permalink
Add freebsd support
Browse files Browse the repository at this point in the history
  • Loading branch information
the-eater committed May 18, 2017
1 parent 6def99b commit 0c53e4f
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 1 deletion.
22 changes: 22 additions & 0 deletions lib/vagrant-sshfs/cap/guest/freebsd/sshfs_client.rb
Original file line number Diff line number Diff line change
@@ -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
13 changes: 13 additions & 0 deletions lib/vagrant-sshfs/cap/guest/freebsd/sshfs_forward_mount.rb
Original file line number Diff line number Diff line change
@@ -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
6 changes: 5 additions & 1 deletion lib/vagrant-sshfs/cap/guest/linux/sshfs_forward_mount.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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
Expand Down
29 changes: 29 additions & 0 deletions lib/vagrant-sshfs/plugin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 0c53e4f

Please sign in to comment.