Files
ports/sysutils/fluent-bit/files/fluent-bit.in
T
Michael Osipov efa59bb216 sysutils/fluent-bit: Improve RC script and fix issues
* Document 'fluent_bit_group' variable
* Install PID file with mode 0600 instead of 0755
* Reuse ${name}
* Pass '-t {name}' to daemon(8)
* Remove self-created PID file

PR:		292782
MFH:		2026Q1
Approved by:	girgen (maintainer)
2026-01-28 18:29:48 +01:00

51 lines
1.3 KiB
Bash

#!/bin/sh
# PROVIDE: fluent-bit
# REQUIRE: DAEMON
# BEFORE: LOGIN
# KEYWORD: shutdown
# Add the following lines to /etc/rc.conf to enable fluent-bit:
#
# fluent_bit_enable (bool): Set to YES to enable fluent-bit
# Default: NO
# fluent_bit_config (str): config files to use
# Default: %%ETCDIR%%/fluent-bit.conf
# fluent_bit_flags (str): Extra flags passed to fluent-bit
# fluent_bit_user (str): Default run as user nobody
# fluent_bit_group (str): Default run as group nogroup
. /etc/rc.subr
name="fluent_bit"
rcvar=${name}_enable
load_rc_config $name
: ${fluent_bit_enable:="NO"}
: ${fluent_bit_user:="nobody"}
: ${fluent_bit_group:="nogroup"}
: ${fluent_bit_config:="%%ETCDIR%%/fluent-bit.conf"}
pidfile=/var/run/${name}.pid
procname="%%PREFIX%%/bin/fluent-bit"
command="/usr/sbin/daemon"
command_args="-H -p ${pidfile} -o /var/log/${name}/${name}.log -t ${name} ${procname} --quiet --config ${fluent_bit_config} ${fluent_bit_flags}"
start_precmd="${name}_startprecmd"
stop_postcmd="${name}_stoppostcmd"
fluent_bit_startprecmd()
{
install -o ${fluent_bit_user} -g ${fluent_bit_group} -d /var/log/${name}
if [ ! -e ${pidfile} ]; then
install -m 0600 -o ${fluent_bit_user} -g ${fluent_bit_group} /dev/null ${pidfile}
fi
}
fluent_bit_stoppostcmd()
{
rm -f ${pidfile}
}
run_rc_command "$1"