aboutsummaryrefslogtreecommitdiff
path: root/www/fcgiwrap/files/fcgiwrap.in
blob: 82f4f451d1c48ec14a6dc987e87b27a6384c4304 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/bin/sh

# $FreeBSD$
#
# fcgiwrap startup script
#
# PROVIDE: fcgiwrap
# REQUIRE: login
# KEYWORD: shutdown

#
# Add the following to /etc/rc.conf[.local] to enable this service
#
# fcgiwrap_enable="YES"
#
# You can fine tune others variables too:
# fcgiwrap_fib="NONE"
# fcgiwrap_socket="unix:/var/run/fcgiwrap.sock" 
# this could also be:
# - tcp:[ipv4_addr]:port (for ipv4)
# - tcp6:[ipv6_addr]:port (for ipv6)
# fcgiwrap_flags=""
# Use fcgiwrap_user to run fcgiwrap as user

fcgiwrap_setfib() {
	sysctl net.fibs >/dev/null 2>&1 || return 0

	case "$fcgiwrap_fib" in
	[Nn][Oo][Nn][Ee])
		;;
	*)
		command="setfib -F ${fcgiwrap_fib} ${command}"
		;;
	esac
} 

fcgiwrap_precmd() {
	fcgiwrap_setfib

	test -d /var/run/fcgiwrap || mkdir -p /var/run/fcgiwrap
	if [ -n "${fcgiwrap_user}" ]; then
		chown -R ${fcgiwrap_user} /var/run/fcgiwrap
	fi
}

fcgiwrap_cleansocket() {
	# Workaround the fact that fcgiwrap doesn't cleanup his socket at stopping
	case ${fcgiwrap_socket} in 
		unix*)
		test -S ${fcgiwrap_socket#unix:} && rm -f ${fcgiwrap_socket#unix:}
		;;
	esac
	
}

. /etc/rc.subr

pidfile="/var/run/fcgiwrap/fcgiwrap.pid"
name="fcgiwrap"
rcvar=`set_rcvar`

procname="%%PREFIX%%/sbin/${name}"
command="/usr/sbin/daemon"
start_precmd="fcgiwrap_precmd"
stop_postcmd="fcgiwrap_cleansocket"

load_rc_config $name

fcgiwrap_enable=${fcgiwrap_enable:-"NO"}
fcgiwrap_fib=${fcgiwrap_fib:-"NONE"}
fcgiwrap_socket=${fcgiwrap_socket:-"unix:/var/run/fcgiwrap/fcgiwrap.sock"}

command_args="-f -p ${pidfile} ${procname} -s ${fcgiwrap_socket}"

run_rc_command "$1"