Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 260162 | Differences between
and this patch

Collapse All | Expand All

(-)file_not_specified_in_diff (-15 / +18 lines)
Line  Link Here
0
-- spawn-fcgi.initd
0
++ spawn-fcgi.initd
Lines 3-9 Link Here
3
# Distributed under the terms of the GNU General Public License v2
3
# Distributed under the terms of the GNU General Public License v2
4
# $Header: /var/cvsroot/gentoo-x86/www-servers/spawn-fcgi/files/spawn-fcgi.initd,v 1.2 2009/04/03 18:18:13 bangert Exp $
4
# $Header: /var/cvsroot/gentoo-x86/www-servers/spawn-fcgi/files/spawn-fcgi.initd,v 1.2 2009/04/03 18:18:13 bangert Exp $
5
5
6
PROGNAME=${SVCNAME/spawn\-fcgi./}
6
PROGNAME=${SVCNAME#*.}
7
SPAWNFCGI=/usr/bin/spawn-fcgi
7
SPAWNFCGI=/usr/bin/spawn-fcgi
8
PIDPATH=/var/run/spawn-fcgi
8
PIDPATH=/var/run/spawn-fcgi
9
PIDFILE=${PIDPATH}/${PROGNAME}
9
PIDFILE=${PIDPATH}/${PROGNAME}
Lines 13-19 Link Here
13
}
13
}
14
14
15
start() {
15
start() {
16
	if [[ "${SVCNAME}" == "spawn-fcgi" ]]; then
16
	if [ "${SVCNAME}" = "spawn-fcgi" ]; then
17
		eerror "You are not supposed to run this script directly. Create a symlink"
17
		eerror "You are not supposed to run this script directly. Create a symlink"
18
		eerror "for the FastCGI application you want to run as well as a copy of the"
18
		eerror "for the FastCGI application you want to run as well as a copy of the"
19
		eerror "configuration file and modify it appropriately like so..."
19
		eerror "configuration file and modify it appropriately like so..."
Lines 25-31 Link Here
25
		return 1
25
		return 1
26
	fi
26
	fi
27
27
28
	if [[ ! -z "${FCGI_SOCKET}" ]] && [[ ! -z "${FCGI_PORT}" ]]; then
28
	if [ ! -z "${FCGI_SOCKET}" ] && [ ! -z "${FCGI_PORT}" ]; then
29
		eerror "Only one of the two may be defined:"
29
		eerror "Only one of the two may be defined:"
30
		eerror "  FCGI_SOCKET=${FCGI_SOCKET}"
30
		eerror "  FCGI_SOCKET=${FCGI_SOCKET}"
31
		eerror "  FCGI_PORT=${FCGI_PORT}"
31
		eerror "  FCGI_PORT=${FCGI_PORT}"
Lines 34-60 Link Here
34
34
35
	local X E OPTIONS SOCKET_OPTION PORT_OPTION RETVAL
35
	local X E OPTIONS SOCKET_OPTION PORT_OPTION RETVAL
36
	
36
	
37
	if [[ -z "${FCGI_ADDRESS}" ]]; then
37
	if [ -z "${FCGI_ADDRESS}" ]; then
38
		FCGI_ADDRESS=127.0.0.1
38
		FCGI_ADDRESS=127.0.0.1
39
	fi
39
	fi
40
40
41
	if [[ -z "${FCGI_CHILDREN}" ]]; then
41
	if [ -z "${FCGI_CHILDREN}" ]; then
42
		FCGI_CHILDREN=1
42
		FCGI_CHILDREN=1
43
	fi
43
	fi
44
44
45
	if [[ -n "${PHP_FCGI_CHILDREN}" ]]; then
45
	if [ -n "${PHP_FCGI_CHILDREN}" ]; then
46
		OPTIONS="${OPTIONS} -C ${PHP_FCGI_CHILDREN}"
46
		OPTIONS="${OPTIONS} -C ${PHP_FCGI_CHILDREN}"
47
	fi
47
	fi
48
48
49
	if [[ -n "${FCGI_CHROOT}" ]]; then
49
	if [ -n "${FCGI_CHROOT}" ]; then
50
		OPTIONS="${OPTIONS} -c ${FCGI_CHROOT}"
50
		OPTIONS="${OPTIONS} -c ${FCGI_CHROOT}"
51
	fi
51
	fi
52
52
53
	if [[ -n "${FCGI_USER}" ]] && [[ "${FCGI_USER}" != "root" ]]; then
53
	if [ -n "${FCGI_USER}" ] && [ "${FCGI_USER}" != "root" ]; then
54
		OPTIONS="${OPTIONS} -u ${FCGI_USER}"
54
		OPTIONS="${OPTIONS} -u ${FCGI_USER}"
55
	fi
55
	fi
56
56
57
	if [[ -n "${FCGI_GROUP}" ]] && [[ "${FCGI_GROUP}" != "root" ]]; then
57
	if [ -n "${FCGI_GROUP}" ] && [ "${FCGI_GROUP}" != "root" ]; then
58
		OPTIONS="${OPTIONS} -g ${FCGI_GROUP}"
58
		OPTIONS="${OPTIONS} -g ${FCGI_GROUP}"
59
	fi
59
	fi
60
60
Lines 62-83 Link Here
62
	unset E
62
	unset E
63
63
64
	for i in ${ALLOWED_ENV}; do
64
	for i in ${ALLOWED_ENV}; do
65
		[[ -n "${!i}" ]] && E="${E} -e ${i}=${!i}"
65
		eval j='"$i"'
66
		[ -n "${j}" ] && E="${E} -e ${i}=${j}"
66
	done
67
	done
67
68
68
	ebegin "Starting FastCGI application ${PROGNAME}"
69
	ebegin "Starting FastCGI application ${PROGNAME}"
69
	for X in `seq 1 ${FCGI_CHILDREN}`; do
70
	X=0
71
	while [ $X -lt ${FCGI_CHILDREN} ]; do
72
		X=$(($X+1))
70
		local P
73
		local P
71
		P=${PIDFILE}-${X}.pid
74
		P=${PIDFILE}-${X}.pid
72
		[[ -n "${FCGI_SOCKET}" ]] && SOCKET_OPTION="-s ${FCGI_SOCKET}-${X}"
75
		[ -n "${FCGI_SOCKET}" ] && SOCKET_OPTION="-s ${FCGI_SOCKET}-${X}"
73
		[[ -n "${FCGI_PORT}" ]] && INET_OPTION="-a ${FCGI_ADDRESS} -p $((${FCGI_PORT} + ${X} - 1))"
76
		[ -n "${FCGI_PORT}" ] && INET_OPTION="-a ${FCGI_ADDRESS} -p $((${FCGI_PORT} + ${X} - 1))"
74
77
75
		start-stop-daemon --start --pidfile ${P} ${E} --exec ${SPAWNFCGI} -- \
78
		start-stop-daemon --start --pidfile ${P} ${E} --exec ${SPAWNFCGI} -- \
76
			${SOCKET_OPTION} ${INET_OPTION} -P ${P} ${OPTIONS} -- ${FCGI_PROGRAM}
79
			${SOCKET_OPTION} ${INET_OPTION} -P ${P} ${OPTIONS} -- ${FCGI_PROGRAM}
77
		RETVAL=$?
80
		RETVAL=$?
78
		
81
		
79
		# Stop on error. Don't want to spawn a mess!
82
		# Stop on error. Don't want to spawn a mess!
80
		[[ "${RETVAL}" != "0" ]] && break
83
		[ "${RETVAL}" != "0" ] && break
81
	done
84
	done
82
	eend ${RETVAL}
85
	eend ${RETVAL}
83
}
86
}

Return to bug 260162