#!/bin/sh
# Prepare environment
mount -t proc proc /proc
mount -t sysfs sysfs /sys
cat /etc/hostname > /proc/sys/kernel/hostname
cat > /usr/sbin/policy-rc.d << EOF
#!/bin/sh
exit 101
EOF
chmod +x /usr/sbin/policy-rc.d
export DEBIAN_FRONTEND=noninteractive

#Setup
apt-get update
apt-get dist-upgrade -y
apt-get install -y isc-dhcp-server

(
cat << EOF
#
# Edubuntu-server generated configuration.
#

authoritative;
subnet $dhcp_network netmask $dhcp_netmask {
    range $dhcp_range_start $dhcp_range_end;
    option domain-name "$dhcp_domain";
    option domain-name-servers $dhcp_dns_servers;
    option netbios-name-servers $dhcp_wins_servers;
    option broadcast-address $dhcp_broadcast;
    option routers $dhcp_gateway;
    option subnet-mask $dhcp_netmask;
}
EOF
) > /etc/dhcp/dhcpd.conf

# Cleanup
rm /usr/sbin/policy-rc.d
exit 0
