#! /bin/sh
# chkconfig: - 85 15
DESC="nginx"
NAME=nginx
DAEMON=/dav3/nginx/sbin/$NAME
CONFIGFILE=/dav3/nginx/conf/$NAME.conf
PIDFILE=/dav3/nginx/logs/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
set -e
[ -x "$DAEMON" ] || exit 0
do_start() {
cd /dav3/nginx
$DAEMON -c $CONFIGFILE || echo -n "nginx already running"
}
do_stop() {
cd /dav3/nginx
$DAEMON -s stop || echo -n "nginx not running"
}
do_reload() {
cd /dav3/nginx
$DAEMON -s reload || echo -n "nginx can't reload"
}
do_status()
{
ret=`ps -ax|grep nginx|grep master` || ret=""
if [ -z "$ret" ];then
echo "nginx is stoped"
else
echo "nginx is running"
fi
}
case "$1" in
start)
echo -n "Starting $DESC: $NAME"
do_start
echo "."
;;
stop)
echo -n "Stopping $DESC: $NAME"
do_stop
echo "."
;;
reload|graceful)
echo -n "Reloading $DESC configuration..."
do_reload
echo "."
;;
restart)
echo -n "Restarting $DESC: $NAME"
do_stop
do_start
echo "."
;;
status)
do_status
echo "."
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|reload|restart}" >&2
exit 3
;;
esac
exit 0