aboutsummaryrefslogtreecommitdiff
path: root/www/gatling/files/gatling.in
blob: 48609e1a26dade2da9de5d53dea1b4fe83044375 (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
#!/bin/sh
#
# $FreeBSD$
#

# PROVIDE: gatling
# REQUIRE: LOGIN
# KEYWORD: shutdown

# Set "gatling_enable=yes" in either /etc/rc.conf, /etc/rc.conf.local or
# /etc/rc.conf.d/gatling to enable gatling.
#
# Set gatling_root if you want to serve files from other locations than
# the default (%%PREFIX%%/www/data).
#
# Set gatling_ftp_enable=yes to make gatling serve files via FTP, too.
#
# Set gatling_ssl_enable=yes to serve files via HTTPS/SSL (needs tlsgatling).
#
# Additionally, you can set gatling_effective_user and gatling_flags; please
# see gatling(8) for further information about possible gatling_flags.

check_user() {
	/usr/sbin/pw usershow -n ${gatling_effective_user} -q >/dev/null
}

. /etc/rc.subr

name=gatling
rcvar=`set_rcvar`

load_rc_config ${name}

gatling_enable=${gatling_enable-"NO"}
gatling_root=${gatling_root:-%%PREFIX%%/www/data}
# needed to bind privileged ports at startup:
gatling_user=root
gatling_effective_user=${gatling_effective_user:-www}
gatling_flags="-u ${gatling_effective_user} -c ${gatling_root} ${gatling_flags}"
case "${gatling_ftp_enable}" in
	[Yy][Ee][Ss])
	gatling_flags="-f ${gatling_flags}"
	;;
	*)
	gatling_flags="-F ${gatling_flags}"
	;;
esac

case "${gatling_ssl_enable}" in
	[Yy][Ee][Ss])
	which_gatling="%%PREFIX%%/sbin/tlsgatling"
	;;
	*)
	which_gatling="%%PREFIX%%/sbin/gatling"
	;;
esac

gatling_flags="${which_gatling} ${gatling_flags} &"
command="%%PREFIX%%/sbin/gatling_wrapper"
command_interpreter="/bin/sh -T"
pidfile=/var/run/gatling_wrapper.pid
required_dirs="${gatling_root}"
required_files="${which_gatling}"

start_precmd=check_user
run_rc_command "$1"