diff --git a/other_scripts/systemd-network-enable-default-dhcp.sh b/other_scripts/systemd-network-enable-default-dhcp.sh index 81d42a9..9111154 100755 --- a/other_scripts/systemd-network-enable-default-dhcp.sh +++ b/other_scripts/systemd-network-enable-default-dhcp.sh @@ -18,13 +18,6 @@ set -e exit 1; ) -apt install systemd-resolved - -# Enable systemd-resolved & link stub-resolv.conf. -systemctl enable --now systemd-resolved - -ln -sf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf - cat << EOF > /etc/systemd/network/dhcp.network [Match] Name=* @@ -46,6 +39,17 @@ EOF systemctl disable networking systemctl enable systemd-networkd +# Only enable systemd if it's installed. +(apt install systemd-resolved && \ + +# Enable systemd-resolved & link stub-resolv.conf. +systemctl enable --now systemd-resolved && \ + +ln -sf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf) || \ + +# Note that systemd-resolved is not available. +printf 'systemd-resolved not available! OK, skipping it...\n'; + # Final warning. printf 'Rebooting in 30 seconds, hit ctrl+c to cancel.\n' sleep 30;