xref: /freebsd/libexec/rc/rc.d/syslogd (revision 6ef644f5889afbd0f681b08ed1a2f369524af83e)
1#!/bin/sh
2#
3#
4
5# netif is required for lo0 because syslogd tries to open a local socket
6#
7# PROVIDE: syslogd
8# REQUIRE: mountcritremote FILESYSTEMS newsyslog netif
9# BEFORE:  SERVERS
10
11. /etc/rc.subr
12
13name="syslogd"
14desc="System log daemon"
15rcvar="syslogd_enable"
16pidfile="/var/run/syslog.pid"
17command="/usr/sbin/${name}"
18required_files="/etc/syslog.conf"
19start_precmd="syslogd_precmd"
20extra_commands="reload"
21
22sockfile="/var/run/syslogd.sockets"
23evalargs="rc_flags=\"\`set_socketlist\` \$rc_flags\""
24
25syslogd_precmd()
26{
27	local _l _ldir
28
29	#	Transitional symlink for old binaries
30	#
31	if [ ! -L /dev/log ] && ! check_jail jailed; then
32		ln -sf /var/run/log /dev/log
33	fi
34	rm -f /var/run/log
35
36	#	Create default list of syslog sockets to watch
37	#
38	( umask 022 ; > $sockfile )
39
40	#	If running named(8) or ntpd(8) chrooted, added appropriate
41	#	syslog socket to list of sockets to watch.
42	#
43	for _l in $altlog_proglist; do
44		eval _ldir=\$${_l}_chrootdir
45		if checkyesno ${_l}_enable && [ -n "$_ldir" ]; then
46			echo "${_ldir}/var/run/log" >> $sockfile
47		fi
48	done
49
50	#	If other sockets have been provided, change run_rc_command()'s
51	#	internal copy of $syslogd_flags to force use of specific
52	#	syslogd sockets.
53	#
54	if [ -s $sockfile ]; then
55		echo "/var/run/log" >> $sockfile
56		eval $evalargs
57	fi
58
59	return 0
60}
61
62set_socketlist()
63{
64	local _s _socketargs
65
66	_socketargs=
67	for _s in `cat $sockfile | tr '\n' ' '` ; do
68		_socketargs="-l $_s $_socketargs"
69	done
70	echo $_socketargs
71}
72load_rc_config $name
73run_rc_command "$1"
74