#!/bin/sh

exec 2>&1
# Configure ACLs
./control/1
. ./config
exec \
  softlimit -m "${ulimitdata:-20000000}" \
    /usr/bin/tcpsvd \
    -k \
    -v \
    -i ./peers \
    -c ${INSTANCES:-400} \
    -C ${INSTANCES_PER_IP:-6}:'421 per host concurrency limit reached\r\n' \
    -l ${LOCALNAME:-0} \
    ${LISTENIP:-0} \
    ${PORT:-imap} \
	makesock \
	  stunnel-tls \
	    -/ ssl \
	    -s "$SSLUID" \
	    -g "$SSLGID" \
	    -N imap \
	    -i \
	    -p imapd.pem \
	    -n imap- \
	    -f \
	    -F 3 \
	    -makesock_connect_to \
		/usr/bin/imapfront-auth \
		  /service/imap/imapd
