#! /bin/sh
#
# Make sure /etc/hostname, /etc/hosts and /target/etc/network/interfaces
# exist before reboot. This is a fallback in case netcfg doesn't do it.

set -e

if [ ! -e /target/etc/hostname ]; then
	echo "localhost" > /target/etc/hostname
fi

if [ ! -e /target/etc/hosts ]; then
	echo "127.0.0.1 localhost" > /target/etc/hosts
fi

if [ ! -e /target/etc/network/interfaces ]; then
	# Every host needs the loopback interface
	cat > /target/etc/network/interfaces <<EOF
# /etc/network/interfaces -- configuration file for ifup(8), ifdown(8)
# Generated by debian-installer.

# The loopback interface
auto lo
iface lo inet loopback
EOF

fi
