2016-02-21 17:24:11 +02:00
|
|
|
#!/bin/bash
|
2016-02-20 22:55:22 +02:00
|
|
|
|
2016-02-21 17:24:11 +02:00
|
|
|
cat << EOF
|
|
|
|
__ _ _
|
|
|
|
/ _| | | (_)
|
2016-02-21 16:50:17 +02:00
|
|
|
| |_ _ __ ___ ___ _ __ ___ ___| |_ ___ _ ___
|
2016-02-21 17:24:11 +02:00
|
|
|
| _| '__/ _ \\/ _ \\ '_ \\ / _ \\/ __| __/ _ \\ | |/ _ \\
|
|
|
|
| | | | | __/ __/ |_) | (_) \\__ \\ || __/_| | (_)|
|
|
|
|
|_| |_| \\___|\\___| .__/ \\___/|___/\\__\\___(_)_|\\___/
|
2016-02-21 16:50:17 +02:00
|
|
|
| |
|
|
|
|
|_|
|
|
|
|
|
|
|
|
For documentation, please visit https://freeposte.io
|
|
|
|
|
|
|
|
EOF
|
|
|
|
|
2016-02-20 22:55:22 +02:00
|
|
|
# When postfix is installed non-interactively, the file does not get copied to
|
|
|
|
# the postfix chroot, thus causing smtpd to fail, fix this at runtime
|
|
|
|
cp /etc/services /var/spool/postfix/etc/
|
|
|
|
|
2016-02-21 16:50:17 +02:00
|
|
|
# Create necessary directories
|
2016-02-20 22:55:22 +02:00
|
|
|
mkdir -p \
|
|
|
|
/data/mail \
|
|
|
|
/data/webmail/tmp \
|
|
|
|
/data/logs \
|
2016-02-21 17:24:11 +02:00
|
|
|
/data/logs/webmail \
|
2016-02-20 22:55:22 +02:00
|
|
|
/data/ssl
|
|
|
|
|
2016-02-21 16:50:17 +02:00
|
|
|
# Create the main database if necessary
|
2016-02-21 17:47:30 +02:00
|
|
|
if [ ! -f /data/freeposte.db ]; then
|
|
|
|
echo 'Initializing the database...'
|
|
|
|
cd /admin && python initdb.py
|
|
|
|
fi
|
2016-02-21 16:50:17 +02:00
|
|
|
|
|
|
|
# Fixing permissions
|
2016-02-21 17:47:30 +02:00
|
|
|
chown www-data:mail /data/freeposte.db
|
|
|
|
chmod 664 /data/freeposte.db
|
2016-02-20 22:55:22 +02:00
|
|
|
chown -R mail:mail /data/mail
|
|
|
|
chown -R www-data:www-data /data/webmail /data/logs/webmail
|
|
|
|
|
|
|
|
# Copy the system snakeoil certificate if none is provided
|
|
|
|
if [ ! -f /data/ssl/cert.pem ]; then
|
2016-02-21 17:47:30 +02:00
|
|
|
cat << EOF
|
2016-02-21 16:50:17 +02:00
|
|
|
No TLS certificate is installed, a snakeoil ceritifcate is thus
|
|
|
|
being configured. You MUST NOT run a production server with this
|
|
|
|
certificate, as the private key is known publicly.
|
|
|
|
|
|
|
|
You have been warned.
|
2016-02-21 17:47:30 +02:00
|
|
|
EOF
|
2016-02-20 22:55:22 +02:00
|
|
|
cp /etc/ssl/private/ssl-cert-snakeoil.key /data/ssl/key.pem
|
|
|
|
cp /etc/ssl/certs/ssl-cert-snakeoil.pem /data/ssl/cert.pem
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Finally run the server
|
2016-02-21 20:48:26 +02:00
|
|
|
echo "Supervisor will now take over..."
|
|
|
|
exec /usr/bin/supervisord -c /etc/supervisor/supervisord.conf
|