xref: /dflybsd-src/etc/rc.d/syslogd (revision ce0833857e05eba4d13f3fd8a4d049ea68c5ffa4)
19c600e7dSMatthew Dillon#!/bin/sh
29c600e7dSMatthew Dillon#
39c600e7dSMatthew Dillon# $NetBSD: syslogd,v 1.12 2002/03/22 04:34:00 thorpej Exp $
49c600e7dSMatthew Dillon# $FreeBSD: src/etc/rc.d/syslogd,v 1.4 2002/10/01 13:29:44 ru Exp $
59c600e7dSMatthew Dillon#
69c600e7dSMatthew Dillon
79c600e7dSMatthew Dillon# PROVIDE: syslogd
8*ce083385SAaron LI# REQUIRE: mountcritremote sysdb newsyslog
99c600e7dSMatthew Dillon# BEFORE:  SERVERS
109c600e7dSMatthew Dillon
119c600e7dSMatthew Dillon. /etc/rc.subr
129c600e7dSMatthew Dillon
139c600e7dSMatthew Dillonname="syslogd"
149c600e7dSMatthew Dillonrcvar=`set_rcvar`
159c600e7dSMatthew Dilloncommand="/usr/sbin/${name}"
169c600e7dSMatthew Dillonrequired_files="/etc/syslog.conf"
179c600e7dSMatthew Dillonstart_precmd="syslogd_precmd"
189c600e7dSMatthew Dillonextra_commands="reload"
19e54c8dc8SAaron LIpidfile="/var/run/syslog.pid"
209c600e7dSMatthew Dillon
219c600e7dSMatthew Dillon_sockfile="/var/run/syslogd.sockets"
229c600e7dSMatthew Dillonevalargs="rc_flags=\"\`set_socketlist\` \$rc_flags\""
239c600e7dSMatthew Dillon
249c600e7dSMatthew Dillonsyslogd_precmd()
259c600e7dSMatthew Dillon{
269c600e7dSMatthew Dillon	#	Transitional symlink for old binaries
279c600e7dSMatthew Dillon	#
289c600e7dSMatthew Dillon	if [ ! -L /dev/log ]; then
299c600e7dSMatthew Dillon		ln -sf /var/run/log /dev/log
309c600e7dSMatthew Dillon	fi
319c600e7dSMatthew Dillon	rm -f /var/run/log
329c600e7dSMatthew Dillon
339c600e7dSMatthew Dillon	#	Create default list of syslog sockets to watch
349c600e7dSMatthew Dillon	#
359c600e7dSMatthew Dillon	( umask 022 ; > $_sockfile )
369c600e7dSMatthew Dillon
3799b0192fSSascha Wildner	#	Find /etc/rc.d scripts with "chrootdir" rcorder(8) keyword,
3899b0192fSSascha Wildner	#	and if $${app}_chrootdir is a directory, add appropriate
399c600e7dSMatthew Dillon	#	syslog socket to list of sockets to watch.
409c600e7dSMatthew Dillon	#
4199b0192fSSascha Wildner	for _lr in $(rcorder -k chrootdir /etc/rc.d/*); do
4299b0192fSSascha Wildner	    (
4399b0192fSSascha Wildner		_l=${_lr##*/}
4499b0192fSSascha Wildner		load_rc_config ${_l}
459c600e7dSMatthew Dillon		eval _ldir=\$${_l}_chrootdir
4699b0192fSSascha Wildner		if checkyesno $_l && [ -n "$_ldir" ]; then
479c600e7dSMatthew Dillon			echo "${_ldir}/var/run/log" >> $_sockfile
489c600e7dSMatthew Dillon		fi
4999b0192fSSascha Wildner	    )
509c600e7dSMatthew Dillon	done
519c600e7dSMatthew Dillon
529c600e7dSMatthew Dillon	#	If other sockets have been provided, change run_rc_command()'s
539c600e7dSMatthew Dillon	#	internal copy of $syslogd_flags to force use of specific
549c600e7dSMatthew Dillon	#	syslogd sockets.
559c600e7dSMatthew Dillon	#
569c600e7dSMatthew Dillon	if [ -s $_sockfile ]; then
579c600e7dSMatthew Dillon		echo "/var/run/log" >> $_sockfile
589c600e7dSMatthew Dillon		eval $evalargs
599c600e7dSMatthew Dillon	fi
609c600e7dSMatthew Dillon
619c600e7dSMatthew Dillon	return 0
629c600e7dSMatthew Dillon}
639c600e7dSMatthew Dillon
649c600e7dSMatthew Dillonset_socketlist()
659c600e7dSMatthew Dillon{
669c600e7dSMatthew Dillon	_socketargs=
679c600e7dSMatthew Dillon	for _s in `cat $_sockfile | tr '\n' ' '` ; do
689c600e7dSMatthew Dillon		_socketargs="-l $_s $_socketargs"
699c600e7dSMatthew Dillon	done
709c600e7dSMatthew Dillon	echo $_socketargs
719c600e7dSMatthew Dillon}
72e54c8dc8SAaron LI
739c600e7dSMatthew Dillonload_rc_config $name
749c600e7dSMatthew Dillonrun_rc_command "$1"
75