alpine-zdt-images/scripts/setup-ami.d/eth-eni-setup
tomalok e42c833553
eth-eni-setup init script (#87)
* eth-eni-setup init script

before networking starts up, makes sure eth interfaces match attached ENIs

also fixes a permissions problem with eth-eni-hotplug mdev config

* fix aarch64 build
2020-09-21 19:43:33 -07:00

37 lines
648 B
Plaintext
Executable File

#!/sbin/openrc-run
description="Sets up interfaces for attached Elastic Network Interfaces"
IFACE_CFG=/etc/network/interfaces
depend() {
before net
need sysfs
}
eni_eths() {
local iface
for iface in /sys/class/net/eth*; do
echo "${iface##*/}"
done
}
start() {
local iface
ebegin "Setting up interfaces for attached ENIs"
cat "$IFACE_CFG.d/lo" > "$IFACE_CFG.new"
for iface in $(eni_eths); do
[ -f "$IFACE_CFG.d/$iface" ] ||
sed -e "s/%%/$iface/g" "$IFACE_CFG.d/DEFAULT" > "$IFACE_CFG.d/$iface"
cat "$IFACE_CFG.d/$iface" >> "$IFACE_CFG.new"
einfo "$iface configured"
done
mv "$IFACE_CFG.new" "$IFACE_CFG"
eend "$?"
}