[Main]
Type = classic
Version = 0.1.0
Description = "postfix daemon"
User = ( root )
Depends = ( mount-rw )
Options = ( log )

[Start]
Execute = (
	# postfix in foreground (start-fg), matching debian/sv/postfix.
	# Pause if unconfigured; fail longrun if postfix check fails.
	
	
	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 }
		exec /usr/sbin/postfix ${Args}
	}
	s6-pause
)

[Logger]
RunAs = s6log
Backup = 3
MaxSize = 2000000
Timestamp = tai
Destination = /var/log/postfix-s6

[Environment]
Args = !start-fg
