#!/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
#
echo 'source chroots {' > "${cfg_file}"
for variable in ${!SYSLOGD_ADDITIONAL_SOCKET*}; do
	eval value=\$$variable
	test -z "$value" && continue
	test -d "${value%/*}" || continue
	echo "unix-dgram(\"$value\");"
done >> "${cfg_file}"
echo '};' >> "${cfg_file}"

exit 0

