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

18 lines
545 B
Ruby
Raw Normal View History

2013-04-04 19:25:10 +00:00
module VagrantPlugins
module GuestSolaris
module Cap
class ChangeHostName
def self.change_host_name(machine, name)
su_cmd = machine.config.solaris.suexec_cmd
# Only do this if the hostname is not already set
if !machine.communicate.test("#{su_cmd} hostname | grep '#{name}'")
machine.communicate.execute("#{su_cmd} sh -c \"echo '#{name}' > /etc/nodename\"")
machine.communicate.execute("#{su_cmd} uname -S #{name}")
end
end
end
end
end
end