#!/bin/bash  
#  
# JYNZDFY 
# chkconfig: 2345 99 01
# description: jingyunsd service, dealing with the virus

### BEGIN INIT INFO
# Provides:          JYNZDFY
# Required-Start:    $local_fs $network
# Required-Stop:     $local_fs
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: jingyunsd service
# Description:       jingyunsd service, dealing with the virus
### END INIT INFO  

PNAME=JYNZDFY2
JYN_PATH=/opt/apps/cn.vsecure.chenxinsd/files/bin
PROG=$JYN_PATH/$PNAME  

start() {
	PID=`pidof $PNAME`
	if [[ "e$PID" == "e" ]] ; then
		if [ -e  $PROG ];then
			$PROG 
			echo "start $SNAME"
		else
			echo "no $SNAME"
		fi
	else
		echo "$PNAME already running $PID"
	fi
}  

stop() {  
	PID=`pidof $PNAME`
	if [[ "e$PID" == "e" ]] ; then
		echo "$PNAME not running"
	else
	    $JYN_PATH/JYToolBox --kill $PID
	fi
}  

restart() {
	stop
	while true; do 
	    PID=`pidof $PNAME`
		if [[ "e$PNAME" == "e" ]] ; then
		    echo "$PNAME stop success"
			break
		fi
		sleep 1
	done
	start
}

status(){
	PID=`pidof $PNAME`
	if [[ "e$PID" == "e" ]] ; then
		echo "$PNAME not running"
	else
		echo "$PNAME is running $PID"
	fi
}

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