# Copyright 17 Oct 1994 Sun Microsystems, Inc. All Rights Reserved.
#
#pragma ident  "@(#)postinstall	1.3 94/10/17 Sun Microsystems"

# postinstall script for Cooperative Consoles Sender Daemon

#
# Return pid of named process in variable "pid"
#
# Exit codes for installation scripts

export BASEDIR

e_ok=0
e_fatal=1      # stop installation on this exit
e_warning=2    # Installation will go on.
e_int=3        # Interrupted. Stop installation
e_reboot=10    # User must reboot after installation of all selected packages
e_rebootnow=20 # User must reboot right after installation of current package
               # To be added to one of the single-digit exit codes above

#
# Trap interrupt
#
trap `exit $e_int` 15
#


# Set up /etc/rpc file
#
cp /etc/rpc /etc/rpc.$$
echo "Adding cc_sender definitions to /etc/rpc ... "
echo ""
chmod 644 /etc/rpc 
ex - /etc/rpc <<RPCEOF >/dev/null
g/# Cooperative Consoles/d
g/\<cc_sender\>/d
$
a
# Cooperative Consoles
sender          100139  cc_sender     
.
w
q
RPCEOF
echo "done."

DIFF=`diff /etc/rpc /etc/rpc.$$`
if [ "$DIFF" != "" ]; then
   echo "Your old /etc/rpc has been saved as /etc/rpc.$$"

else
   rm /etc/rpc.$$
   echo "Your /etc/rpc file was already up to date."
fi

 
#
# Set up /etc/inetd.conf file
#
echo ""
echo "Updating /etc/inet/inetd.conf to reflect CC's installation directory"
echo ""
chmod 644 /etc/inet/inetd.conf
cp /etc/inet/inetd.conf /etc/inet/inetd.conf.$$
ex - /etc/inet/inetd.conf <<INETDCONF >/dev/null
g/# Cooperative Consoles/d
g/\<cc_sender\>/d
$
a
# Cooperative Consoles Sender Daemon
sender/10  tli  rpc/tcp  wait  root  $BASEDIR/SUNWconn/snm/agents/cc_sender  cc_sender
sender/10  tli  rpc/udp  wait  root  $BASEDIR/SUNWconn/snm/agents/cc_sender  cc_sender
.
w
q
INETDCONF
echo "done."
chmod 444 /etc/inet/inetd.conf
 
DIFF=`diff /etc/inet/inetd.conf /etc/inet/inetd.conf.$$`
if [ "$DIFF" != "" ]; then
   echo "Your old /etc/inet/inetd.conf has been saved as /etc/inet/inetd.conf.$$"
else
   rm /etc/inet/inetd.conf.$$
   echo "Your /etc/inet/inetd.conf file was already up to date."
fi
 

#
# restart inetd
#
echo "Instructing inetd to re-read config file"
INETD=`ps -ae | egrep inetd | egrep -v egrep | head -1 | awk '{print $1}'`
kill -HUP $INETD
echo "done."
echo ""

#
# let packaging stuff know we're done
#
 
exit $e_ok



