Remove sed magic to set /etc/hosts for Debian templates

Hosts file is changed according to
http://www.debian.org/doc/manuals/debian-reference/ch05.en.html#_the_hostname_resolution
This commit is contained in:
Michael Stucki 2013-06-06 22:33:25 +02:00
parent 1bb2bc244a
commit 70f3b90f6f

View file

@ -65,13 +65,19 @@ EOF
cat <<EOF > $rootfs/etc/hostname
$hostname
EOF
# set minimal hosts
cat <<EOF > $rootfs/etc/hosts
127.0.0.1 localhost
127.0.1.1 $hostname
# set the host in case it is not set so that sudo does not complain about the host
if ! (grep -q $hostname $rootfs/etc/hosts); then
chroot $rootfs sed -i -e \
"s/^127.0.0.1\(\s\+\)localhost$/127.0.0.1\1localhost\n127.0.1.1\1${hostname}/g" \
/etc/hosts >/dev/null 2>&1 || true
fi
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
EOF
# set default locale
cat <<EOF > $rootfs/etc/locale.gen