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

15 lines
395 B
Ruby
Raw Normal View History

2013-08-28 04:12:09 +00:00
module VagrantPlugins
module GuestOpenBSD
module Cap
class ChangeHostName
def self.change_host_name(machine, name)
if !machine.communicate.test("hostname | grep '^#{name}$'")
machine.communicate.sudo("sh -c \"echo '#{name}' > /etc/myname\"")
machine.communicate.sudo("hostname #{name}")
end
end
end
end
end
end