#!/bin/sh

if [ -z "$3" ]
then
    echo "Usage: $0 [options] user server[:port] secret"
    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-Status-Type=$type
    if [ "$time" ]
    then
	echo Acct-Session-Time=$time
    fi
) | radclient -a $args "$2" "$3"
