1#!/bin/sh 2# 3# $FreeBSD$ 4# 5 6# netif is required for lo0 because syslogd tries to open a local socket 7# 8# PROVIDE: syslogd 9# REQUIRE: mountcritremote FILESYSTEMS newsyslog netif 10# BEFORE: SERVERS 11 12. /etc/rc.subr 13 14name="syslogd" 15desc="System log daemon" 16rcvar="syslogd_enable" 17pidfile="/var/run/syslog.pid" 18command="/usr/sbin/${name}" 19required_files="/etc/syslog.conf" 20start_precmd="syslogd_precmd" 21extra_commands="reload" 22 23sockfile="/var/run/syslogd.sockets" 24evalargs="rc_flags=\"\`set_socketlist\` \$rc_flags\"" 25 26syslogd_precmd() 27{ 28 local _l _ldir 29 30 # Transitional symlink for old binaries 31 # 32 if [ ! -L /dev/log ] && ! check_jail jailed; 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 ${_l}_enable && [ -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 local _s _socketargs 66 67 _socketargs= 68 for _s in `cat $sockfile | tr '\n' ' '` ; do 69 _socketargs="-l $_s $_socketargs" 70 done 71 echo $_socketargs 72} 73load_rc_config $name 74run_rc_command "$1" 75