Skip to content

Instantly share code, notes, and snippets.

@phoet
Created February 19, 2015 21:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phoet/0280157c61ac39cfb6a7 to your computer and use it in GitHub Desktop.
Save phoet/0280157c61ac39cfb6a7 to your computer and use it in GitHub Desktop.
Running Vagrant with inverted NFS directories
config.export_nfs.each do |export|
config.trigger.before :halt, stdout: true do
mount_point = export[1]
system("sudo umount -f #{mount_point}")
end
config.trigger.after [:up, :reload], stdout: true do
remote_point = "#{PRIVATE_IP}:#{export[0]}"
mount_point = export[1]
puts "mounting #{remote_point} to #{mount_point}"
unless Dir.exists?(mount_point)
Dir.mkdir(mount_point)
end
8.times do |attempt|
if system("sudo mount -t nfs -o rw,noatime,intr,nfc #{remote_point} #{mount_point} > /dev/null 2>&1")
print "done!\n"
break
end
print "."
sleep(1/0.6**attempt)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment