856e45a
#!/bin/sh
856e45a
#
856e45a
# nginx - this script starts and stops the nginx daemin
856e45a
#
856e45a
# chkconfig:   - 85 15 
856e45a
# description:  Nginx is an HTTP(S) server, HTTP(S) reverse \
856e45a
#               proxy and IMAP/POP3 proxy server
856e45a
# processname: nginx
856e45a
# config:      /etc/nginx/nginx.conf
530e5a0
# config:      /etc/sysconfig/nginx
856e45a
# pidfile:     /var/run/nginx.pid
856e45a
856e45a
# Source function library.
856e45a
. /etc/rc.d/init.d/functions
856e45a
856e45a
# Source networking configuration.
856e45a
. /etc/sysconfig/network
856e45a
856e45a
# Check that networking is up.
856e45a
[ "$NETWORKING" = "no" ] && exit 0
856e45a
856e45a
nginx="/usr/sbin/nginx"
856e45a
prog=$(basename $nginx)
856e45a
530e5a0
NGINX_CONF_FILE="/etc/nginx/nginx.conf"
530e5a0
473d84b
[ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx
856e45a
856e45a
lockfile=/var/lock/subsys/nginx
856e45a
856e45a
start() {
530e5a0
    [ -x $nginx ] || exit 5
473d84b
    [ -f $NGINX_CONF_FILE ] || exit 6
856e45a
    echo -n $"Starting $prog: "
3678312
    daemon $nginx -c $NGINX_CONF_FILE
856e45a
    retval=$?
856e45a
    echo
856e45a
    [ $retval -eq 0 ] && touch $lockfile
856e45a
    return $retval
856e45a
}
856e45a
856e45a
stop() {
856e45a
    echo -n $"Stopping $prog: "
856e45a
    killproc $prog -QUIT
856e45a
    retval=$?
856e45a
    echo
856e45a
    [ $retval -eq 0 ] && rm -f $lockfile
856e45a
    return $retval
856e45a
}
856e45a
856e45a
restart() {
473d84b
    configtest || return $?
856e45a
    stop
856e45a
    start
856e45a
}
856e45a
856e45a
reload() {
473d84b
    configtest || return $?
856e45a
    echo -n $"Reloading $prog: "
856e45a
    killproc $nginx -HUP
856e45a
    RETVAL=$?
856e45a
    echo
856e45a
}
856e45a
856e45a
force_reload() {
856e45a
    restart
856e45a
}
856e45a
473d84b
configtest() {
473d84b
  $nginx -t -c $NGINX_CONF_FILE
473d84b
}
473d84b
530e5a0
rh_status() {
856e45a
    status $prog
856e45a
}
856e45a
530e5a0
rh_status_q() {
530e5a0
    rh_status >/dev/null 2>&1
530e5a0
}
530e5a0
856e45a
case "$1" in
530e5a0
    start)
530e5a0
        rh_status_q && exit 0
530e5a0
        $1
530e5a0
        ;;
530e5a0
    stop)
530e5a0
        rh_status_q || exit 0
530e5a0
        $1
530e5a0
        ;;
473d84b
    restart|configtest)
530e5a0
        $1
530e5a0
        ;;
530e5a0
    reload)
530e5a0
        rh_status_q || exit 7
856e45a
        $1
856e45a
        ;;
856e45a
    force-reload)
856e45a
        force_reload
856e45a
        ;;
856e45a
    status)
530e5a0
        rh_status
856e45a
        ;;
856e45a
    condrestart|try-restart)
530e5a0
        rh_status_q || exit 0
530e5a0
	    ;;
856e45a
    *)
473d84b
        echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
856e45a
        exit 2
856e45a
esac