Lines 7-15
Link Here
|
7 |
# Add the following to /etc/rc.conf[.local] to enable this service |
7 |
# Add the following to /etc/rc.conf[.local] to enable this service |
8 |
# |
8 |
# |
9 |
# blocky_enable (bool): Set to NO by default. |
9 |
# blocky_enable (bool): Set to NO by default. |
10 |
# Set it to YES to enable blocky. |
10 |
# Set it to YES to enable blocky. |
11 |
# blocky_config (str): Set to /usr/local/etc/blocky/config.yml by default. |
11 |
# blocky_config (str): Set to /usr/local/etc/blocky-config.yml by default. |
12 |
# |
12 |
# Set it to a path to use that config file. |
|
|
13 |
# blocky_user (str): Services run as root by default. Set to a user name |
14 |
# to run blocky as that user. Note: non-root users |
15 |
# might need permission to bind to ports. |
16 |
# blocky_group (str): Set to the user's primary group by default. |
17 |
# Set it to a group name for daemon file ownership. |
18 |
# blocky_flags (str): Enter extra flags to append to the blocky command. |
13 |
|
19 |
|
14 |
. /etc/rc.subr |
20 |
. /etc/rc.subr |
15 |
|
21 |
|
Lines 20-36
load_rc_config ${name}
Link Here
|
20 |
|
26 |
|
21 |
: ${blocky_enable:=NO} |
27 |
: ${blocky_enable:=NO} |
22 |
: ${blocky_config:="%%PREFIX%%/etc/blocky-config.yml"} |
28 |
: ${blocky_config:="%%PREFIX%%/etc/blocky-config.yml"} |
|
|
29 |
: ${blocky_group:=} |
23 |
: ${blocky_flags:=} |
30 |
: ${blocky_flags:=} |
24 |
|
31 |
|
25 |
pidfile=/var/run/blocky.pid |
32 |
if [ -n "${blocky_user}" ] && [ -z "${blocky_group}" ]; then |
26 |
command="%%PREFIX%%/sbin/blocky" |
33 |
# Detect the daemon user's primary group |
|
|
34 |
blocky_group=$(id -gn "${blocky_user}") |
35 |
fi |
36 |
|
37 |
pidfile="/var/run/${name}.pid" |
38 |
blocky_path="%%PREFIX%%/sbin/blocky" |
39 |
|
40 |
command="/usr/sbin/daemon" |
41 |
procname="/usr/local/sbin/blocky" |
42 |
command_args="-c -f -p ${pidfile} ${blocky_path} \ |
43 |
-c ${blocky_config} ${blocky_flags}" |
27 |
|
44 |
|
28 |
start_cmd="${name}_start" |
45 |
start_precmd="blocky_precmd" |
29 |
|
46 |
|
30 |
blocky_start() |
47 |
# Sets up a pidfile the daemon user can access |
|
|
48 |
blocky_precmd() |
31 |
{ |
49 |
{ |
32 |
echo -n "Starting ${name}." |
50 |
install -o "${blocky_user:-root}" -g "${blocky_group:-wheel}" \ |
33 |
/usr/sbin/daemon -p ${pidfile} -f ${command} -c ${blocky_config} ${blocky_flags} |
51 |
-m 0600 /dev/null "${pidfile}" |
34 |
} |
52 |
} |
35 |
|
53 |
|
36 |
run_rc_command "$1" |
54 |
run_rc_command "$1" |
37 |
- |
|
|