#!/usr/bin/execlineb -P
# syslog-ng in foreground (-F), matching debian/sv/syslog-ng.

envfile -I /etc/default/syslog-ng
importas -uD "" CONSOLE_LOG_LEVEL CONSOLE_LOG_LEVEL
importas -sCuD "" SYSLOGNG_OPTS SYSLOGNG_OPTS
envfile -I /etc/s6-rc/config/syslog-ng.conf
importas -sCuD "-F -p /run/syslog-ng.pid" Args Args

foreground {
	ifelse { test -n "${CONSOLE_LOG_LEVEL}" } {
		dmesg -n ${CONSOLE_LOG_LEVEL}
	}
	exit 0
}
foreground { mkdir -p /run/syslog-ng }
foreground {
	ifelse { test ! -e /dev/xconsole } {
		foreground { mknod -m 640 /dev/xconsole p }
		foreground { chown root:adm /dev/xconsole }
	}
	exit 0
}

fdmove -c 2 1
exec /usr/sbin/syslog-ng ${Args} ${SYSLOGNG_OPTS}
