#!/bin/bash
### BEGIN INIT INFO
# Provides:          cdns-ha
# Required-Start:    $local_fs $remote_fs $network $syslog 
# Required-Stop:     $local_fs $remote_fs $network $syslog 
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# X-Interactive:     true
# Short-Description: Start/Stop cdns-ha
### END INIT INFO
# Begin /etc/init.d/cdns-ha
. /lib/lsb/init-functions

case "$1" in
        start)
		echo -n "Starting cdns ..."
		/etc/init.d/bind9 start 
		exit 0
                ;;


        stop)
                echo -n "Stopping cdns ..."
		/bin/pidof named
		x1=`echo $?`
		if [ ${x1} == "0" ];then
		/etc/init.d/bind9 stop
		fi
		exit 0
		;;

	status)
		#/bin/sleep 3
		#x1=`ps ax | grep "tnslsnr" | grep -v "grep" | wc -l`
		/bin/pidof named
		x3=`echo $?`
		#if (($x2 < 1 ));then
		if [ ${x3} != "0" ];then
			echo "stopped"
			exit 3
		else
			echo "running"
			exit 0
		fi
		;;

	restart)
	       $0 stop
	       /bin/sleep 1
	       $0 start
	       ;;

	
        *)
                echo "Usage: $0 {start|stop|status|restart}"
                exit 1
                ;;

esac

# End /etc/init.d/cdns-ha
