:
#      @(#)lpd.sh	1.3 Lachman System V STREAMS TCP  source
#
#	System V STREAMS TCP - Release 4.0
#
#   Copyright 1990 Interactive Systems Corporation,(ISC)
#   All Rights Reserved.
#
#	Copyright 1987, 1988, 1989 Lachman Associates, Incorporated (LAI)
#	All Rights Reserved.
#
#	The copyright above and this notice must be preserved in all
#	copies of this source code.  The copyright above does not
#	evidence any actual or intended publication of this source
#	code.
#
#	This is unpublished proprietary trade secret source code of
#	Lachman Associates.  This source code may not be copied,
#	disclosed, distributed, demonstrated or licensed except as
#	expressly authorized by Lachman Associates.
#
#	System V STREAMS TCP was jointly developed by Lachman
#	Associates and Convergent Technologies.
#
#      SCCS IDENTIFICATION
#
# Copyrighted as an unpublished work.
# (c) Copyright 1989 INTERACTIVE Systems Corporation
# All rights reserved.
#


#
# Remote Line Printing start/stop script
#

PATH=/etc:/bin:/usr/bin:/usr/lib
#
# PROCS contains a list of processes to kill when SNMP is stopped.
# Edit as appropriate.
#
PROCS="lpd"

# figure out which kernel we're running
if [ -x /bin/ps ] ; then
    /bin/su root -c /bin/ps -e > /tmp/ps.err$$ 2>&1
    if grep "not the booted" /tmp/ps.err$$ > /dev/null ; then
	PS="/bin/ps -n /unix.old"
    else
        PS="/bin/ps"
    fi
    rm -f /tmp/ps.err$$
else
    echo "$0: Can't find ps"
    exit 1
fi

case "$1" in
'start')
	/bin/su root -c "$PS -e" 2>/dev/null | \
		/usr/bin/fgrep lpd > /dev/null 2>&1
	if [ $? -eq 0 ]
	then
		echo "lpd already running.  lpd start aborted."
		exit 0
	fi

	echo "Remote Line Printing Startup: \c"

	echo " lpd\c"
	/usr/lib/lpd 

	echo ""
	;;

'stop')
	echo "Remote Line Printing Shutdown: \c"

	PX=""
	OR=""
	for P in $PROCS
	do
		PX="$PX$OR$P"
		OR="|"
	done
	PX="/$PX/"
	/bin/su root -c "$PS -e" 2>/dev/null | \
		/usr/bin/awk "$PX { print \"kill \" \$1 }" | /bin/sh

	echo "done"
	;;

*)
	echo "Usage: $0 [ start | stop ]"
	exit 1
	;;
esac

exit 0
