#!/bin/sh # # $FreeBSD: head/net/boinc-client/files/boinc-client.in 325145 2013-08-21 14:45:47Z rene $ # # 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="--daemon %%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 su - ${boinc_client_user} -c \ "\"${command}\" ${boinc_client_flags} ${command_args}" || return 1 pgrep -U ${boinc_client_user} -n -t - '^boinc_client$' \ > "${pidfile}" || return 1 } boinc_client_poststop() { rm -f "${pidfile}" } run_rc_command "$1"