Skip to content

Instantly share code, notes, and snippets.

@mariusv
Created July 16, 2010 11:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mariusv/478229 to your computer and use it in GitHub Desktop.
Save mariusv/478229 to your computer and use it in GitHub Desktop.
#!/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