mirror of
https://github.com/armbian/build.git
synced 2025-08-18 00:56:57 +02:00
- only affects systemd-networkd-using builds (MINIMAL images?) - does NOT affect NetworkManager - this allows network administrators to give out IPv6 addresses over DHCPv6 based on the MAC address (which should be stable) instead of systemd's own notion of it's "DUID", which is based on the machine-id and changes on every redeployment
43 lines
2.1 KiB
Bash
43 lines
2.1 KiB
Bash
#
|
|
# Extension to manage network interfaces with systemd-networkd + Netplan
|
|
#
|
|
function extension_prepare_config__install_systemd_networkd() {
|
|
# Sanity check
|
|
if [[ "${NETWORKING_STACK}" != "systemd-networkd" ]]; then
|
|
exit_with_error "Extension: ${EXTENSION}: requires NETWORKING_STACK='systemd-networkd', currently set to '${NETWORKING_STACK}'"
|
|
fi
|
|
|
|
display_alert "Extension: ${EXTENSION}: Adding extra packages to image" "netplan.io" "info"
|
|
add_packages_to_image netplan.io
|
|
}
|
|
|
|
function pre_install_kernel_debs__configure_systemd_networkd() {
|
|
display_alert "Extension: ${EXTENSION}: Enabling systemd-networkd" "" "info"
|
|
|
|
# Enable networkd and resolved
|
|
# Very likely not needed to enable manually since these services are enabled by default
|
|
chroot_sdcard systemctl enable systemd-networkd.service || display_alert "Failed to enable systemd-networkd.service" "" "wrn"
|
|
chroot_sdcard systemctl enable systemd-resolved.service || display_alert "Failed to enable systemd-resolved.service" "" "wrn"
|
|
|
|
# Copy network config files into the appropriate folders
|
|
display_alert "Extension: ${EXTENSION}: Configuring" "systemd-networkd and Netplan" "info"
|
|
local netplan_config_src_folder="${EXTENSION_DIR}/config-networkd/netplan/"
|
|
local netplan_config_dst_folder="${SDCARD}/etc/netplan/"
|
|
|
|
run_host_command_logged cp -v "${netplan_config_src_folder}"* "${netplan_config_dst_folder}"
|
|
|
|
local networkd_config_src_folder="${EXTENSION_DIR}/config-networkd/systemd/network/"
|
|
local networkd_config_dst_folder="${SDCARD}/etc/systemd/network/"
|
|
|
|
run_host_command_logged cp -v "${networkd_config_src_folder}"* "${networkd_config_dst_folder}"
|
|
|
|
local networkd_conf_d_config_src_folder="${EXTENSION_DIR}/config-networkd/systemd/networkd.conf.d/"
|
|
local networkd_conf_d_config_dst_folder="${SDCARD}/etc/systemd/networkd.conf.d/"
|
|
|
|
mkdir -p "${networkd_conf_d_config_dst_folder}" # This doesn't exist by default, create it
|
|
run_host_command_logged cp -v "${networkd_conf_d_config_src_folder}"* "${networkd_conf_d_config_dst_folder}"
|
|
|
|
# Change the file permissions according to https://netplan.readthedocs.io/en/stable/security/
|
|
chmod -v 600 "${SDCARD}"/etc/netplan/*
|
|
}
|