Created
July 16, 2010 11:00
-
-
Save mariusv/478229 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#chkconfig: 2345 80 05 | |
#description: Nginx | |
. /etc/rc.d/init.d/functions | |
INITLOG_ARGS="" | |
nginx=/usr/local/nginx/sbin/nginx | |
prog=nginx | |
pidfile=${PIDFILE-/var/run/nginx.pid} | |
lockfile=${LOCKFILE-/var/lock/subsys/nginx} | |
RETVAL=0 | |
start() { | |
echo -n $"Starting $prog: " | |
daemon $nginx $OPTIONS | |
RETVAL=$? | |
echo | |
[ $RETVAL = 0 ] && touch ${lockfile} | |
return $RETVAL | |
} | |
stop() { | |
echo -n $"Stopping $prog: " | |
killproc -d 10 $nginx | |
RETVAL=$? | |
echo | |
[ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile} | |
} | |
reload() { | |
echo -n $"Reloading $prog: " | |
if ! $nginx $OPTIONS -t >&/dev/null; then | |
RETVAL=$? | |
echo $"not reloading due to configuration syntax error" | |
failure $"not reloading $httpd due to configuration syntax error" | |
else | |
killproc $nginx -HUP | |
RETVAL=$? | |
fi | |
echo | |
} | |
test() { | |
echo $"Testing $prog config: " | |
$nginx -t | |
echo | |
} | |
case "$1" in | |
start) | |
start | |
;; | |
stop) | |
stop | |
;; | |
status) | |
status $nginx | |
RETVAL=$? | |
;; | |
restart) | |
stop | |
start | |
;; | |
test) | |
test | |
;; | |
condrestart) | |
if [ -f ${pidfile} ] ; then | |
stop | |
start | |
fi | |
;; | |
reload) | |
reload | |
;; | |
*) | |
echo $"Usage: $prog {start|stop|restart|condrestart|reload|status|fullstatus|graceful|help|configtest}" | |
exit 1 | |
esac | |
exit $RETVAL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment