aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBaptiste Daroussin <bapt@FreeBSD.org>2012-01-27 08:05:14 +0000
committerBaptiste Daroussin <bapt@FreeBSD.org>2012-01-27 08:05:14 +0000
commit4b7df72a76914e8730c16538be3234c9cbc9200a (patch)
tree46d78cb76a1cc1ea757f54ffcb4d9698dd4e22ff
parent20af63807d63bc3a12183307c11c41fa1cf875b8 (diff)
downloadports-4b7df72a76914e8730c16538be3234c9cbc9200a.tar.gz
ports-4b7df72a76914e8730c16538be3234c9cbc9200a.zip
Notes
-rw-r--r--www/fcgiwrap/Makefile5
-rw-r--r--www/fcgiwrap/files/fcgiwrap.in51
2 files changed, 52 insertions, 4 deletions
diff --git a/www/fcgiwrap/Makefile b/www/fcgiwrap/Makefile
index a942d1eb5755..ea084044b5e6 100644
--- a/www/fcgiwrap/Makefile
+++ b/www/fcgiwrap/Makefile
@@ -7,17 +7,18 @@
PORTNAME= fcgiwrap
PORTVERSION= 1.0.3
-PORTREVISION= 3
+PORTREVISION= 4
CATEGORIES= www
MASTER_SITES= http://cloud.github.com/downloads/gnosek/fcgiwrap/
MAINTAINER= bapt@FreeBSD.org
COMMENT= Simple FastCGI wrapper for CGI scripts
+LICENSE= MIT
+
LIB_DEPENDS= fcgi.0:${PORTSDIR}/www/fcgi
WRKSRC= ${WRKDIR}/gnosek-fcgiwrap-2e301c8
-LICENSE= MIT
USE_RC_SUBR= fcgiwrap
diff --git a/www/fcgiwrap/files/fcgiwrap.in b/www/fcgiwrap/files/fcgiwrap.in
index cbbe791ccb5d..c4466f164d55 100644
--- a/www/fcgiwrap/files/fcgiwrap.in
+++ b/www/fcgiwrap/files/fcgiwrap.in
@@ -21,6 +21,21 @@
# fcgiwrap_flags=
# Use fcgiwrap_user to run fcgiwrap as user
+# fcgiwrap rc.d script supports multiple profiles (a-la rc.d/nginx)
+# When profiles are specified, the non-profile specific parameters become defaults.
+# You need to make sure that no two profiles have the same socket parameter.
+#
+# Example:
+#
+# fcgiwrap_enable="YES"
+# fcgiwrap_profiles="myserver myotherserver"
+# fcgiwrap_flags="-c 4"
+# fcgiwrap_myserver_socket="unix:/var/run/fcgiwrap.myserver.socket"
+# fcgiwrap_myserver_user="myuser"
+# fcgiwrap_myotherserver_socket="unix:/var/run/fcgiwrap.myotherserver.socket"
+# fcgiwrap_myotherserver_user="myotheruser"
+# fcgiwrap_myotherserver_flags="" # No flags for this profile.
+
. /etc/rc.subr
name="fcgiwrap"
@@ -40,7 +55,7 @@ fcgiwrap_setfib() {
fcgiwrap_precmd() {
fcgiwrap_setfib
- install -d -o $fcgiwrap_user -m 755 /var/run/fcgiwrap
+ install -d -o root -g wheel -m 1777 /var/run/fcgiwrap
}
fcgiwrap_cleansocket() {
@@ -53,7 +68,8 @@ fcgiwrap_cleansocket() {
rm -f $pidfile
}
-pidfile="/var/run/fcgiwrap/fcgiwrap.pid"
+pidprefix="/var/run/fcgiwrap/fcgiwrap"
+pidfile="${pidprefix}.pid" # May be a different path if profiles are in use
procname="%%PREFIX%%/sbin/${name}"
command="/usr/sbin/daemon"
@@ -62,11 +78,42 @@ stop_postcmd="fcgiwrap_cleansocket"
load_rc_config $name
+# These are just the defaults, they might get overriden for a specific profile.
fcgiwrap_enable=${fcgiwrap_enable:-"NO"}
fcgiwrap_fib=${fcgiwrap_fib:-"NONE"}
fcgiwrap_user=${fcgiwrap_user:-"root"}
fcgiwrap_socket=${fcgiwrap_socket:-"unix:/var/run/fcgiwrap/fcgiwrap.sock"}
+# This handles profile specific vars.
+if [ -n "$2" ]; then
+ profile="$2"
+ if [ -n "${fcgiwrap_profiles}" ]; then
+ pidfile="${pidprefix}.${profile}.pid"
+ eval fcgiwrap_enable="\${fcgiwrap_${profile}_enable:-${fcgiwrap_enable}}"
+ eval fcgiwrap_fib="\${fcgiwrap_${profile}_fib:-${fcgiwrap_fib}}"
+ eval fcgiwrap_user="\${fcgiwrap_${profile}_user:-${fcgiwrap_user}}"
+ eval fcgiwrap_socket="\${fcgiwrap_${profile}_socket:?}"
+ eval fcgiwrap_flags="\${fcgiwrap_${profile}_flags:-${fciwrap_flags}}"
+ else
+ echo "$0: extra argument ignored"
+ fi
+else
+ if [ -n "${fcgiwrap_profiles}" -a -n "$1" ]; then
+ for profile in ${fcgiwrap_profiles}; do
+ echo "===> fcgiwrap profile: ${profile}"
+ /usr/local/etc/rc.d/fcgiwrap $1 ${profile}
+ retcode="$?"
+ if [ "0${retcode}" -ne 0 ]; then
+ failed="${profile} (${retcode}) ${failed:-}"
+ else
+ success="${profile} ${success:-}"
+ fi
+ done
+ # It exits so that non-profile rc.d is not started when there are profiles.
+ exit 0
+ fi
+fi
+
command_args="-f -p ${pidfile} ${procname} -s ${fcgiwrap_socket}"
run_rc_command "$1"