parabola-vmbootstrap/src/hooks/hook-ethernet-dhcp.sh
Jacob Hrbek 1a85688c27
QA: Replace shebang with env-variant
This is to provide a compatibility with nix such as GNU Guix to use the
project painlessly without the need of deploying a sandboxed FHS
environment.

Signed-off-by: Jacob Hrbek <kreyren@rixotstudio.cz>
2023-02-23 09:19:14 +01:00

23 lines
500 B
Bash

#!/usr/bin/env bash
set -e
# determine first ethernet device
eth="$(basename "$(find /sys/class/net/ -mindepth 1 -maxdepth 1 -iname 'e*' | head -n1)")"
[ -n "$eth" ] || eth="eth0"
# create a network configuration
cat > /etc/systemd/network/$eth.network << EOF
[Match]
Name=$eth
[Network]
DHCP=yes
EOF
# enable said network configuration
systemctl enable --now systemd-networkd.service
systemctl enable --now systemd-resolved.service
ln -sf /var/run/systemd/resolve/resolv.conf /etc/resolv.conf