# Copyright 08 Mar 1996 Sun Microsystems, Inc. All Rights Reserved.
#
#pragma ident  "@(#)preremove	1.5 96/03/08 Sun Microsystems"

# preremove 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
#
 
#
# kill running proc
#
killproc() {
    pid=`/usr/bin/ps -e | /usr/bin/grep $1 |
         /usr/bin/sed -e 's/^  *//' -e 's/ .*//'`
 
    for p in $pid
    do
         echo "Terminating $1: PID=$p "
         kill -9  $p
    done
}
 
 
echo "Terminating Cooperative Consoles Sender Daemon."
 
killproc cc_sender
 
#
# Set up /etc/rpc file
#
# cp /etc/rpc /etc/rpc.$$
# echo "Remove 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
# $
# .
# w
# q
# RPCEOF
# echo "done."
#  
#
# Set up /etc/inetd.conf file
#
# echo ""
# echo "Remove /etc/inet/inetd.conf to reflect CC's 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
# $
# .
# w
# q
# INETDCONF
# echo "done."
#  
#
# 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 ""
#  

 
exit $e_ok



