2013-09-01 14:13:51 +00:00
|
|
|
# This is the entry point for configuring the system.
|
|
|
|
#####################################################
|
|
|
|
|
2013-08-31 13:05:58 +00:00
|
|
|
# Check system setup.
|
2013-09-01 14:13:51 +00:00
|
|
|
|
2014-03-17 00:42:00 +00:00
|
|
|
if [ "`lsb_release -d | sed 's/.*:\s*//'`" != "Ubuntu 13.04" ]; then
|
|
|
|
echo "Mail-in-a-Box only supports being installed on Ubuntu 13.04, sorry. You are running:"
|
|
|
|
echo
|
|
|
|
lsb_release -d | sed 's/.*:\s*//'
|
|
|
|
echo
|
|
|
|
echo "We can't write scripts that run on every possible setup, sorry."
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2013-09-01 14:13:51 +00:00
|
|
|
# Check that SSH login with password is disabled. Stop if it's enabled.
|
2013-08-31 13:05:58 +00:00
|
|
|
if grep -q "^PasswordAuthentication yes" /etc/ssh/sshd_config \
|
|
|
|
|| ! grep -q "^PasswordAuthentication no" /etc/ssh/sshd_config ; then
|
|
|
|
echo
|
|
|
|
echo "The SSH server on this machine permits password-based login."
|
|
|
|
echo "Add your SSH public key to $HOME/.ssh/authorized_keys, check"
|
|
|
|
echo "check that you can log in without a password, set the option"
|
|
|
|
echo "'PasswordAuthentication no' in /etc/ssh/sshd_config, and then"
|
|
|
|
echo "restart the machine."
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2013-09-01 14:13:51 +00:00
|
|
|
# Gather information from the user about the hostname and public IP
|
|
|
|
# address of this host.
|
2013-08-26 21:01:48 +00:00
|
|
|
if [ -z "$PUBLIC_HOSTNAME" ]; then
|
|
|
|
echo
|
|
|
|
echo "Enter the hostname you want to assign to this machine."
|
|
|
|
echo "We've guessed a value. Just backspace it if it's wrong."
|
|
|
|
echo "Josh uses box.occams.info as his hostname. Yours should"
|
|
|
|
echo "be similar."
|
2013-08-31 14:46:10 +00:00
|
|
|
echo
|
2013-08-26 21:01:48 +00:00
|
|
|
read -e -i "`hostname`" -p "Hostname: " PUBLIC_HOSTNAME
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "$PUBLIC_IP" ]; then
|
|
|
|
echo
|
|
|
|
echo "Enter the public IP address of this machine, as given to"
|
|
|
|
echo "you by your ISP. We've guessed a value, but just backspace"
|
|
|
|
echo "it if it's wrong."
|
2013-08-31 14:46:10 +00:00
|
|
|
echo
|
2013-08-26 21:01:48 +00:00
|
|
|
read -e -i "`hostname -i`" -p "Public IP: " PUBLIC_IP
|
|
|
|
fi
|
|
|
|
|
2013-09-01 14:13:51 +00:00
|
|
|
# Create the user named "userconfig-data" and store all persistent user
|
|
|
|
# data (mailboxes, etc.) in that user's home directory.
|
2013-08-26 21:01:48 +00:00
|
|
|
if [ -z "$STORAGE_ROOT" ]; then
|
2013-09-01 14:13:51 +00:00
|
|
|
STORAGE_USER=user-data
|
|
|
|
if [ ! -d /home/$STORAGE_USER ]; then useradd -m $STORAGE_USER; fi
|
|
|
|
STORAGE_ROOT=/home/$STORAGE_USER
|
2013-08-31 13:05:58 +00:00
|
|
|
mkdir -p $STORAGE_ROOT
|
2013-08-26 21:01:48 +00:00
|
|
|
fi
|
|
|
|
|
2013-09-01 14:13:51 +00:00
|
|
|
# Save the global options in /etc/mailinabox.conf so that standalone
|
|
|
|
# tools know where to look for data.
|
2013-08-31 14:46:10 +00:00
|
|
|
cat > /etc/mailinabox.conf << EOF;
|
|
|
|
STORAGE_ROOT=$STORAGE_ROOT
|
2013-08-31 18:52:13 +00:00
|
|
|
PUBLIC_HOSTNAME=$PUBLIC_HOSTNAME
|
2013-09-08 11:47:27 +00:00
|
|
|
PUBLIC_IP=$PUBLIC_IP
|
2013-08-31 14:46:10 +00:00
|
|
|
EOF
|
|
|
|
|
2013-09-01 14:13:51 +00:00
|
|
|
# Start service configuration.
|
2013-08-26 21:01:48 +00:00
|
|
|
. scripts/system.sh
|
|
|
|
. scripts/dns.sh
|
|
|
|
. scripts/mail.sh
|
|
|
|
. scripts/dkim.sh
|
|
|
|
. scripts/spamassassin.sh
|
|
|
|
. scripts/dns_update.sh
|
2013-09-07 20:53:25 +00:00
|
|
|
. scripts/web.sh
|
|
|
|
. scripts/webmail.sh
|
2013-09-01 14:39:36 +00:00
|
|
|
|
2014-01-27 15:41:59 +00:00
|
|
|
if [ -z "`tools/mail.py user`" ]; then
|
2013-09-01 14:39:36 +00:00
|
|
|
# The outut of "tools/mail.py user" is a list of mail users. If there
|
|
|
|
# are none configured, ask the user to configure one.
|
|
|
|
echo
|
|
|
|
echo "Let's create your first mail user."
|
|
|
|
read -e -i "user@`hostname`" -p "Email Address: " EMAIL_ADDR
|
|
|
|
tools/mail.py user add $EMAIL_ADDR # will ask for password
|
2013-09-08 10:16:09 +00:00
|
|
|
tools/mail.py alias add hostmaster@$PUBLIC_HOSTNAME $EMAIL_ADDR
|
2013-09-01 14:39:36 +00:00
|
|
|
fi
|
2013-08-31 14:46:25 +00:00
|
|
|
|