ports-local/dns/blocky-devel/files/blocky.in

55 lines
1.5 KiB
Plaintext
Raw Normal View History

2022-09-14 21:47:32 -04:00
#!/bin/sh
# PROVIDE: blocky
# REQUIRE: DAEMON NETWORKING
# KEYWORD: shutdown
#
# Add the following to /etc/rc.conf[.local] to enable this service
#
# blocky_enable (bool): Set to NO by default.
2023-02-01 10:17:35 -05:00
# Set it to YES to enable blocky.
# blocky_config (str): Set to /usr/local/etc/blocky-config.yml by default.
# Set it to a path to use that config file.
# blocky_user (str): Services run as root by default. Set to a user name
# to run blocky as that user. Note: non-root users
# might need permission to bind to ports.
# blocky_group (str): Set to the user's primary group by default.
# Set it to a group name for daemon file ownership.
# blocky_flags (str): Enter extra flags to append to the blocky command.
2022-09-14 21:47:32 -04:00
. /etc/rc.subr
name=blocky
rcvar=blocky_enable
load_rc_config ${name}
: ${blocky_enable:=NO}
: ${blocky_config:="%%PREFIX%%/etc/blocky-config.yml"}
2023-02-01 10:17:35 -05:00
: ${blocky_group:=}
2022-09-14 21:47:32 -04:00
: ${blocky_flags:=}
2023-02-01 10:17:35 -05:00
if [ -n "${blocky_user}" ] && [ -z "${blocky_group}" ]; then
# Detect the daemon user's primary group
blocky_group=$(id -gn "${blocky_user}")
fi
pidfile="/var/run/${name}.pid"
blocky_path="%%PREFIX%%/sbin/blocky"
command="/usr/sbin/daemon"
procname="/usr/local/sbin/blocky"
command_args="-c -f -p ${pidfile} ${blocky_path} \
-c ${blocky_config} ${blocky_flags}"
2022-09-14 21:47:32 -04:00
2023-02-01 10:17:35 -05:00
start_precmd="blocky_precmd"
2022-09-14 21:47:32 -04:00
2023-02-01 10:17:35 -05:00
# Sets up a pidfile the daemon user can access
blocky_precmd()
2022-09-14 21:47:32 -04:00
{
2023-02-01 10:17:35 -05:00
install -o "${blocky_user:-root}" -g "${blocky_group:-wheel}" \
-m 0600 /dev/null "${pidfile}"
2022-09-14 21:47:32 -04:00
}
run_rc_command "$1"