#!/bin/sh
# Copyright (C) 1997 Florian La Roche
# PPP-login that extracts the correct IP-address from the password files
# in /etc/ppp/{pap-secrets,chap-secrets}.
# sample entry in /etc/passwd:
# Pname:x:2000:15:PPP for name:/home/dummy:/usr/sbin/ppplogin

if test -z "$LOGNAME" ; then
	echo "No username found."
	exit 1
fi
PASSWD_FILES="/etc/ppp/pap-secrets /etc/ppp/chap-secrets"
IP=`cat ${PASSWD_FILES} | awk "/^${LOGNAME}[[:blank:]]/ { print \\$4 }"`
if test -z "$IP" ; then
	echo "Didn't find an IP address."
	exit 1
fi
exec /usr/sbin/pppd ":$IP" -pap -chap
