From fc0a0d04e54b6d714c9b836661af4108680d4b0b Mon Sep 17 00:00:00 2001 From: LoreLLo Date: Fri, 12 Oct 2012 18:11:52 +0200 Subject: [PATCH] fix change_host_name for Ubuntu Hardy --- plugins/guests/ubuntu/guest.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/plugins/guests/ubuntu/guest.rb b/plugins/guests/ubuntu/guest.rb index ed4311cea..5b9673621 100644 --- a/plugins/guests/ubuntu/guest.rb +++ b/plugins/guests/ubuntu/guest.rb @@ -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") - comm.sudo("service hostname start") + 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