#!/bin/sh

# Copyright 1988-1991 Network Computing Devices, Inc.  All rights reserved.
# An unpublished work.

#ident "@(#)add_prt	14.1	91/02/26"

SEP="%"
if [ "$DESTBIN" = "" ]; then DESTBIN=/usr/local/bin/ncdprint; fi

HOSTFILE=/etc/hosts

EXIT_OK=0
EXIT_USAGE=1
EXIT_ERROR=2

if [ $# -ne 2 ]
then
    echo "Usage: add_prt type name" >&2
    exit $EXIT_USAGE
fi

type="$1"
case "$type" in
    ascii)
	;;
    dj*)
	;;
    lj*) 
	;;
    lw*| lw*up)
	;;
    *)
	echo "Invalid printer type: $type" >&2
	exit $EXIT_ERROR
	;;
esac

name="$2"
sed -e 's/#.*$//' $HOSTFILE | \
    sed -e 's/	/ /g' | \
    sed -e 's/$/ /' | \
    grep " $name " > /dev/null
if [ $? -ne 0 ]
then
    echo "Warning: $name is not in the $HOSTFILE file." >&2
fi

pat="${DESTBIN}/if${SEP}*${SEP}${name}"
junk=`echo $pat`
if [ "$junk" != "$pat" ]
then
    echo "Warning: $name appears to already be configured." >&2
fi

link="${DESTBIN}/if${SEP}${type}${SEP}${name}"
if [ ! -f "$link" ]
then
    ln ${DESTBIN}/if.sh ${DESTBIN}/if${SEP}${type}${SEP}${name}
fi
