#!/usr/bin/bsh
# @(#)41	1.7  src/bos/usr/bin/uucp/uutry, cmduucp, bos411, 9436B411a 9/6/94 17:44:15
# 
# COMPONENT_NAME: CMDUUCP uutry
# 
# FUNCTIONS: 
#
# ORIGINS: 10  27  3 
#
# (C) COPYRIGHT International Business Machines Corp. 1985, 1989
# All Rights Reserved
# Licensed Materials - Property of IBM
#
# US Government Users Restricted Rights - Use, duplication or
# disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
#
#	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

STATUS=/var/spool/uucp/.Status
UUCICO=/usr/sbin/uucp/uucico
CMD=`basename $0`
USAGE="Usage: $CMD [ -xDebugLevel ] [ -r ] SystemName"
REMOVE=""
X="-x5"
SYS=
for arg
do
	case $arg in
	-x*) X=$arg;;
	-r) REMOVE="y";;
	-*) echo "$CMD: Invalid option $arg"; echo $USAGE; exit 1;;
	*) SYS="$arg";;
	esac
done
if [ -z "$SYS" ]
then
     	if [ -x /usr/bin/dspmsg ];
		then
                    MSG=`dspmsg uucp.cat 1 "%s:  system name required" $CMD;`
                else
                    MSG="$CMD:  system name required."
        fi
        echo $MSG
	exit 1
fi

#  check for existence in Systems
#  We require an exact match since some names can be prefixes of others.
FULLNAME=`uuname | grep "^${SYS}$"  2>/dev/null`
if [ "${FULLNAME}XX" = "XX" ]
then
    if [ -x /usr/bin/dspmsg ];
        then
            MSG=`dspmsg uucp.cat 2 "Invalid system name \"%s\"" $SYS;`
        else
            MSG="Invalid system name \"$SYS\""
    fi
    echo $MSG
    exit 1
fi

#  remove old status file
if [ -n "$REMOVE" ]; then
    rm -f $STATUS/${FULLNAME}
fi

echo "$UUCICO -r1 -s$FULLNAME  $X &"
$UUCICO  -r1 -s$FULLNAME  $X &
