use basename for setting hostname

This commit is contained in:
Matthias Haag 2017-11-22 11:09:51 +01:00
parent bcf3a4b3d1
commit a139dd2b59
1 changed files with 2 additions and 2 deletions

View File

@ -8,8 +8,8 @@ module VagrantPlugins
if !comm.test("hostname -f | grep '^#{name}$'", sudo: false) if !comm.test("hostname -f | grep '^#{name}$'", sudo: false)
basename = name.split(".", 2)[0] basename = name.split(".", 2)[0]
comm.sudo <<-EOH.gsub(/^ {14}/, '') comm.sudo <<-EOH.gsub(/^ {14}/, '')
echo '#{name}' > /etc/HOSTNAME echo '#{basename}' > /etc/HOSTNAME
hostname '#{name}' hostname '#{basename}'
# Prepend ourselves to /etc/hosts # Prepend ourselves to /etc/hosts
grep -w '#{name}' /etc/hosts || { grep -w '#{name}' /etc/hosts || {