mastodon-docker/rootfs/etc/service/postfix/run

70 lines
1.2 KiB
Plaintext
Raw Normal View History

#!/bin/bash
2019-12-09 09:15:23 +00:00
POSTFIX='/usr/sbin/postfix'
MONITOR_INTERVAL=10 # seconds
2019-12-09 09:15:23 +00:00
exec 2>&1
2019-12-09 09:15:23 +00:00
if [[ ! -d /state/envdir ]]; then
mkdir -p /state/envdir
chown mastodon:mastodon /state/envdir
fi
2019-12-09 13:11:52 +00:00
if [[ -z "$WEB_DOMAIN" ]]; then
WEB_DOMAIN="$(hostname --fqdn)"
2019-12-09 09:15:23 +00:00
fi
2019-12-09 13:11:52 +00:00
if [[ -e /state/envdir/WEB_DOMAIN ]]; then
WEB_DOMAIN="$(cat /state/envdir/WEB_DOMAIN)"
fi
cat /etc/postfix/main.cf | grep -v '^myhostname' | grep -v '^myorigin' > /etc/postfix/main.new
2019-12-09 09:15:23 +00:00
rm /etc/postfix/main.cf
2019-12-09 13:11:52 +00:00
echo "myhostname = $WEB_DOMAIN" >> /etc/postfix/main.cf
echo "myorigin = $WEB_DOMAIN" >> /etc/postfix/main.cf
2019-12-09 09:15:23 +00:00
cat /etc/postfix/main.new >> /etc/postfix/main.cf
rm /etc/postfix/main.new
running() {
pkill -0 master
}
start() {
echo "postfix starting..."
/etc/init.d/postfix start
}
stop() {
if running; then
echo Stopping
/etc/init.d/postfix stop
fi
}
reload() {
echo Reloading
/etc/init.d/postfix reload
}
check() {
echo Checking
"$POSTFIX" check
}
status() {
"$POSTFIX" status
}
trap 'echo INT; stop; exit' INT
trap 'echo QUIT; stop; exit' QUIT
trap 'echo TERM; stop; exit' TERM
trap 'echo STOP; stop' STOP
trap 'echo HUP; reload' HUP
trap 'echo USR1; check' USR1
trap 'echo USR2; status' USR2
while :; do
running || start
sleep $MONITOR_INTERVAL
done