#!/usr/bin/execlineb -P
# postfix in foreground (start-fg), matching debian/sv/postfix.
# Pause if unconfigured; fail longrun if postfix check fails.

envfile -I /etc/s6-rc/config/postfix.conf
importas -sCuD "start-fg" Args Args

ifelse { test -f /etc/postfix/main.cf } {
	foreground { /usr/sbin/postfix check }
	# Log to the s6 pipeline (runit does the same via postconf).
	foreground { postconf maillog_file=/dev/stdout }
	foreground { postconf postlog_service_name=postlog }
	fdmove -c 2 1
	exec /usr/sbin/postfix ${Args}
}
s6-pause
