2013-04-04 18:49:26 +00:00
|
|
|
module VagrantPlugins
|
2013-05-07 09:38:46 +00:00
|
|
|
module GuestGentoo
|
2013-04-04 18:49:26 +00:00
|
|
|
module Cap
|
|
|
|
class ChangeHostName
|
|
|
|
def self.change_host_name(machine, name)
|
|
|
|
machine.communicate.tap do |comm|
|
2013-04-04 19:09:40 +00:00
|
|
|
if !comm.test("sudo hostname --fqdn | grep '#{name}'")
|
|
|
|
comm.sudo("echo 'hostname=#{name.split('.')[0]}' > /etc/conf.d/hostname")
|
2013-04-04 18:49:26 +00:00
|
|
|
comm.sudo("sed -i 's@^\\(127[.]0[.]0[.]1[[:space:]]\\+\\)@\\1#{name} #{name.split('.')[0]} @' /etc/hosts")
|
2013-04-04 19:09:40 +00:00
|
|
|
comm.sudo("hostname #{name.split('.')[0]}")
|
2013-04-04 18:49:26 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|