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

15 lines
395 B
Ruby

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