diff --git a/CHANGELOG.md b/CHANGELOG.md index c3f7799..ecff7dd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ ## vagrant-sshfs 0.0.6 ## +* Checks if the `sshfs` command is available + + *Fabio Kreusch* + * Unmount/mount on vagrant reload *Fabio Kreusch* diff --git a/lib/vagrant-sshfs/builders/host.rb b/lib/vagrant-sshfs/builders/host.rb index 747c632..864889e 100644 --- a/lib/vagrant-sshfs/builders/host.rb +++ b/lib/vagrant-sshfs/builders/host.rb @@ -15,7 +15,7 @@ def unmount(target) end def mount(src, target) - `sshfs -p #{port} #{username}@#{host}:#{check_src!(src)} #{check_target!(target)} -o IdentityFile=#{private_key}` + `#{sshfs_bin} -p #{port} #{username}@#{host}:#{check_src!(src)} #{check_target!(target)} -o IdentityFile=#{private_key}` end def ssh_info @@ -38,6 +38,16 @@ def private_key Array(ssh_info[:private_key_path]).first end + def sshfs_bin + bin = `which sshfs`.chomp + + if bin.empty? + error("bin_not_found") + else + bin + end + end + def check_src!(src) unless machine.communicate.test("test -d #{src}") if ask("create_src", src: src) == "y" diff --git a/locales/en.yml b/locales/en.yml index d8bb05c..8aee7f3 100644 --- a/locales/en.yml +++ b/locales/en.yml @@ -18,3 +18,4 @@ en: not_created_src: "Source folder `%{src}` was not created" not_created_target: "Target folder `%{target}` was not created" not_mounted: "Error when mounting `%{src}` to `%{target}`" + bin_not_found: "Could not find sshfs bin in the host machine. Please make sure it is installed."