#!/bin/bash

set -eux

install-packages ifmetric

cat <<EOF > /etc/network/interfaces
# The loopback network interface
auto lo
iface lo inet loopback

source /etc/network/interfaces.d/*
EOF

mkdir -p /etc/network/interfaces.d
rm /etc/network/interfaces.d/*

cat <<EOF > /etc/network/interfaces.d/eth0
# The primary network interface
allow-hotplug eth0
iface eth0 inet dhcp
    metric 0
EOF

cat <<EOF > /etc/network/interfaces.d/eth1
allow-hotplug eth1
iface eth1 inet dhcp
    metric 1
EOF

cat <<EOF > /etc/network/interfaces.d/eth2
allow-hotplug eth2
iface eth2 inet dhcp
    metric 2
EOF
