guests/atomic: Search for FQDN hostname
This commit is contained in:
parent
10b12ce393
commit
bbcddb6499
|
@ -5,19 +5,19 @@ module VagrantPlugins
|
|||
def self.change_host_name(machine, name)
|
||||
comm = machine.communicate
|
||||
|
||||
if !comm.test("hostname | grep -w '#{name}'")
|
||||
if !comm.test("hostname -f | grep '^#{name}$'")
|
||||
basename = name.split(".", 2)[0]
|
||||
comm.sudo <<-EOH
|
||||
hostnamectl set-hostname '#{name}'
|
||||
comm.sudo <<-EOH.gsub(/^ {14}/, "")
|
||||
hostnamectl set-hostname '#{basename}'
|
||||
|
||||
# Remove comments and blank lines from /etc/hosts
|
||||
sed -i'' -e 's/#.*$//' -e '/^$/d' /etc/hosts
|
||||
# Remove comments and blank lines from /etc/hosts
|
||||
sed -i'' -e 's/#.*$//' -e '/^$/d' /etc/hosts
|
||||
|
||||
# Prepend ourselves to /etc/hosts
|
||||
grep -w '#{name}' /etc/hosts || {
|
||||
sed -i'' '1i 127.0.0.1\\t#{name}\\t#{basename}' /etc/hosts
|
||||
}
|
||||
EOH
|
||||
# Prepend ourselves to /etc/hosts
|
||||
grep -w '#{name}' /etc/hosts || {
|
||||
sed -i'' '1i 127.0.0.1\\t#{name}\\t#{basename}' /etc/hosts
|
||||
}
|
||||
EOH
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue