#!/bin/ksh
#
#ident	"@(#)install.staf	1.6	04/12/08 SMI"
#
# Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
# Use is subject to license terms.
#

# variables
sdir=/opt/SUNWstaf

# functions

# kill the named process(es)
killproc() {
        pid=`/usr/bin/ps -e |
             /usr/bin/grep -w $1 |
             /usr/bin/sed -e 's/^  *//' -e 's/ .*//'`
        [ "$pid" != "" ] && kill -HUP $pid
}

### MAIN ###

clear
echo "Installing STAF to client system..."

if [ `/usr/ucb/whoami` != root ]
then
	echo "\n!ERROR: Must be root user.\n"
	exit
fi

# edit /etc/inet/services
if [ -z `grep staf /etc/inet/services` ]
then
	echo "Adding STAF entry to /etc/inet/services..."
	echo "staf            777/tcp" >> /etc/inet/services
fi

# edit /etc/inet/inetd.conf
if [ -z `grep staf /etc/inet/inetd.conf` ]
then
	echo "Adding STAF entry to /etc/inet/inetd.conf..."
	echo "staf    stream  tcp     nowait  root    $sdir/staf.eng       staf.eng" >> /etc/inet/inetd.conf
	echo "Restarting inetd..."
	killproc inetd
fi

# finish
echo "Done."

