From d60586f47e277ef1f241963099bf96ab4811f67e Mon Sep 17 00:00:00 2001
From: Helmut Grohne <helmut@subdivi.de>
Date: Sat, 29 Mar 2025 12:49:10 +0100
Subject: debvm-create: create a more sensible /etc/hosts

This is close to what the debian installer sets up.
---
 bin/debvm-create | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

(limited to 'bin/debvm-create')

diff --git a/bin/debvm-create b/bin/debvm-create
index 0d89ad4..f6cd90a 100755
--- a/bin/debvm-create
+++ b/bin/debvm-create
@@ -350,9 +350,10 @@ case "$INITSYSTEM" in
 esac
 
 # set up a hostname
+ETC_HOSTS_TEMPLATE='127.0.0.1 localhost\n127.0.1.1 %s\n::1 ip6-localhost ip6-loopback\n'
 set -- \
-	"--customize-hook=echo $VMNAME >"'"$1/etc/hostname"' \
-	"--customize-hook=echo 127.0.0.1 localhost $VMNAME >"'"$1/etc/hosts"' \
+	"--customize-hook=echo '$VMNAME' >"'"$1/etc/hostname"' \
+	"--customize-hook=printf '$ETC_HOSTS_TEMPLATE' '$VMNAME' >"'"$1/etc/hosts"' \
 	"$@"
 
 # allow password-less root login
-- 
cgit v1.2.3