#!/bin/sh
# file: /etc/firewall/post_takeover
# function: The post_takeover script is used to restart T.Rex services after
#	    an auto-takeover by fwpulse.
#
# (C) R. J. Livermore    1995-2000
# (C) Livermore Software Laboratories, Inc.  1995-2000
#
# NOTICE TO USERS OF SOURCE CODE EXAMPLES
#
# LSLI PROVIDES THE SOURCE CODE EXAMPLES, "AS IS" WITHOUT WARRANTY OF ANY
# KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO THE IMPLIED
# WARRANTIES OR MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE
# ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOURCE CODE EXAMPLES
# IS WITH YOU.  SHOULD ANY PART OF THE SOURCE CODE PROVE DEFECTIVE, YOU
# (AND NOT LSLI OR AGENT OF LSLI) ASSUME THE ENTIRE COST OR ALL NECESSARY
# SERVICING, REPAIR OR CORRECTION.
#

#
# Post takeover script
#

PATH=/usr/sbin:/usr/bin:/bin
export PATH

if [ "`id | awk '{print $1}'`" != "uid=0(root)" ]; then
  echo "$0 must be run as root."
  exit 1
fi

#
# Re-start webgate if necessary
#
ps -e | grep -w webgate >/dev/null 2>&1
if [ $? -eq 0 ]; then
	kill `cat /etc/firewall/webgate.pid`
	/usr/local/etc/webgate
fi

#
# Re-start apache if necessary
#
ps -e | grep -w httpd >/dev/null 2>&1
if [ $? -eq 0 ]; then
	kill `cat /etc/apache/httpd.pid`
	/usr/local/etc/httpd
fi

#
# Re-start rpcproxy if necessary
# Note that this is commented out in this example because the restart of
# rpcproxy involves terminating all current rpcproxy connections.
# The user should assess whether this restart should be done automatically
# by this script.
#
#pid=`ps -e | grep -w rpcproxy | awk '{print $1}'`
#if [ $? -eq 0 ]; then
#	kill $pid
#	/usr/local/etc/rpcproxy
#fi

exit 0
