67 lines
2.4 KiB
Bash
67 lines
2.4 KiB
Bash
#!/hint/bash -euE
|
|
# Copyright (C) 2023 Umorpha Systems
|
|
#
|
|
# Some of the config files created here are based on the ones from
|
|
# archiso. It is the position of archiso that the config files are
|
|
# not sufficiently creative to qualify for copyright.
|
|
#
|
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
post_install+=(20:ethernet:post_install)
|
|
ethernet:post_install() {
|
|
local arg_mountpoint=$1
|
|
|
|
# networkd (IP) ########################################################
|
|
|
|
install -Dm644 /dev/stdin "$arg_mountpoint/etc/systemd/network/20-ethernet.network" <<-EOF
|
|
[Match]
|
|
# Matching with "Type=ether" causes issues with containers because it also matches virtual Ethernet interfaces (veth*).
|
|
# See https://bugs.archlinux.org/task/70892
|
|
# Instead match by globbing the network interface name.
|
|
Name=en*
|
|
Name=eth*
|
|
|
|
[Network]
|
|
DHCP=yes
|
|
MulticastDNS=yes
|
|
|
|
# systemd-networkd does not set per-interface-type default route metrics
|
|
# https://github.com/systemd/systemd/issues/17698
|
|
# Explicitly set route metric, so that Ethernet is preferred over Wi-Fi and Wi-Fi is preferred over mobile broadband.
|
|
# Use values from NetworkManager. From nm_device_get_route_metric_default in
|
|
# https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/blob/main/src/core/devices/nm-device.c
|
|
[DHCPv4]
|
|
RouteMetric=100
|
|
|
|
[IPv6AcceptRA]
|
|
RouteMetric=100
|
|
EOF
|
|
|
|
install -Dm644 /dev/stdin "$arg_mountpoint/etc/systemd/network.conf.d/ipv6-privacy-extensions.conf" <<-EOF
|
|
[Network]
|
|
IPv6PrivacyExtensions=yes
|
|
EOF
|
|
|
|
install -Dm644 /dev/stdin "$arg_mountpoint/etc/systemd/system/systemd-networkd-wait-online.service.d/wait-for-only-one-interface.conf" <<-EOF
|
|
# Allow systemd-networkd-wait-online to succeed with one interface, otherwise, if multiple network interfaces exist,
|
|
# network-online.target gets needlessly delayed.
|
|
# See https://wiki.archlinux.org/title/systemd-networkd#systemd-networkd-wait-online
|
|
[Service]
|
|
ExecStart=
|
|
ExecStart=/usr/lib/systemd/systemd-networkd-wait-online --any
|
|
EOF
|
|
|
|
systemctl --root="$arg_mountpoint" enable systemd-networkd.service
|
|
|
|
# resolved (DNS) #######################################################
|
|
|
|
ln -sf /run/systemd/resolve/stub-resolv.conf "$arg_mountpoint/etc/resolv.conf"
|
|
systemctl --root="$arg_mountpoint" enable systemd-resolved.service
|
|
|
|
# timesyncd (NTP) ######################################################
|
|
|
|
systemctl --root="$arg_mountpoint" enable systemd-timesyncd.service
|
|
|
|
|
|
}
|