summaryrefslogtreecommitdiff
blob: 14537b670692f0988da75ab31c8655931cc398a3 (plain)
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
#!/sbin/runscript
# Copyright 1999-2004 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/www-servers/tux/files/tux.init.d,v 1.1 2004/08/08 19:03:31 stuart Exp $

checkconfig() {
	if [ ! -e /proc/sys/net/tux ] ; then
		# maybe they built is a module ...
		modprobe tux >& /dev/null
		if [ ! -e /proc/sys/net/tux ] ; then
			eerror "Make sure tux support is enabled in your kernel!"
			return 1
		fi
	fi
	if [ -z "${TUX_DOCROOT}" ] ; then
		eerror "You must specify TUX_DOCROOT in /etc/conf.d/tux"
		return 1
	fi
	if [ -z "${TUX_UID}" ] || [ -z "${TUX_GID}" ] ; then
		eerror "You must specify TUX_UID and TUX_GID in /etc/conf.d/tux"
		return 1
	fi
	[ -z "${TUX_THREADS}" ] && TUX_THREADS=1
	[ -z "${TUX_CGIROOT}" ] && TUX_CGIROOT=${TUX_DOCROOT}
	[ -z "${TUX_KEEPALIVE}" ] && TUX_KEEPALIVE=30
	[ -n "${TUX_MODULEPATH}" ] && TUX_MODULES="-m ${TUX_MODULEPATH} ${TUX_MODULES}"
	return 0
}

setconfig() {
	echo ${TUX_THREADS} > /proc/sys/net/tux/threads
	echo ${TUX_DOCROOT} > /proc/sys/net/tux/documentroot
	if [ -n "${TUX_LOGFILE}" ] ; then
		echo 1 > /proc/sys/net/tux/logging
		echo ${TUX_LOGFILE} > /proc/sys/net/tux/logfile
	else
		echo 0 > /proc/sys/net/tux/logging
	fi
	echo ${TUX_UID} > /proc/sys/net/tux/cgi_uid
	echo ${TUX_GID} > /proc/sys/net/tux/cgi_gid
	echo ${TUX_CGIROOT} > /proc/sys/net/tux/cgiroot
	echo ${TUX_KEEPALIVE} > /proc/sys/net/tux/keepalive_timeout
}

start() {
	checkconfig || return 1

	ebegin "Starting tux"
	setconfig
	/usr/sbin/tux -d \
		-u ${TUX_UID} -g ${TUX_GID} \
		-t ${TUX_THREADS} \
		-r ${TUX_DOCROOT} \
		${TUX_MODULES}
	eend $?
}

stop() {
	ebegin "Stopping tux"
	/usr/sbin/tux --stop
	eend $?
}