#!/bin/bash
# Create by wxh 2015-07-05
# Version: v0.1
. /etc/rc.d/init.d/functionsnginx=/usr/local/nginx/sbin/nginx
prog=nginx
pidfile=/usr/local/nginx/logs/nginx.pid
RETVAL=0
start() {
echo -n $"Starting $prog: "
$nginx -t &> /dev/null
if [ $? -eq 0 ];then
$nginx &> /dev/null && success || failure
fi
echo
RETVAL=$?
return $RETVAL
}
stop() {
echo -n $"Stopping $prog: "
$nginx -s stop &> /dev/null && success || failure
echo
RETVAL=$?}
reload() {
echo -n $"Reloading $prog: "
$nginx -s reload &> /dev/null && success || failure
echo
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
reload)
reload;;
status)
status -p ${pidfile} $nginx
RETVAL=$?
;;
help)
$nginx -h
RETVAL=$?
;;
*)
echo $"Usage: $prog {start|stop|restart|reload|help|status}"
RETVAL=1
esac
exit $RETVAL