Update cloud-init network config

This commit is contained in:
Laura Hausmann 2023-03-13 03:08:47 +01:00
parent eb9c492573
commit 525bf5b46d
Signed by untrusted user: zotan
GPG key ID: D044E84C5BE01605

View file

@ -35,8 +35,8 @@ main() {
swapsize="$6"
fi
export swapsize
if [[ -e /etc/netplan/50-cloud-init.yaml ]]; then
export cinetwork="/etc/netplan/50-cloud-init.yaml"
if test -n "$(find /etc/systemd/network -name '??-cloud-init*.network' -print -quit)"; then
export cinetwork="/etc/systemd/network"
fi
if grep -q "console=ttyS0" /proc/cmdline; then
export consoleboot="console=ttyS0"
@ -118,8 +118,8 @@ main() {
export password
# VM specific stuff
if [[ -e /etc/netplan/50-cloud-init.yaml ]]; then
export cinetwork="/etc/netplan/50-cloud-init.yaml"
if test -n "$(find /etc/systemd/network -name '??-cloud-init*.network' -print -quit)"; then
export cinetwork="/etc/systemd/network"
fi
if grep -q "console=ttyS0" /proc/cmdline; then
@ -312,9 +312,8 @@ basic_postinstall(){
fi
if [[ -n $cinetwork ]]; then
cp /run/systemd/network/*.link /mnt/etc/systemd/network/10-cloud-init.link || : # ignore failures because file doesn't exist
cp /run/systemd/network/*.network /mnt/etc/systemd/network/50-cloud-init.network || : # ignore failures because file doesn't exist
cat /mnt/etc/systemd/network/50-cloud-init.network | grep -E 'DNS|Domains' | sed 's/DNS=/nameserver /g' | sed 's/Domains=/search /g' >> /mnt/etc/resolv.conf
cp /run/systemd/network/??-cloud-init-*.link /run/systemd/network/??-cloud-init-*.network /mnt/etc/systemd/network || : # ignore failures because file doesn't exist
cat /mnt/etc/systemd/network/??-cloud-init-*.network | grep -E 'DNS|Domains' | sed 's/DNS=/nameserver /g' | sed 's/Domains=/search /g' >> /mnt/etc/resolv.conf
archchroot "systemctl enable systemd-networkd"
fi
}