#! /bin/sh

# $Id: msg_autoreply.sh,v 1.1 1999/09/30 19:56:19 v2kea318 Exp $
# $Log: msg_autoreply.sh,v $
# Revision 1.1  1999/09/30  19:56:19  v2kea318
# Initial revision
#
#***************************************************************************
#
# This script will control the autoreply mechanism in the msg daemon 
# program.
#
#***************************************************************************

usage() {
    echo "usage:  "`basename $0`" -set autoreply_text | -unset" 1>&2
    exit 1
}

# Where is the FIFO for autoreply?
autoreply=/tmp/$USER/.msg_autoreply
if [ ! -p $autoreply ] ; then
    echo "Can't talk to msgd.  Are you sure it's running?" 1>&2
    exit 1
fi

# Check the command line.
[ $# = 0 ] && usage
while [ "`echo $1 | sed -n '/^-/p'`" != "" ]
    do
	case $1 in
	    -set) # setting autoreply
		shift
		echo "AUTOREPLY_SET $*" >> $autoreply
		exit 0
		;;
	    -unset) # turning auto reply off.
		echo "AUTOREPLY_UNSET" >> $autoreply
		exit 0
		;;
	    *)
		usage
	esac
    done

		
