#!/bin/sh
PREFIX=$(expr $0 : "\(/.*\)/bin/$(basename $0)\$") || exit 1

if [ -r $PREFIX/etc/utcount.conf ]; then
	. $PREFIX/etc/utcount.conf
else
	exit 1
fi

who | awk '{printf("%s %s %s\n",$1,$2,substr($2,1,4))}' \
	| while read user ttyname ttyprefix
do
	if [ "$ttyprefix" != "$pppd_ttyprefix" ] ; then
		continue
	fi
	grep ":" /etc/ppp/options.$ttyname \
		| awk -F: '{printf(" %s %s\n",user,$2)}' user=$user
done
