summaryrefslogtreecommitdiff
path: root/sysutils/rsyslog55/files/rsyslogd.in
blob: 6ce16c56f70b0d31de50ddebd57cd754013bc462 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/bin/sh
#
# $FreeBSD: /tmp/pcvs/ports/sysutils/rsyslog55/files/Attic/rsyslogd.in,v 1.2 2009-12-18 20:44:28 miwi Exp $
#


# PROVIDE: rsyslogd
# REQUIRE: mountcritremote cleanvar newsyslog ldconfig
# BEFORE:  SERVERS

. %%RC_SUBR%%

name=rsyslogd
rcvar=`set_rcvar`
command="%%PREFIX%%/sbin/${name}"
load_rc_config $name
: ${rsyslogd_enable:="NO"}
: ${rsyslogd_pidfile:="/var/run/rsyslogd.pid"}
: ${rsyslogd_config:="%%PREFIX%%/etc/rsyslog.conf"}
pidfile="${rsyslogd_pidfile}"
command_args="-i ${pidfile} -f ${rsyslogd_config}"
required_files="${rsyslogd_config}"
start_precmd="rsyslogd_precmd"
extra_commands="reload"

sockfile="/var/run/rsyslogd.sockets"
evalargs="rc_flags=\"\`set_socketlist\` \$rc_flags\""
altlog_proglist="named"

rsyslogd_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 `set_rcvar $_l` && [ -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 $rsyslogd_flags to force use of specific
	#	rsyslogd 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="-a $_s $_socketargs"
	done
	echo $_socketargs
}

run_rc_command "$1"