vagrant/lib/vagrant/hosts/bsd.rb

34 lines
1.0 KiB
Ruby
Raw Normal View History

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
def nfs?
system("which nfsd > /dev/null 2>&1")
$?.to_i == 0
rescue TypeError
false
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
end
end
end