Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 16 Jul 2012 17:47:56 +0000 (UTC)
From:      "Sergey A. Osokin" <osa@FreeBSD.org>
To:        ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org
Subject:   svn commit: r300963 - in head/www: nginx nginx-devel nginx-devel/files nginx/files
Message-ID:  <201207161747.q6GHlunT066054@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: osa
Date: Mon Jul 16 17:47:56 2012
New Revision: 300963
URL: http://svn.freebsd.org/changeset/ports/300963

Log:
  Move rc script nginx.sh.in to more canonical nginx.in.

Added:
  head/www/nginx-devel/files/nginx.in
     - copied unchanged from r300954, head/www/nginx-devel/files/nginx.sh.in
  head/www/nginx/files/nginx.in
     - copied unchanged from r300954, head/www/nginx/files/nginx.sh.in
Deleted:
  head/www/nginx-devel/files/nginx.sh.in
  head/www/nginx/files/nginx.sh.in
Modified:
  head/www/nginx-devel/Makefile
  head/www/nginx/Makefile

Modified: head/www/nginx-devel/Makefile
==============================================================================
--- head/www/nginx-devel/Makefile	Mon Jul 16 17:41:53 2012	(r300962)
+++ head/www/nginx-devel/Makefile	Mon Jul 16 17:47:56 2012	(r300963)
@@ -210,7 +210,7 @@ NGINX_ACCESSLOG?=	${NGINX_LOGDIR}/nginx-
 NGINX_ERRORLOG?=	${NGINX_LOGDIR}/nginx-error.log
 
 CONFLICTS?=	nginx-1.*
-USE_RC_SUBR=	nginx.sh
+USE_RC_SUBR=	nginx
 SUB_LIST+=	WWWOWN=${WWWOWN} \
 		WWWGRP=${WWWGRP} \
 		NGINX_RUNDIR=${NGINX_RUNDIR} \

Copied: head/www/nginx-devel/files/nginx.in (from r300954, head/www/nginx-devel/files/nginx.sh.in)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/www/nginx-devel/files/nginx.in	Mon Jul 16 17:47:56 2012	(r300963, copy of r300954, head/www/nginx-devel/files/nginx.sh.in)
@@ -0,0 +1,133 @@
+#!/bin/sh
+# $FreeBSD$
+
+# PROVIDE: nginx
+# REQUIRE: LOGIN cleanvar
+# KEYWORD: shutdown
+
+#
+# Add the following lines to /etc/rc.conf to enable nginx:
+# nginx_enable (bool):		Set to "NO" by default.
+#				Set it to "YES" to enable nginx
+# nginx_profiles (str):		Set to "" by default.
+#				Define your profiles here.
+# nginxlimits_enable (bool):	Set to "NO" by default.
+#				Set it to yes to run `limits $limits_args`
+#				just before nginx starts.
+# nginx_flags (str):		Set to "" by default.
+#				Extra flags passed to start command.
+# nginxlimits_args (str):	Default to "-e -U %%WWWOWN%%"
+#				Arguments of pre-start limits run.
+
+. /etc/rc.subr
+
+name="nginx"
+rcvar=nginx_enable
+
+start_precmd="nginx_precmd"
+restart_precmd="nginx_checkconfig"
+reload_precmd="nginx_checkconfig"
+configtest_cmd="nginx_checkconfig"
+gracefulstop_cmd="nginx_gracefulstop"
+upgrade_precmd="nginx_checkconfig"
+upgrade_cmd="nginx_upgrade"
+command="%%PREFIX%%/sbin/nginx"
+_pidprefix="%%NGINX_RUNDIR%%"
+pidfile="${_pidprefix}/${name}.pid"
+_tmpprefix="%%NGINX_TMPDIR%%"
+required_files=%%PREFIX%%/etc/nginx/nginx.conf
+extra_commands="reload configtest upgrade gracefulstop"
+
+[ -z "$nginx_enable" ]		&& nginx_enable="NO"
+[ -z "$nginxlimits_enable" ]	&& nginxlimits_enable="NO"
+[ -z "$nginxlimits_args" ]	&& nginxlimits_args="-e -U %%WWWOWN%%"
+
+load_rc_config $name
+
+if [ -n "$2" ]; then
+	profile="$2"
+	if [ "x${nginx_profiles}" != "x" ]; then
+		pidfile="${_pidprefix}.${profile}.pid"
+		eval nginx_configfile="\${nginx_${profile}_configfile:-}"
+		if [ "x${nginx_configfile}" = "x" ]; then
+			echo "You must define a configuration file (nginx_${profile}_configfile)"
+			exit 1
+		fi
+		required_files="${nginx_configfile}"
+		eval nginx_enable="\${nginx_${profile}_enable:-${nginx_enable}}"
+		eval nginx_flags="\${nginx_${profile}_flags:-${nginx_flags}}"
+		eval nginxlimits_enable="\${nginxlimits_${profile}_enable:-${nginxlimits_enable}}"
+		eval nginxlimits_args="\${nginxlimits_${profile}_args:-${nginxlimits_args}}"
+		nginx_flags="-c ${nginx_configfile} -g \"pid ${pidfile};\" ${nginx_flags}"
+	else
+		echo "$0: extra argument ignored"
+	fi
+else
+	if [ "x${nginx_profiles}" != "x" -a "x$1" != "x" ]; then
+		for profile in ${nginx_profiles}; do
+			echo "===> nginx profile: ${profile}"
+			%%PREFIX%%/etc/rc.d/nginx $1 ${profile}
+			retcode="$?"
+			if [ "0${retcode}" -ne 0 ]; then
+				failed="${profile} (${retcode}) ${failed:-}"
+			else
+				success="${profile} ${success:-}"
+			fi
+		done
+		exit 0
+	fi
+fi
+
+# tmpfs(5)
+nginx_checktmpdir()
+{
+	if [ ! -d ${_tmpprefix} ] ; then
+		install -d -o %%WWWOWN%% -g %%WWWGRP%% -m 755 ${_tmpprefix}
+	fi
+}
+
+nginx_checkconfig()
+{
+	nginx_checktmpdir
+
+	echo "Performing sanity check on nginx configuration:"
+	eval ${command} ${nginx_flags} -t
+}
+
+nginx_gracefulstop()
+{
+	echo "Performing a graceful stop:"
+	sig_stop="QUIT"
+	run_rc_command ${rc_prefix}stop $rc_extra_args || return 1
+}
+
+nginx_upgrade()
+{
+	echo "Upgrading nginx binary:"
+
+	reload_precmd=""
+	sig_reload="USR2"
+	run_rc_command ${rc_prefix}reload $rc_extra_args || return 1
+
+	sleep 1
+
+	echo "Stopping old binary:"
+
+	sig_reload="QUIT"
+	pidfile="$pidfile.oldbin"
+	run_rc_command ${rc_prefix}reload $rc_extra_args || return 1
+}
+
+nginx_precmd() 
+{
+	nginx_checkconfig
+
+	if checkyesno nginxlimits_enable
+	then
+		eval `/usr/bin/limits ${nginxlimits_args}` 2>/dev/null
+	else
+		return 0
+	fi
+}
+
+run_rc_command "$1"

Modified: head/www/nginx/Makefile
==============================================================================
--- head/www/nginx/Makefile	Mon Jul 16 17:41:53 2012	(r300962)
+++ head/www/nginx/Makefile	Mon Jul 16 17:47:56 2012	(r300963)
@@ -208,7 +208,7 @@ NGINX_ACCESSLOG?=	${NGINX_LOGDIR}/nginx-
 NGINX_ERRORLOG?=	${NGINX_LOGDIR}/nginx-error.log
 
 CONFLICTS?=	nginx-devel-1.*
-USE_RC_SUBR=	nginx.sh
+USE_RC_SUBR=	nginx
 SUB_LIST+=	WWWOWN=${WWWOWN} \
 		WWWGRP=${WWWGRP} \
 		NGINX_RUNDIR=${NGINX_RUNDIR} \

Copied: head/www/nginx/files/nginx.in (from r300954, head/www/nginx/files/nginx.sh.in)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/www/nginx/files/nginx.in	Mon Jul 16 17:47:56 2012	(r300963, copy of r300954, head/www/nginx/files/nginx.sh.in)
@@ -0,0 +1,133 @@
+#!/bin/sh
+# $FreeBSD$
+
+# PROVIDE: nginx
+# REQUIRE: LOGIN cleanvar
+# KEYWORD: shutdown
+
+#
+# Add the following lines to /etc/rc.conf to enable nginx:
+# nginx_enable (bool):		Set to "NO" by default.
+#				Set it to "YES" to enable nginx
+# nginx_profiles (str):		Set to "" by default.
+#				Define your profiles here.
+# nginxlimits_enable (bool):	Set to "NO" by default.
+#				Set it to yes to run `limits $limits_args`
+#				just before nginx starts.
+# nginx_flags (str):		Set to "" by default.
+#				Extra flags passed to start command.
+# nginxlimits_args (str):	Default to "-e -U %%WWWOWN%%"
+#				Arguments of pre-start limits run.
+
+. /etc/rc.subr
+
+name="nginx"
+rcvar=nginx_enable
+
+start_precmd="nginx_precmd"
+restart_precmd="nginx_checkconfig"
+reload_precmd="nginx_checkconfig"
+configtest_cmd="nginx_checkconfig"
+gracefulstop_cmd="nginx_gracefulstop"
+upgrade_precmd="nginx_checkconfig"
+upgrade_cmd="nginx_upgrade"
+command="%%PREFIX%%/sbin/nginx"
+_pidprefix="%%NGINX_RUNDIR%%"
+pidfile="${_pidprefix}/${name}.pid"
+_tmpprefix="%%NGINX_TMPDIR%%"
+required_files=%%PREFIX%%/etc/nginx/nginx.conf
+extra_commands="reload configtest upgrade gracefulstop"
+
+[ -z "$nginx_enable" ]		&& nginx_enable="NO"
+[ -z "$nginxlimits_enable" ]	&& nginxlimits_enable="NO"
+[ -z "$nginxlimits_args" ]	&& nginxlimits_args="-e -U %%WWWOWN%%"
+
+load_rc_config $name
+
+if [ -n "$2" ]; then
+	profile="$2"
+	if [ "x${nginx_profiles}" != "x" ]; then
+		pidfile="${_pidprefix}.${profile}.pid"
+		eval nginx_configfile="\${nginx_${profile}_configfile:-}"
+		if [ "x${nginx_configfile}" = "x" ]; then
+			echo "You must define a configuration file (nginx_${profile}_configfile)"
+			exit 1
+		fi
+		required_files="${nginx_configfile}"
+		eval nginx_enable="\${nginx_${profile}_enable:-${nginx_enable}}"
+		eval nginx_flags="\${nginx_${profile}_flags:-${nginx_flags}}"
+		eval nginxlimits_enable="\${nginxlimits_${profile}_enable:-${nginxlimits_enable}}"
+		eval nginxlimits_args="\${nginxlimits_${profile}_args:-${nginxlimits_args}}"
+		nginx_flags="-c ${nginx_configfile} -g \"pid ${pidfile};\" ${nginx_flags}"
+	else
+		echo "$0: extra argument ignored"
+	fi
+else
+	if [ "x${nginx_profiles}" != "x" -a "x$1" != "x" ]; then
+		for profile in ${nginx_profiles}; do
+			echo "===> nginx profile: ${profile}"
+			%%PREFIX%%/etc/rc.d/nginx $1 ${profile}
+			retcode="$?"
+			if [ "0${retcode}" -ne 0 ]; then
+				failed="${profile} (${retcode}) ${failed:-}"
+			else
+				success="${profile} ${success:-}"
+			fi
+		done
+		exit 0
+	fi
+fi
+
+# tmpfs(5)
+nginx_checktmpdir()
+{
+	if [ ! -d ${_tmpprefix} ] ; then
+		install -d -o %%WWWOWN%% -g %%WWWGRP%% -m 755 ${_tmpprefix}
+	fi
+}
+
+nginx_checkconfig()
+{
+	nginx_checktmpdir
+
+	echo "Performing sanity check on nginx configuration:"
+	eval ${command} ${nginx_flags} -t
+}
+
+nginx_gracefulstop()
+{
+	echo "Performing a graceful stop:"
+	sig_stop="QUIT"
+	run_rc_command ${rc_prefix}stop $rc_extra_args || return 1
+}
+
+nginx_upgrade()
+{
+	echo "Upgrading nginx binary:"
+
+	reload_precmd=""
+	sig_reload="USR2"
+	run_rc_command ${rc_prefix}reload $rc_extra_args || return 1
+
+	sleep 1
+
+	echo "Stopping old binary:"
+
+	sig_reload="QUIT"
+	pidfile="$pidfile.oldbin"
+	run_rc_command ${rc_prefix}reload $rc_extra_args || return 1
+}
+
+nginx_precmd() 
+{
+	nginx_checkconfig
+
+	if checkyesno nginxlimits_enable
+	then
+		eval `/usr/bin/limits ${nginxlimits_args}` 2>/dev/null
+	else
+		return 0
+	fi
+}
+
+run_rc_command "$1"



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201207161747.q6GHlunT066054>