Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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