Merge pull request #1191 from lorello/master

Fix change_host_name on Ubuntu Hardy
This commit is contained in:
Mitchell Hashimoto 2012-11-02 21:32:59 -07:00
commit 335d9fad1f
1 changed files with 6 additions and 1 deletions

View File

@ -29,7 +29,12 @@ module VagrantPlugins
if !comm.test("sudo hostname | grep '^#{name}$'")
comm.sudo("sed -i 's/.*$/#{name}/' /etc/hostname")
comm.sudo("sed -i 's@^\\(127[.]0[.]1[.]1[[:space:]]\\+\\)@\\1#{name} #{name.split('.')[0]} @' /etc/hosts")
if comm.test("[ `lsb_release -c -s` = hardy ]")
# hostname.sh returns 1, so I grep for the right name in /etc/hostname just to have a 0 exitcode
comm.sudo("/etc/init.d/hostname.sh start; grep '#{name}' /etc/hostname")
else
comm.sudo("service hostname start")
end
comm.sudo("hostname --fqdn > /etc/mailname")
end
end