REL-0.1 Initial Release

This commit is contained in:
cytopia
2018-02-23 08:53:30 +01:00
parent c594390bb3
commit f9782dbab6
47 changed files with 5952 additions and 31 deletions

View File

@@ -0,0 +1,95 @@
#!/usr/bin/env bash
#
# Wrapper to have postfix run in foreground
# mode in order to be called by supvervisord
#
#
# CREDITS:
# This script is mostly based on the following Gist:
# https://gist.github.com/chrisnew/b0c1b8d310fc5ceaeac4
#
###
### Be strict
###
set -e
set -u
set -o pipefail
###
### Variables
###
if [ -f "/etc/alpine-release" ]; then
MAILLOG="/var/log/maillog"
elif [ -f "/etc/debian_version" ]; then
MAILLOG="/var/log/mail.log"
else
MAILLOG="/var/log/maillog"
fi
MAILPID="/var/spool/postfix/pid/master.pid"
###
### Sanity checks
###
if ! command -v pidof >/dev/null 2>&1; then
echo "pidof is required for cleaning up tail command."
exit 1
fi
# Give rsyslogd some time to start up
sleep 2
if ! pidof rsyslogd >/dev/null 2>&1; then
echo "rsyslogd is not running, but required for mail logging."
exit 1
fi
# force new copy of hosts there (otherwise links could be outdated)
# TODO: check if required
#cp /etc/hosts /var/spool/postfix/etc/hosts
###
### Trap signals
###
trap "postfix stop" SIGINT
trap "postfix stop" SIGTERM
trap "postfix reload" SIGHUP
###
### Startup
###
# start postfix
postfix start
# Capture output
tail -qF -n 0 "${MAILLOG}" &
tail_pid="${?}"
###
### Warm-up time
###
sleep 3
###
### Wait for kill signales
###
while kill -0 "$(cat "${MAILPID}")" >/dev/null 2>&1; do
# Check every second
sleep 1
done
###
### Clean-up
###
kill "${tail_pid}"