aboutsummaryrefslogtreecommitdiffstats
path: root/net/boinc-client/files/boinc.sh.in
blob: 4c87c3e7c7f8b5c32096fe92fef7a1ec92c8748b (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
# REQUIRE: LOGIN
# KEYWORD: FreeBSD shutdown

. %%RC_SUBR%%

name="boinc"
rcvar=`set_rcvar`

boinc_user=%%BOINC_USER%%
boinc_home=%%BOINC_HOME%%
program_file=%%BOINC_BINARY%%
program_path=%%PREFIX%%/lib/boinc/${program_file}
syslog_facility=daemon.err

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

start_cmd=boinc_start
stop_cmd=boinc_stop

boinc_start() {
    if checkyesno boinc_enable
    then
        if [ ! -x ${program_path} ]
        then
            logger -sp ${syslog_facility} -t ${program_file} \
                "unable to start: ${program_path} is missing."
            exit 72
        fi
        if ps axo ucomm | egrep ${program_file}; then
            logger -sp ${syslog_facility} -t ${program_file} \
            "unable to start: ${program_file} is already running."
            exit 72
        fi
        echo "Starting BOINC client."
        export LD_LIBRARY_PATH=%%LOCALBASE%%/lib/boinc
        idprio 31 su - ${boinc_user} -c "${program_path} ${boinc_flags} >/dev/null &"
    fi
}

boinc_stop() {
    killall ${program_file} 2> /dev/null
}

run_rc_command "$1"