Skip to content

Commit

Permalink
Merge pull request #21 from fabiokr/feature/check
Browse files Browse the repository at this point in the history
Checks if the sshfs command is available
  • Loading branch information
fabiokr committed May 26, 2014
2 parents 068d94a + 2e974dd commit eeeb4df
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
4 changes: 4 additions & 0 deletions 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*
Expand Down
12 changes: 11 additions & 1 deletion lib/vagrant-sshfs/builders/host.rb
Expand Up @@ -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
Expand All @@ -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"
Expand Down
1 change: 1 addition & 0 deletions locales/en.yml
Expand Up @@ -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."

0 comments on commit eeeb4df

Please sign in to comment.