ports-local/security/glauth/files/glauth.in
2023-11-16 00:50:13 -05:00

54 lines
1.5 KiB
Bash

#!/bin/sh
# PROVIDE: glauth
# REQUIRE: DAEMON NETWORKING
# KEYWORD: shutdown
#
# Add the following to /etc/rc.conf[.local] to enable this service
#
# glauth_enable (bool): Set to NO by default.
# Set it to YES to enable glauth.
# glauth_config (str): Set to /usr/local/etc/glauth-config.yml by default.
# Set it to a path to use that config file.
# glauth_user (str): Services run as root by default. Set to a user name
# to run glauth as that user. Note: non-root users
# might need permission to bind to ports.
# glauth_group (str): Set to the user's primary group by default.
# Set it to a group name for daemon file ownership.
# glauth_flags (str): Enter extra flags to append to the glauth command.
. /etc/rc.subr
name=glauth
rcvar=glauth_enable
load_rc_config ${name}
: ${glauth_enable:=NO}
: ${glauth_config:="%%PREFIX%%/etc/glauth-config.cfg"}
: ${glauth_group:=}
: ${glauth_flags:=}
if [ -n "${glauth_user}" ] && [ -z "${glauth_group}" ]; then
# Detect the daemon user's primary group
glauth_group=$(id -gn "${glauth_user}")
fi
pidfile="/var/run/${name}.pid"
glauth_path="%%PREFIX%%/sbin/glauth"
command="/usr/sbin/daemon"
procname="/usr/local/sbin/glauth"
command_args="-c -f -p ${pidfile} ${glauth_path} \
-c ${glauth_config} ${glauth_flags}"
start_precmd="glauth_precmd"
# Sets up a pidfile the daemon user can access
glauth_precmd()
{
install -o "${glauth_user:-root}" -g "${glauth_group:-wheel}" \
-m 0600 /dev/null "${pidfile}"
}
run_rc_command "$1"