#! /bin/bash
#=====================
# author :zhonglong
# create :2019-9-10
#======================
. /etc/init.d/functions
proc=/usr/local/nginx/sbin/nginx
name=nginx
function start(){
num=`netstat -ntlp |grep $name | wc -l`
if [ $num -gt 0 ]
then
echo " $name is Runing" && exit
else
daemon $proc > /dev/null
[ $? -eq 0 ] && echo " $name start SUCCESS"
fi
}
function stop(){
num2=`netstat -ntlp |grep $name | wc -l`
if [ $num2 -eq 0 ]
then
echo " please start $name first" && exit
else
killproc $proc > /dev/null
[ $? -eq 0 ] && echo " $name stop SUCCESS"
fi
}
case $1 in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo " $name start|stop|restart"
;;
esac