2010-07-11 05:07:10 +00:00
|
|
|
module Vagrant
|
|
|
|
module Hosts
|
|
|
|
# Represents a BSD host, such as FreeBSD and Darwin (Mac OS X).
|
|
|
|
class BSD < Base
|
2010-07-13 05:10:17 +00:00
|
|
|
include Util
|
|
|
|
|
2010-07-12 04:33:49 +00:00
|
|
|
def nfs?
|
2010-07-14 04:41:29 +00:00
|
|
|
system("which nfsd > /dev/null 2>&1")
|
2010-07-13 05:41:41 +00:00
|
|
|
$?.to_i == 0
|
2010-07-14 03:30:24 +00:00
|
|
|
rescue TypeError
|
|
|
|
false
|
2010-07-12 04:33:49 +00:00
|
|
|
end
|
2010-07-13 05:10:17 +00:00
|
|
|
|
|
|
|
def nfs_export(ip, folders)
|
|
|
|
output = TemplateRenderer.render('nfs/exports',
|
|
|
|
:uuid => env.vm.uuid,
|
|
|
|
:ip => ip,
|
|
|
|
:folders => folders)
|
|
|
|
|
|
|
|
env.logger.info "Preparing to edit /etc/exports. Administrator priveleges will be required..."
|
|
|
|
output.split("\n").each do |line|
|
|
|
|
# This should only ask for administrative permission once, even
|
|
|
|
# though its executed in multiple subshells.
|
|
|
|
system(%Q[sudo su root -c "echo '#{line}' >> /etc/exports"])
|
|
|
|
end
|
2010-07-13 05:37:24 +00:00
|
|
|
|
|
|
|
# We run restart here instead of "update" just in case nfsd
|
|
|
|
# is not starting
|
|
|
|
system("sudo nfsd restart")
|
2010-07-13 05:10:17 +00:00
|
|
|
end
|
2010-07-11 05:07:10 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|