Created
February 19, 2015 21:00
-
-
Save phoet/0280157c61ac39cfb6a7 to your computer and use it in GitHub Desktop.
Running Vagrant with inverted NFS directories
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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