vagrant/plugins/guests/netbsd/cap/change_host_name.rb

18 lines
511 B
Ruby
Raw Normal View History

2014-01-14 06:25:35 +00:00
module VagrantPlugins
module GuestNetBSD
module Cap
class ChangeHostName
def self.change_host_name(machine, name)
if !machine.communicate.test("hostname -s | grep '^#{name}$'")
machine.communicate.sudo(<<CMDS, {shell: "sh"})
sed -e 's/^hostname=.*$/hostname=#{name}/' /etc/rc.conf > /tmp/rc.conf.vagrant_changehostname_#{name} &&
mv /tmp/rc.conf.vagrant_changehostname_#{name} /etc/rc.conf &&
2014-01-14 06:25:35 +00:00
hostname #{name}
CMDS
end
end
end
end
end
end