mirror of
https://github.com/mail-in-a-box/mailinabox.git
synced 2026-03-17 17:57:23 +01:00
Fully working docker!
This commit is contained in:
committed by
Joshua Tauberer
parent
dd5de8acf3
commit
a5ffd6d25e
@@ -72,6 +72,7 @@ python3-pip
|
||||
pyzor
|
||||
razor
|
||||
resolvconf
|
||||
rsyslog
|
||||
spampd
|
||||
sqlite3
|
||||
sudo
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
#!/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
|
||||
|
||||
# Start configuration.
|
||||
cd /usr/local/mailinabox
|
||||
export IS_DOCKER=1
|
||||
export DISABLE_FIREWALL=1
|
||||
source setup/start.sh # using 'source' means an exit from inside also exits this script and terminates container
|
||||
|
||||
# Once the configuration is complete, start the Unix init process
|
||||
# provided by the base image. We're running as process 0, and
|
||||
# /sbin/my_init needs to run as process 0, so use 'exec' to replace
|
||||
# this shell process and not fork a new one. Nifty right?
|
||||
exec /sbin/my_init -- bash
|
||||
67
containers/docker/init.sh
Executable file
67
containers/docker/init.sh
Executable file
@@ -0,0 +1,67 @@
|
||||
#!/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
|
||||
|
||||
# Start configuration.
|
||||
cd /usr/local/mailinabox
|
||||
export IS_DOCKER=1
|
||||
export STORAGE_ROOT=/data
|
||||
export STORAGE_USER=user-data
|
||||
export DISABLE_FIREWALL=1
|
||||
|
||||
mkdir /etc/service/rsyslogd
|
||||
mkdir /etc/service/bind9
|
||||
mkdir /etc/service/dovecot
|
||||
mkdir /etc/service/fail2ban
|
||||
mkdir /etc/service/mailinabox
|
||||
mkdir /etc/service/memcached
|
||||
mkdir /etc/service/nginx
|
||||
mkdir /etc/service/nsd
|
||||
mkdir /etc/service/opendkim
|
||||
mkdir /etc/service/php5-fpm
|
||||
mkdir /etc/service/postfix
|
||||
mkdir /etc/service/postgrey
|
||||
mkdir /etc/service/spampd
|
||||
cp services/rsyslogd.sh /etc/service/rsyslogd/run
|
||||
cp services/bind9.sh /etc/service/bind9/run
|
||||
cp services/dovecot.sh /etc/service/dovecot/run
|
||||
cp services/fail2ban.sh /etc/service/fail2ban/run
|
||||
cp services/mailinabox.sh /etc/service/mailinabox/run
|
||||
cp services/memcached.sh /etc/service/memcached/run
|
||||
cp services/nginx.sh /etc/service/nginx/run
|
||||
cp services/nsd.sh /etc/service/nsd/run
|
||||
cp services/opendkim.sh /etc/service/opendkim/run
|
||||
cp services/php5-fpm.sh /etc/service/php5-fpm/run
|
||||
cp services/postfix.sh /etc/service/postfix/run
|
||||
cp services/postgrey.sh /etc/service/postgrey/run
|
||||
cp services/spampd.sh /etc/service/spampd/run
|
||||
|
||||
rsyslogd
|
||||
source setup/start.sh
|
||||
/etc/init.d/mailinabox start
|
||||
/usr/sbin/dovecot -c /etc/dovecot/dovecot.conf
|
||||
sleep 5
|
||||
curl -s -d POSTDATA --user $(</var/lib/mailinabox/api.key): http://127.0.0.1:10222/dns/update
|
||||
curl -s -d POSTDATA --user $(</var/lib/mailinabox/api.key): http://127.0.0.1:10222/web/update
|
||||
source setup/firstuser.sh
|
||||
/etc/init.d/mailinabox stop
|
||||
kill $(pidof dovecot)
|
||||
/etc/init.d/resolvconf start
|
||||
killall rsyslogd
|
||||
my_init
|
||||
|
||||
@@ -17,21 +17,18 @@
|
||||
# volume if the volume is new.
|
||||
|
||||
|
||||
DOCKER=docker.io
|
||||
DOCKER=docker
|
||||
|
||||
# Build or rebuild the image.
|
||||
# Rebuilds are very fast.
|
||||
$DOCKER build -q -t mailinabox .
|
||||
|
||||
# Start the user-data containerw which is merely to create
|
||||
# a container that maintains a reference to a volume so that
|
||||
# we can destroy the main container without losing user data.
|
||||
if ! $DOCKER ps -a | grep mailinabox-userdata > /dev/null; then
|
||||
echo Starting user-data volume container...
|
||||
$DOCKER run -d \
|
||||
--name mailinabox-userdata \
|
||||
-v /home/user-data \
|
||||
scratch bash
|
||||
scratch /bin/bash
|
||||
fi
|
||||
|
||||
# End a running container.
|
||||
@@ -43,8 +40,9 @@ fi
|
||||
# Start container.
|
||||
echo Starting new container...
|
||||
$DOCKER run \
|
||||
-p 25 -p 53 -p 80 -p 443 -p 587 -p 993 \
|
||||
--volumes-from mailinabox-userdata \
|
||||
--privileged \
|
||||
-v /dev/urandom:/dev/random \
|
||||
-p 25 -p 53/udp -p 53/tcp -p 80 -p 443 -p 587 -p 993 \
|
||||
--name mailinabox-services \
|
||||
-t -i \
|
||||
mailinabox
|
||||
--volumes-from mailinabox-userdata \
|
||||
mailinabox
|
||||
Reference in New Issue
Block a user