#!/bin/sh # # nginx # ### BEGIN INIT INFO # Provides: nginx # Required-Start: $local_fs $remote_fs $network $syslog # Required-Stop: $local_fs $remote_fs $network $syslog # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: starts the nginx web server # Description: starts nginx using start-stop-daemon ### END INIT INFO # Source function library. . /etc/rc.status rc_reset # Check that networking is up. [ "$NETWORKING" = "no" ] && exit exec=<%= node['nginx']['binary'] %> prog=$(basename $exec) # default options, overruled by items in sysconfig NGINX_GLOBAL="" [ -e /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx lockfile=/var/lock/subsys/nginx start() { [ -x $exec ] || exit 5 echo -n $"Starting $prog: " # if not running, start it up here, usually something like "daemon $exec" options="" if [ "${NGINX_GLOBAL}" != "" ]; then options="-g ${NGINX_GLOBAL}" fi $exec $options retval=$? echo [ $retval -eq 0 ] && touch $lockfile rc_status -v } stop() { echo -n $"Stopping $prog: " $exec -s stop retval=$? echo [ $retval -eq 0 ] && rm -f $lockfile rc_status -v } restart() { stop start rc_status } reload() { echo -n $"Reloading $prog: " $exec -s reload retval=$? echo [ $retval -eq 0 ] && rm -f $lockfile rc_status -v } configtest() { if [ "$#" -ne 0 ] ; then case "$1" in -q) FLAG=$1 ;; *) ;; esac shift fi ${exec} -t $FLAG RETVAL=$? return $RETVAL } # See how we were called. case "$1" in start) start ;; stop) stop ;; status) status nginx ;; restart) restart ;; reload|force-reload) reload ;; condrestart) [ -f $lockfile ] && restart || : ;; configtest) configtest ;; *) echo $"Usage: $0 {start|stop|status|restart|reload|force-reload|condrestart|configtest}" exit 1 esac exit $?