#!/bin/sh
#
#

echo
echo "Configuring system for PPP over Ethernet."
echo

# Allow for local network reconfig
config_local

echo
echo -n "Enter PPPoE username: "
read PPPOE_USERNAME

echo
echo -n "Enter PPPoE password: "
read PPPOE_PASSWORD

echo
echo -n "Enter the domain name for your area: "
read DOMAINNAME

echo
echo -n "Enter your primary DNS server IP: "
read DNS1

echo
echo -n "Enter your secondary DNS server IP: "
read DNS2

echo
echo "You can either"
echo "- keep up the connection permanently [1]" 
echo "- or connect automatically on outbound traffic"
echo "  and close the connection after a period of"
echo "  inactivity that you can define     [2]"
echo
echo -n "Which option do you want [1/2]: "
read PPPOETMP
if [ "$PPPOETMP" = "1" ]; then
	PPPOE_IDLE="NO"
else
	echo
	echo -n "How many minutes of inactivity ? "
	read PPPOE_IDLE
	if [ "$PPPOE_IDLE" = "" ]; then
		PPPOE_IDLE=10
	fi
	PPPOE_IDLE=$(($PPPOE_IDLE*60))
fi

# Clear the additional packages file
# echo "pppoe" > floppy/packages

config_dhcp

config_dmz

# Reset the modules definition file
> pkgsrc/modules/etc/modules
# Reset the modules directory
rm -f pkgsrc/modules/lib/modules/*
for REQMODS in `cat data/modules-pppoe`; do
	add_module $REQMODS
done

# Get the network card configuration
scripts/getcards.pl

config_dmz_card

. ./scripts/mkflp-misc

config_language

# Create the Coyote configuration file
save_local_config
save_dmz_config
save_dhcp_config
echo "INETTYPE=PPPOE" >> $CONFIG_FILE
echo "PPPOE_USERNAME=$PPPOE_USERNAME" >> $CONFIG_FILE
echo "PPPOE_PASSWORD=$PPPOE_PASSWORD" >> $CONFIG_FILE
echo "PPPOE_IDLE=$PPPOE_IDLE" >> $CONFIG_FILE

echo "DNS1=$DNS1" >>  $CONFIG_FILE
echo "DNS2=$DNS2" >>  $CONFIG_FILE
echo "DOMAINNAME=$DOMAINNAME" >>  $CONFIG_FILE

if ! [ -z "$LOGGING_HOST" ]; then
        echo "LOGGING_HOST=$LOGGING_HOST" >> $CONFIG_FILE
fi

buildall
write_floppy

echo "Done."
