#!/bin/sh
#	This shell will start a uucico for the system given.
#	Options:
#	  -xN the debugging level for uucico (-x5 default)
#	  -r  force the removal of the status file
#	  -gX set minimum grade to X
#	The output is put in /tmp/Name where Name is the name
#	of the system name.  A tail -f is performed after uucico is started.

STATUS=/var/spool/uucp/.Status

PATH=.:/usr/libexec/uucp:$PATH export PATH

set -v
REMOVE=""
X="-x5"
SYS=
while [ $# -gt 0 ]
do
	case $1 in
	-x)  shift; X="-x$1"; shift;;
	-x*) X=$1; shift;;
	-g*) G=$1; shift;;
	-r) REMOVE="y"; shift;;
	-?) echo "$0: unrecognized flag $1"
	    echo "Usage: $0 [-r] [-xdebug_level] system";
	    exit 1;;
	*) SYS="$1"; shift;;
	esac
done

if [ -z "$SYS" ]
then
	echo "$0:  system name required"
	exit 1
fi

#  remove old status file (can't actually remove, since $STATUS isn't
#  publicly writable, but zero-ing it out works fine)
if [ -n "$REMOVE" ]; then
    cp /dev/null $STATUS/${SYS}
fi

tail -f /var/spool/uucp/Debug&
procs=$!
tail -f /var/spool/uucp/Log&
procs="$procs $!"
echo "time uucico -r1 -S$SYS  $X $G &"
time uucico  -r1 -S$SYS  $X $G

kill $procs 



