summaryrefslogtreecommitdiff
path: root/net/boinc-client/files/boinc-client.in
blob: 68d57fcec0397fbd993092cad952fafa7b76e084 (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
#!/bin/sh
#
# $FreeBSD$
#
# PROVIDE: boinc-client
# REQUIRE: LOGIN
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf to enable the BOINC client:
#
# boinc_client_enable (boolean)		Set to "YES" to enable boinc_client
#					(default is "NO").
# boinc_client_flags (string)		Additional flags for boinc_client.

. /etc/rc.subr

name="boinc_client"
rcvar=boinc_client_enable

load_rc_config ${name}
: ${boinc_client_enable="NO"}

command="%%PREFIX%%/bin/boinc_client"
pidfile="/var/run/${name}.pid"

boinc_client_user=%%BOINC_CLIENT_USER%%
command_args="--redirectio %%OPTION_NO_GUI_RPC%% %%OPTION_NO_NET_INFO%% --dir %%BOINC_CLIENT_HOME%%"

start_cmd=boinc_client_start
stop_postcmd=boinc_client_poststop

boinc_client_start()
{
	local pid

	pid=$(check_pidfile "${pidfile}" "${command}")
	if [ -n "${pid}" ]; then
		echo 1>&2 "${name} already running? (pid=${pid})."
		return 1
	fi
	echo "Starting ${name}."
	idprio 31 daemon -u ${boinc_client_user} -p ${pidfile} -f ${command} ${boinc_client_flags} ${command_args} || return 1
}

boinc_client_poststop()
{
	rm -f "${pidfile}"
}

run_rc_command "$1"