Fix hostname setting also in Debian

Same fix as #2334.
This commit is contained in:
Teemu Matilainen 2013-10-15 15:57:40 -03:00
parent 535eb35206
commit 330f72eae2
1 changed files with 3 additions and 3 deletions

View File

@ -20,11 +20,11 @@ module VagrantPlugins
comm.sudo("sed -i 's/.*$/#{name.split('.')[0]}/' /etc/hostname")
# hosts should resemble:
# 127.0.0.1 localhost host.fqdn.com host
# 127.0.1.1 host.fqdn.com host
# First to set fqdn
comm.sudo("sed -i 's@#{old}@#{name}@' /etc/hosts")
# Second to set hostname
comm.sudo("sed -i 's@#{old.split('.')[0]}@#{name.split('.')[0]}@' /etc/hosts")
comm.sudo("sed -ri 's@^(([0-9]{1,3}\.){3}[0-9]{1,3})\\s+(localhost)\\b.*$@\\1\\t#{name} #{name.split('.')[0]} \\3@g' /etc/hosts")
comm.sudo("sed -ri 's@^(([0-9]{1,3}\.){3}[0-9]{1,3})\\s+(#{old.split('.')[0]})\\b.*$@\\1\\t#{name} #{name.split('.')[0]}@g' /etc/hosts")
comm.sudo("hostname -F /etc/hostname")
comm.sudo("hostname --fqdn > /etc/mailname")