freebsd-dev/etc/rc.d/syslogd
Doug Barton 801c438304 Prepare for the removal of set_rcvar() by changing the rcvar=
assignments to the literal values it would have returned.

The concept of set_rcvar() was nice in theory, but the forks
it creates are a drag on the startup process, which is especially
noticeable on slower systems, such as embedded ones.

During the discussion on freebsd-rc@ a preference was expressed for
using ${name}_enable instead of the literal values. However the
code portability concept doesn't really apply since there are so
many other places where the literal name has to be searched for
and replaced. Also, using the literal value is also a tiny bit
faster than dereferencing the variables, and every little bit helps.
2012-01-14 02:18:41 +00:00

73 lines
1.4 KiB
Bash
Executable File

#!/bin/sh
#
# $FreeBSD$
#
# PROVIDE: syslogd
# REQUIRE: mountcritremote cleanvar newsyslog
# BEFORE: SERVERS
. /etc/rc.subr
name="syslogd"
rcvar="syslogd_enable"
pidfile="/var/run/syslog.pid"
command="/usr/sbin/${name}"
required_files="/etc/syslog.conf"
start_precmd="syslogd_precmd"
extra_commands="reload"
sockfile="/var/run/syslogd.sockets"
evalargs="rc_flags=\"\`set_socketlist\` \$rc_flags\""
altlog_proglist="named"
syslogd_precmd()
{
local _l _ldir
# Transitional symlink for old binaries
#
if [ ! -L /dev/log ]; then
ln -sf /var/run/log /dev/log
fi
rm -f /var/run/log
# Create default list of syslog sockets to watch
#
( umask 022 ; > $sockfile )
# If running named(8) or ntpd(8) chrooted, added appropriate
# syslog socket to list of sockets to watch.
#
for _l in $altlog_proglist; do
eval _ldir=\$${_l}_chrootdir
if checkyesno ${_l}_enable && [ -n "$_ldir" ]; then
echo "${_ldir}/var/run/log" >> $sockfile
fi
done
# If other sockets have been provided, change run_rc_command()'s
# internal copy of $syslogd_flags to force use of specific
# syslogd sockets.
#
if [ -s $sockfile ]; then
echo "/var/run/log" >> $sockfile
eval $evalargs
fi
return 0
}
set_socketlist()
{
local _s _socketargs
_socketargs=
for _s in `cat $sockfile | tr '\n' ' '` ; do
_socketargs="-l $_s $_socketargs"
done
echo $_socketargs
}
load_rc_config $name
run_rc_command "$1"