#!/bin/bash
###############################################################################
#
# This is HA-VPN-action-script
#
# this script is running on the normal gateways only
# to execute neccessary start/stop functions
# its called by HA-VPN-supervisor with exact one parameter:
# start | stop
#
# autor:        J.Hubertz
# date:         20040127
# license:      GNU/General Public License
#
###############################################################################
# feel free to improve or change,
# this is your copy of HA-VPN-action-script!
###############################################################################
#
#VERBOSE=-v
VERBOSE=""
#
#
NAME=`basename $0`
LOG="/usr/bin/logger -t HA-VPN"
#
PARAMETER_FAULT=0
#
if [ $# -ne 1 ] ; then
        PARAMETER_FAULT=1
else
	PARAMETER=$1
	case $PARAMETER in
		start)  ;;
		stop)   ;;
		*)      PARAMETER_FAULT=1 ;;
	esac
fi

if [ $PARAMETER_FAULT -ne 0 ] ; then
	$LOG " ${NAME}: called with :$*: ==> parameter error, abort"
	echo "`date +%Y%m%d%H%M%S` ${NAME}: parameter error, abort"
	exit 1
fi

ACTION_FAIL_START="/etc/init.d/heartbeat stop"
ACTION_OK_AGAIN="/etc/init.d/heartbeat start"

#echo $PARAMETER

case $PARAMETER in
	start)  $LOG ${ACTION_FAIL_START} ;
		${ACTION_FAIL_START} ;;
	stop)   $LOG ${ACTION_OK_AGAIN} ;
		${ACTION_OK_AGAIN} ;;
esac
exit 0

