install: write /etc/conf.d/hostname too

Write the hostname to this file, so NetworkManager picks it up and
doesn't attempt to fetch and apply a hostname via DHCP.
This commit is contained in:
Oliver Smith 2021-08-15 22:44:15 +02:00
parent a6c63f9580
commit 231ad89484
No known key found for this signature in database
GPG Key ID: 5AE7F5513E0885CB
1 changed files with 4 additions and 0 deletions

View File

@ -321,6 +321,10 @@ def setup_hostname(args):
# Generate /etc/hostname
pmb.chroot.root(args, ["sh", "-c", "echo " + shlex.quote(hostname) +
" > /etc/hostname"], suffix)
# Generate /etc/conf.d/hostname (pma#768)
line = f"hostname={shlex.quote(hostname)}"
cmd = ["sh", "-c", f"echo {shlex.quote(line)} > /etc/conf.d/hostname"]
pmb.chroot.root(args, cmd, suffix)
# Update /etc/hosts
regex = (r"s/^127\.0\.0\.1.*/127.0.0.1\t" + re.escape(hostname) +
" localhost.localdomain localhost/")