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}$'")
|
2014-05-22 16:35:12 +00:00
|
|
|
machine.communicate.sudo(<<CMDS, {shell: "sh"})
|
2016-10-24 17:06:59 +00:00
|
|
|
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
|