#!/bin/sh -e
# Set up and enable ppp so that it can use used to download packages
# a little later on.
# TODO: should be in ppp and/or wvdial packages.
. /usr/share/debconf/confmodule

db_title 'Debian System Configuration'

if [ -e /usr/bin/pon ]; then
	# Should ppp be used?
	# Re-ask this question every time, because circumstances change..
	db_fset base-config/use-ppp seen false
	db_input critical base-config/use-ppp || true
	db_go || true
	db_get base-config/use-ppp
	if [ "$RET" = true ]; then
		# Set up ppp if not already set up.
		if [ ! -e /etc/ppp/peers/provider ]; then
			pppconfig --noname </dev/tty >/dev/tty || true
		fi
		# redirect 3 so it goes to background w/o
		# hanging debconf later..
		pon </dev/tty >/dev/tty 2>/dev/tty 3>/dev/tty || true
		# TODO: this should be much more robust. What if ppp
		# fails to dial?
	fi
fi
