#
# Copyright (c) 1992 by Sun Microsystems, Inc.
#
# Postinstall script for base DNI package
#

#ident	"@(#)postinstall	1.11	93/03/30	SMI"

#
# Info used to create license file
#
SERVERNAME=lic.SUNW
PRODVERS=8.0
FEATURE=SUNWdni
HOSTNAME=`uname -n`
HOSTID=`/usr/ucb/hostid`

ETCDNI=/etc/SUNWconn/dni
SBINDNI=/opt/SUNWconn/dni/sbin

#
# Return pid of named process in variable "pid"
#
pidproc() {
	pid=`/usr/bin/ps -e |
		/usr/bin/grep $1 |
		/usr/bin/sed -e 's/^  *//' -e 's/ .*//'`
}

#
# Create/Edit files in /etc/SUNWconn/dni
#
echo "$DNIINTERFACE" > $ETCDNI/controller
echo "$DNIHOSTNAME" > $ETCDNI/nodename
echo "$DNIAREA.$DNINODE	$DNIHOSTNAME" >> $ETCDNI/hosts

#
# First character of license is the vendor string
#
VENDORSTR=`echo $DNILICENSE | cut -c-1`
DNILICENSE=`echo $DNILICENSE | cut -c2-`

#
# Create the license file in /etc/SUNWconn/dni
#
echo "SERVER $HOSTNAME $HOSTID 1700" > $ETCDNI/license.dat
echo "DAEMON $SERVERNAME" >> $ETCDNI/license.dat
echo "INCREMENT $FEATURE $SERVERNAME $PRODVERS $DNILICDATE 0 $DNILICENSE \"$VENDORSTR\" $HOSTID" >> $ETCDNI/license.dat

#
# Record the files that we create
#
installf $PKGINST $ETCDNI/controller f 644 root other
installf $PKGINST $ETCDNI/nodename f 644 root other
installf $PKGINST $ETCDNI/license.dat f 644 root other

#
# Add drivers
#
/usr/sbin/add_drv nsp
/usr/sbin/add_drv rt

installf -f $PKGINST

#
# If installed on the native machine i.e. BASEDIR = /
# startup DNI and restart inetd
#
	/etc/init.d/init.dni start
	if [ "$?" = "0" ]
	then
		pidproc inetd
		[ "$pid" != "" ] && kill -HUP $pid
	else
		exit 1
	fi

exit 0
