Allow hostnames to be subset of box name for Ubuntu

This commit is contained in:
Mitchell Hashimoto 2012-10-12 20:06:54 -07:00
parent 3c0341b7be
commit 625741ab6a
1 changed files with 1 additions and 1 deletions

View File

@ -26,7 +26,7 @@ module VagrantPlugins
def change_host_name(name)
vm.communicate.tap do |comm|
if !comm.test("sudo hostname | grep '#{name}'")
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")