#!/bin/sh set -e NAME="SMTP" function stop { echo "Stopping ${NAME}" kill $(cat /run/saslauthd/saslauthd.pid) kill $(cat /run/sendmail/mta/sendmail.pid|head -1) } trap 'stop' SIGTERM if [ -z "$@" ]; then if [ -z `hostname -d` ]; then echo "You must start this container with --hostname= specifying a domain name" exit 1 fi touch /etc/postfix/custom/relay_host touch /etc/postfix/custom/sasl_passwd postmap -o lmdb:/etc/postfix/custom/sasl_passwd touch /etc/postfix/custom/transport postmap -o lmdb:/etc/postfix/custom/transport /usr/sbin/saslauthd -m /run/saslauthd -ca shadow newaliases postfix start /usr/sbin/opendkim -P /run/opendkim.pid -u opendkim -f wait else exec $@ fi