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