summaryrefslogtreecommitdiff
blob: 5bd6bf5e8cbc5acfac2dd33bae054a15af317757 (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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/sbin/runscript
# Copyright 1999-2007 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/dev-dotnet/xsp/files/1.2.4/mod-mono-server.initd,v 1.1 2007/05/17 18:18:53 jurek Exp $

depend() {
	use net
	after dotnet
}

start() {
	[ -z "$MonoServerRootDir" ] && \
	MonoServerRootDir="/usr/lib/xsp/test"
	[ -z "$MonoApplications" ] && \
	MonoApplications="/mono:/usr/lib/xsp/test,/:."
	[ -z "$UnixSocketFileName" ] && \
	UnixSocketFileName="/tmp/mod_mono_server"
	[ -z "$MonoServerAddress" ] && \
	MonoServerAddress=127.0.0.1
	[ -z "$MonoServerPort" ] && \
	MonoServerPort=8080
	[ -z "$MonoServerVersion" ] && \
	MonoServerVersion=1

	MONO_SERVER_OPTS="--root ${MonoServerRootDir} \
--applications ${MonoApplications} --nonstop"

	[ -n "$MonoApplicationsConfigDir" ] && \
	MONO_SERVER_OPTS="${MONO_SERVER_OPTS} \
--appconfigdir ${MonoApplicationsConfigDir}"

	case "$MonoServerChannel" in
	"tcp" )
		MONO_SERVER_OPTS="${MONO_SERVER_OPTS} \
--address ${MonoServerAddress} --port ${MonoServerPort}"
		;;
	
	"unix" )
		[ -f "$UnixSocketFileName" ] && rm -f $UnixSocketFileName
		MONO_SERVER_OPTS="${MONO_SERVER_OPTS} \
--filename ${UnixSocketFileName}"
		;;

	* )
		eerror "Please set a valid value for MonoServerChannel"
		return 1
		;;
	esac

	if [ ${MonoServerVersion} -eq 1 ]; then
		modmonoserverpath=1.0/mod-mono-server.exe
	elif [ ${MonoServerVersion} -eq 2 ]; then
		modmonoserverpath=2.0/mod-mono-server2.exe
	else
		eerror "MonoServerVersion was not properly set. Check your /etc/conf.d/xsp"
		return 1
	fi

	export MONO_SHARED_DIR=/tmp

	ebegin "Starting mod-mono-server"

	start-stop-daemon --quiet --start \
		--background \
		--make-pidfile \
		--pidfile /var/run/aspnet/mod-mono-server.pid \
		--chuid aspnet \
		--exec /usr/bin/mono /usr/lib/mono/${modmonoserverpath} \
		-- $MONO_SERVER_OPTS

	eend $?
}

stop() {
	ebegin "Stopping mod-mono-server"

	start-stop-daemon -o --quiet --stop \
		--pidfile /var/run/aspnet/mod-mono-server.pid

	eend $?
}