2014-04-23 22:54:05 +00:00
|
|
|
#!/bin/bash
|
2013-09-01 14:13:51 +00:00
|
|
|
# This is the entry point for configuring the system.
|
|
|
|
#####################################################
|
|
|
|
|
2014-06-07 17:54:58 +00:00
|
|
|
source setup/functions.sh # load our functions
|
|
|
|
|
2014-08-25 12:09:37 +00:00
|
|
|
# Check system setup: Are we running as root on Ubuntu 14.04 on a
|
|
|
|
# machine with enough memory? If not, this shows an error and exits.
|
2014-10-04 18:05:00 +00:00
|
|
|
source setup/preflight.sh
|
2014-07-16 12:27:14 +00:00
|
|
|
|
2014-09-30 11:33:27 +00:00
|
|
|
# Ensure Python reads/writes files in UTF-8. If the machine
|
|
|
|
# triggers some other locale in Python, like ASCII encoding,
|
|
|
|
# Python may not be able to read/write files. Here and in
|
|
|
|
# the management daemon startup script.
|
|
|
|
|
|
|
|
if [ -z `locale -a | grep en_US.utf8` ]; then
|
2015-04-04 15:39:40 +00:00
|
|
|
# Generate locale if not exists
|
|
|
|
hide_output locale-gen en_US.UTF-8
|
2014-09-30 11:33:27 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
export LANGUAGE=en_US.UTF-8
|
|
|
|
export LC_ALL=en_US.UTF-8
|
|
|
|
export LANG=en_US.UTF-8
|
|
|
|
export LC_TYPE=en_US.UTF-8
|
|
|
|
|
2014-06-03 21:31:13 +00:00
|
|
|
# Recall the last settings used if we're running this a second time.
|
|
|
|
if [ -f /etc/mailinabox.conf ]; then
|
2014-06-30 20:41:29 +00:00
|
|
|
# Run any system migrations before proceeding. Since this is a second run,
|
|
|
|
# we assume we have Python already installed.
|
2014-07-10 12:49:19 +00:00
|
|
|
setup/migrate.py --migrate
|
2014-06-30 20:41:29 +00:00
|
|
|
|
2014-08-03 21:41:32 +00:00
|
|
|
# Load the old .conf file to get existing configuration options loaded
|
|
|
|
# into variables with a DEFAULT_ prefix.
|
2014-06-03 21:31:13 +00:00
|
|
|
cat /etc/mailinabox.conf | sed s/^/DEFAULT_/ > /tmp/mailinabox.prev.conf
|
|
|
|
source /tmp/mailinabox.prev.conf
|
2014-08-03 21:41:32 +00:00
|
|
|
rm -f /tmp/mailinabox.prev.conf
|
2014-06-03 21:31:13 +00:00
|
|
|
fi
|
2013-08-31 13:05:58 +00:00
|
|
|
|
2014-09-21 20:56:28 +00:00
|
|
|
# Put a start script in a global location. We tell the user to run 'mailinabox'
|
|
|
|
# in the first dialog prompt, so we should do this before that starts.
|
|
|
|
cat > /usr/local/bin/mailinabox << EOF;
|
|
|
|
#!/bin/bash
|
|
|
|
cd `pwd`
|
|
|
|
source setup/start.sh
|
|
|
|
EOF
|
|
|
|
chmod +x /usr/local/bin/mailinabox
|
|
|
|
|
2015-04-04 15:39:40 +00:00
|
|
|
# Start configuration
|
|
|
|
source setup/configure.sh
|
2014-06-03 21:17:10 +00:00
|
|
|
|
2015-04-04 15:39:40 +00:00
|
|
|
# Start service installation.
|
2014-10-04 18:05:00 +00:00
|
|
|
source setup/system.sh
|
|
|
|
source setup/ssl.sh
|
|
|
|
source setup/dns.sh
|
|
|
|
source setup/mail-postfix.sh
|
|
|
|
source setup/mail-dovecot.sh
|
|
|
|
source setup/mail-users.sh
|
|
|
|
source setup/dkim.sh
|
|
|
|
source setup/spamassassin.sh
|
|
|
|
source setup/web.sh
|
|
|
|
source setup/webmail.sh
|
|
|
|
source setup/owncloud.sh
|
|
|
|
source setup/zpush.sh
|
|
|
|
source setup/management.sh
|
2014-06-03 13:24:48 +00:00
|
|
|
|
2015-02-10 15:03:04 +00:00
|
|
|
# Ping the management daemon to write the DNS and nginx configuration files.
|
2015-04-04 15:44:14 +00:00
|
|
|
until nc -z -w 4 localhost 10222
|
|
|
|
do
|
2015-02-10 15:03:04 +00:00
|
|
|
echo Waiting for the Mail-in-a-Box management daemon to start...
|
|
|
|
sleep 2
|
|
|
|
done
|
|
|
|
tools/dns_update
|
|
|
|
tools/web_update
|
2013-09-01 14:39:36 +00:00
|
|
|
|
2014-06-04 23:39:58 +00:00
|
|
|
# If there aren't any mail users yet, create one.
|
2014-10-04 18:05:00 +00:00
|
|
|
source setup/firstuser.sh
|
2014-06-03 13:24:48 +00:00
|
|
|
|
2014-08-25 12:09:37 +00:00
|
|
|
# Done.
|
2014-08-17 22:43:57 +00:00
|
|
|
echo
|
|
|
|
echo "-----------------------------------------------"
|
|
|
|
echo
|
|
|
|
echo Your Mail-in-a-Box is running.
|
|
|
|
echo
|
|
|
|
echo Please log in to the control panel for further instructions at:
|
|
|
|
echo
|
2014-08-21 10:43:55 +00:00
|
|
|
if management/status_checks.py --check-primary-hostname; then
|
2014-08-17 22:43:57 +00:00
|
|
|
# Show the nice URL if it appears to be resolving and has a valid certificate.
|
|
|
|
echo https://$PRIMARY_HOSTNAME/admin
|
|
|
|
echo
|
2014-08-26 16:12:29 +00:00
|
|
|
echo If you have a DNS problem use the box\'s IP address and check the SSL fingerprint:
|
|
|
|
echo https://$PUBLIC_IP/admin
|
|
|
|
else
|
|
|
|
echo https://$PUBLIC_IP/admin
|
|
|
|
echo
|
|
|
|
echo You will be alerted that the website has an invalid certificate. Check that
|
|
|
|
echo the certificate fingerprint matches:
|
2014-08-17 22:43:57 +00:00
|
|
|
echo
|
|
|
|
fi
|
|
|
|
openssl x509 -in $STORAGE_ROOT/ssl/ssl_certificate.pem -noout -fingerprint \
|
2015-04-04 15:39:40 +00:00
|
|
|
| sed "s/SHA1 Fingerprint=//"
|
2014-08-17 22:43:57 +00:00
|
|
|
echo
|
|
|
|
echo Then you can confirm the security exception and continue.
|
2015-01-30 22:40:58 +00:00
|
|
|
echo
|