#!/bin/bash

test -s "/etc/sysconfig/syslog" && \
      . "/etc/sysconfig/syslog"

run_dir="RUN_DIR"
cfg_file="ADDITIONAL_SOCKETS"

umask 0022
/bin/mkdir -p -m 0755 "${run_dir}"

#
# Prepare include with sockets in chroot's
#
> "${cfg_file}"
for variable in ${!SYSLOGD_ADDITIONAL_SOCKET*}; do
	eval value=\$$variable
	test -z "$value" && continue
	test -d "${value%/*}" || continue
	echo "\$AddUnixListenSocket $value"
done >> "${cfg_file}"

#
# make sure xconsole exists and is a pipe
#
if test -e /dev/xconsole -a ! -p /dev/xconsole ; then
	/bin/rm -f /dev/xconsole
fi
if test ! -e /dev/xconsole ; then
	/bin/mknod -m 0600  /dev/xconsole p
	/bin/chown root:tty /dev/xconsole
	restorecon /dev/xconsole 2> /dev/null
fi

exit 0

