#!/bin/sh

if [ -z "$3" ]
then
    echo "Usage:   $0 [options] user server[:port] secret"
    echo
    echo "Options: -v               more verbose output"
    echo "         -start           send Accounting-Start instead of -Stop"
    echo "         -time seconds    include Acct-Session-Time"
    exit 1
fi

args=-q
type=Stop
while expr "$1" : "-" >/dev/null
do
    case "$1" in
	-v)     args= ;;
	-time)  time="$2" ; shift ;;
	-start) type=Start ;;
    esac
    shift
done

(
    echo User-Name=\""$1"\"
    echo Acct-Session-Id=$$
    echo Acct-Status-Type="$type"
    [ "$time" ] && echo Acct-Session-Time="$time"
) | radclient -a $args "$2" "$3"
