ports/144060: [PATCH] www/nginx support for profiles in rc.d/nginx like www/apache22
Dmitry V. Sukhodoyev
raven428 at gmail.com
Thu Feb 18 13:30:02 UTC 2010
>Number: 144060
>Category: ports
>Synopsis: [PATCH] www/nginx support for profiles in rc.d/nginx like www/apache22
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: freebsd-ports-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: change-request
>Submitter-Id: current-users
>Arrival-Date: Thu Feb 18 13:30:01 UTC 2010
>Closed-Date:
>Last-Modified:
>Originator: Dmitry V. Sukhodoyev
>Release: FreeBSD 7.2-RELEASE-p4 amd64
>Organization:
i-jet
>Environment:
System: FreeBSD zafira.i-jet.ru 7.2-RELEASE-p4 FreeBSD 7.2-RELEASE-p4 #0: Mon Oct 26 10:09:56 MSK 2009 root at gemini.i-jet.ru:/usr/obj/usr/nfs/src/sys/taran amd64
>Description:
this /usr/local/etc/rc.d/nginx file will add support for multiple nginxes on one machine like port www/apache22
>How-To-Repeat:
>Fix:
# This is a shell archive. Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file". Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
# /usr/local/etc/rc.d/nginx
#
echo x - /usr/local/etc/rc.d/nginx
sed 's/^X//' >/usr/local/etc/rc.d/nginx << '6baee78ac0becb0aaea0d0ac9c52bfa2'
X#!/bin/sh
X#
X# $FreeBSD: ports/www/nginx/files/nginx.sh.in,v 1.4 2008/10/15 07:36:39 osa Exp $
X#
X
X# PROVIDE: nginx
X# REQUIRE: LOGIN cleanvar
X# KEYWORD: shutdown
X
X#
X# Add the following lines to /etc/rc.conf to enable nginx:
X# nginx_enable (bool): Set to "NO" by default.
X# Set it to "YES" to enable nginx
X# nginx_profiles (str): Set to "NO" by default.
X# Unsupported feature, reserved for future releases.
X# nginxlimits_enable (bool): Set to "NO" by default.
X# Set it to yes to run `limits $limits_args`
X# just before nginx starts.
X# nginx_flags (str): Set to "" by default.
X# Extra flags passed to start command.
X# nginxlimits_args (str): Default to "-e -U %%WWWOWN%%"
X# Arguments of pre-start limits run.
X
X. /etc/rc.subr
X
Xname="nginx"
Xrcvar=`set_rcvar`
X
Xstart_precmd="nginx_precmd"
Xrestart_precmd="nginx_checkconfig"
Xreload_precmd="nginx_checkconfig"
Xconfigtest_cmd="nginx_checkconfig"
Xupgrade_precmd="nginx_checkconfig"
Xupgrade_cmd="nginx_upgrade"
Xcommand="/usr/local/sbin/nginx"
X_pidprefix="/var/run/nginx"
Xpidfile="${_pidprefix}.pid"
Xrequired_files=/usr/local/etc/nginx/nginx.conf
X
X[ -z "$nginx_enable" ] && nginx_enable="NO"
X[ -z "$nginx_profiles" ] && nginx_profiles="NO"
X[ -z "$nginx_flags" ] && nginx_flags=""
X[ -z "$nginxlimits_enable" ] && nginxlimits_enable="NO"
X[ -z "$nginxlimits_args" ] && nginxlimits_args="-e -U %%WWWOWN%%"
X
Xload_rc_config $name
X
Xif [ -n "$2" ]; then
X profile="$2"
X if [ "x${nginx_profiles}" != "x" ]; then
X pidfile="${_pidprefix}.${profile}.pid"
X eval nginx_configfile="\${nginx_${profile}_configfile:-}"
X if [ "x${nginx_configfile}" = "x" ]; then
X echo "You must define a configuration file (nginx_${profile}_configfile)"
X exit 1
X fi
X required_files="${nginx_configfile}"
X eval nginx_enable="\${nginx_${profile}_enable:-${nginx_enable}}"
X eval nginx_flags="\${nginx_${profile}_flags:-${nginx_flags}}"
X eval nginxlimits_enable="\${nginxlimits_${profile}_enable:-${nginxlimits_enable}}"
X eval nginxlimits_args="\${nginxlimits_${profile}_args:-${nginxlimits_args}}"
X nginx_flags="-c ${nginx_configfile} -g \"pid ${pidfile};\" ${nginx_flags}"
X else
X echo "$0: extra argument ignored"
X fi
Xelse
X if [ "x${nginx_profiles}" != "x" -a "x$1" != "x" ]; then
X for profile in ${nginx_profiles}; do
X eval _enable="\${nginx_${profile}_enable}"
X case "x${_enable:-${nginx_enable}}" in
X x|x[Nn][Oo]|x[Nn][Oo][Nn][Ee])
X continue
X ;;
X x[Yy][Ee][Ss])
X ;;
X *)
X if test -z "$_enable"; then
X _var=nginx_enable
X else
X _var=nginx_"${profile}"_enable
X fi
X echo "Bad value" \
X "'${_enable:-${nginx_enable}}'" \
X "for ${_var}. " \
X "Profile ${profile} skipped."
X continue
X ;;
X esac
X echo "===> nginx profile: ${profile}"
X $0 $1 ${profile}
X retcode="$?"
X if [ "0${retcode}" -ne 0 ]; then
X failed="${profile} (${retcode}) ${failed:-}"
X else
X success="${profile} ${success:-}"
X fi
X done
X exit 0
X fi
Xfi
X
Xnginx_checkconfig()
X{
X echo "Performing sanity check on nginx configuration:"
X eval ${command} ${nginx_flags} -t
X}
X
Xnginx_upgrade()
X{
X echo "Upgrading nginx binary:"
X
X reload_precmd=""
X sig_reload="USR2"
X run_rc_command ${rc_prefix}reload $rc_extra_args || return 1
X
X sleep 1
X
X echo "Stopping old binary:"
X
X sig_reload="QUIT"
X pidfile="$pidfile.oldbin"
X run_rc_command ${rc_prefix}reload $rc_extra_args || return 1
X}
X
Xnginx_precmd()
X{
X nginx_checkconfig
X
X if checkyesno nginxlimits_enable
X then
X eval `/usr/bin/limits ${nginxlimits_args}` 2>/dev/null
X else
X return 0
X fi
X}
X
Xextra_commands="reload configtest upgrade"
Xrun_rc_command "$1"
6baee78ac0becb0aaea0d0ac9c52bfa2
exit
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-ports-bugs
mailing list