#!/bin/sh -e

# debirf module: network
# setup default network interface configuration
#
# The debirf scripts were written by
# Jameson Rollins <jrollins@fifthhorseman.net>
# and
# Daniel Kahn Gillmor <dkg@fifthhorseman.net>.
#
# They are Copyright 2007-2011, and are all released under the GPL,
# version 3 or later.

# reset default udev persistent-net rule
rm -f "${DEBIRF_ROOT}"/etc/udev/rules.d/*_persistent-net.rules

# write /etc/network/interfaces
cat <<EOF > "${DEBIRF_ROOT}/etc/network/interfaces"
# Used by ifup(8) and ifdown(8). See the interfaces(5) manpage or
# /usr/share/doc/ifupdown/examples for more information.

auto lo
iface lo inet loopback

# a default dynamic ethernet address.
# if you have eth0, you can use this with "ifup eth0=dhcp"
iface dhcp inet dhcp
EOF

# reset /etc/resolv.conf
> "${DEBIRF_ROOT}/etc/resolv.conf"

# add network note to /etc/motd.tail
cat <<EOF >> "${DEBIRF_ROOT}/etc/motd.tail"
If you have a network interface (ie. "eth0"), you can bring it up with:
ifup eth0=dhcp
(you can list available network interfaces with 'ifconfig -a')
==================================================
EOF
