mailinabox/containers/docker/init.sh

43 lines
1.4 KiB
Bash
Raw Normal View History

2015-01-24 10:29:16 +00:00
#!/bin/bash
# This script is used within containers to turn it into a Mail-in-a-Box.
# It is referenced by the Dockerfile. You should not run it directly.
########################################################################
# Local configuration details were not known at the time the Docker
# image was created, so all setup is defered until the container
# is started. That's when this script runs.
# If we're not in an interactive shell, set defaults.
if [ ! -t 0 ]; then
export PUBLIC_IP=auto
export PUBLIC_IPV6=auto
export PRIMARY_HOSTNAME=auto
export CSR_COUNTRY=US
export NONINTERACTIVE=1
fi
2015-02-22 10:36:10 +00:00
for service in rsyslog dovecot memcached postgrey postfix nginx bind9 fail2ban spampd nsd opendkim opendmarc php5-fpm
do
# create runit service from source file
2015-01-30 22:40:58 +00:00
mkdir -p /etc/service/$service
cp /usr/local/mailinabox/containers/docker/runit/$service.sh /etc/service/$service/run
chmod +x /etc/service/$service/run
2015-02-22 10:36:10 +00:00
# runit -> LSB compatibility
# see http://smarden.org/runit/faq.html#lsb
if [ -f /etc/init.d/$service ]; then
mv /etc/init.d/$service /etc/init.d/$service.lsb
chmod -x /etc/init.d/$service.lsb
fi
ln -s /usr/bin/sv /etc/init.d/$service
done
2015-01-30 22:40:58 +00:00
# Start configuration. Using 'source' means an exit from inside
# also exits this script and terminates the container.
2015-01-24 10:29:16 +00:00
cd /usr/local/mailinabox
export IS_DOCKER=1
export DISABLE_FIREWALL=1
source setup/start.sh