| 1 | #!/bin/sh
|
---|
| 2 | #
|
---|
| 3 | # $FreeBSD: src/etc/rc.d/syslogd,v 1.13.2.1.6.1 2010/12/21 17:09:25 kensmith Exp $
|
---|
| 4 | #
|
---|
| 5 |
|
---|
| 6 | # PROVIDE: syslogd
|
---|
| 7 | # REQUIRE: mountcritremote cleanvar newsyslog
|
---|
| 8 | # BEFORE: SERVERS
|
---|
| 9 |
|
---|
| 10 | . /etc/rc.subr
|
---|
| 11 | name="syslogd"
|
---|
| 12 | rcvar=`set_rcvar`
|
---|
| 13 | pidfile="/var/run/syslog.pid"
|
---|
| 14 | command="/usr/sbin/${name}"
|
---|
| 15 | required_files="/etc/syslog.conf"
|
---|
| 16 | start_precmd="syslogd_precmd"
|
---|
| 17 | extra_commands="reload"
|
---|
| 18 | sockfile="/var/run/syslogd.sockets"
|
---|
| 19 |
|
---|
| 20 | inf=$(dig +short `hostname`)
|
---|
| 21 | command_args="-b $inf"
|
---|
| 22 |
|
---|
| 23 | evalargs="rc_flags=\"\`set_socketlist\` \$rc_flags\""
|
---|
| 24 | altlog_proglist="named"
|
---|
| 25 |
|
---|
| 26 | syslogd_precmd()
|
---|
| 27 | {
|
---|
| 28 | local _l _ldir
|
---|
| 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 |
|
---|
| 63 | set_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 | }
|
---|
| 73 | load_rc_config $name
|
---|
| 74 | run_rc_command "$1"
|
---|