---
# System prepended metadata

title: Untitled

---

#!/usr/bin/env bash


set -e

MACS=($(ip -4 -o link | awk '/eth0:/ { print $17 }') $(ip -4 -o link | awk '/eth1:/ { print $17 }'))
MACS=($(echo ${MACS[@]} | xargs -n1 | sort))

rm -f /tmp/rule

set +e

i=0
for MAC in ${MACS[@]}; do
  sed -e "s/__MAC__/${MAC}/" -e "s/__IFACE__/eth${i}/" /cdrom/nocloud/net_rule.template >> /tmp/rule
  ((i++))
done

mv /tmp/rule /target/etc/udev/rules.d/70-persistent-net.rules