#!/bin/sh
#
# Copyright 1996-1999 Sun Microsystems, Inc. All Rights Reserved
#
# ident "@(#)ss_ha_passive_mode.sh	3.3 11/18/99 Sun Microsystems"
#
# usage: ss_ha_passive_mode [-Z]
#

HA_PROGNAME="ss_had"
SS_VARDIR=/var/opt/SUNWicg/SunScreen
HA_PIDFILE=${SS_VARDIR}/ss_had.pid
SS_LIBDIR=/opt/SUNWicg/SunScreen/lib
KILL=/bin/kill

PATH="/opt/SUNWicg/SunScreen/bin:/usr/bin"
export PATH

###
### NOTE: Use this command with caution.  Disabling the sending of packets on 
###       a HA host that is currently the active HA host will stop all
###	  traffic through the EFS HA group.
###

if [ "$1" != "-Z" ] ; then
  echo ""
  echo "WARNING: You are about to put this machine in passive mode."
  echo " This will disable the sending of packets from this machine,"
  echo " with the exception of administration and HA traffic."
  echo " Doing so will disrupt all traffic that is going into or"
  echo " through this HA cluster.  This command should only be used"
  echo " in conjunction with the high availability (HA) feature."
  echo ""
  echo "Do you want to put this SunScreen in passive mode ? (Y/N)"
  read ANSWER
  case $ANSWER in
    Y|y|Yes|YES|yes)
		     # continue
		     ;;
    *)
                     # all other responses are considered a "no"
                     echo "No action taken."
                     exit 0
		     ;;
  esac
fi

if [ -f $HA_PIDFILE ] && read pid <$HA_PIDFILE &&
   /usr/bin/ps -fp$pid | /usr/bin/fgrep $HA_PROGNAME >/dev/null
then :
else /bin/rm -f $HA_PIDFILE
     pid=
fi

#
# If ss_had is running, we signal it such that it can perform necessary
# actions to make this screen passive. Otherwise, we just do it ourselves.
#
#
if [ -n "$pid" ]
then $KILL -USR2 $pid
else exec $SS_LIBDIR/ss_disable_send DISABLE
fi
