Remove that '.novalocal' line in /etc/hosts, added by cloud-init

It messes up `hostname -f` on Debian, even if there's a correct line
further down in /etc/hosts.
This commit is contained in:
Linus Nordberg 2019-02-20 11:39:38 +01:00 committed by Patrik Lundin
parent 3b80ba32c7
commit 0692cabba3
Signed by: patlu
GPG key ID: A0A812BA2249F294

View file

@ -57,6 +57,9 @@ if [ ${?} -eq 0 ]; then
sed -i 's/manage_etc_hosts: true/manage_etc_hosts: false/g' /etc/cloud/cloud.cfg sed -i 's/manage_etc_hosts: true/manage_etc_hosts: false/g' /etc/cloud/cloud.cfg
fi fi
# Remove potential $hostname.novalocal line from /etc/hosts, added by cloud-init
sed -i.bak -e "s/^127\.0\.1\.1 $(hostname)\..*novalocal.*//1" /etc/hosts
hostname $cmd_hostname hostname $cmd_hostname
short=`echo ${cmd_hostname} | awk -F. '{print $1}'` short=`echo ${cmd_hostname} | awk -F. '{print $1}'`
echo "127.0.1.1 ${cmd_hostname} ${short}" >> /etc/hosts echo "127.0.1.1 ${cmd_hostname} ${short}" >> /etc/hosts