#!/bin/bash # This is the entry point for configuring the system. ##################################################### source setup/functions.sh # load our functions # Check system setup: Are we running as root on Ubuntu 18.04 on a # machine with enough memory? Is /tmp mounted with exec. # If not, this shows an error and exits. source setup/preflight.sh # 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. This is also # in the management daemon startup script and the cron script. if ! locale -a | grep en_US.utf8 >/dev/null; then # Generate locale if not exists hide_output locale-gen en_US.UTF-8 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 # Fix so line drawing characters are shown correctly in Putty on Windows. See #744. export NCURSES_NO_UTF8_ACS=1 # Recall the last settings used if we're running this a second time. if [ -f /etc/mailinabox.conf ]; then # Run any system migrations before proceeding. Since this is a second run, # we assume we have Python already installed. setup/migrate.py --migrate || exit 1 # Load the old .conf file to get existing configuration options loaded # into variables with a DEFAULT_ prefix. cat /etc/mailinabox.conf | sed s/^/DEFAULT_/ >/tmp/mailinabox.prev.conf source /tmp/mailinabox.prev.conf rm -f /tmp/mailinabox.prev.conf # Since this is a second run, attempt to read overridden settings from $STORAGE_ROOT/mailinabox.conf if [ -f $DEFAULT_STORAGE_ROOT/mailinabox.conf ]; then cat $DEFAULT_STORAGE_ROOT/mailinabox.conf | sed s/^/DEFAULT_/ >/tmp/mailinabox.prev.conf source /tmp/mailinabox.prev.conf rm -f /tmp/mailinabox.prev.conf fi else FIRST_TIME_SETUP=1 fi # 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 </dev/null 2>&1; then useradd -m "$STORAGE_USER" fi if [ ! -d "$STORAGE_ROOT" ]; then mkdir -p "$STORAGE_ROOT" fi f=$STORAGE_ROOT while [[ $f != / ]]; do chmod a+rx "$f" f=$(dirname "$f") done if [ ! -f "$STORAGE_ROOT/mailinabox.version" ]; then setup/migrate.py --current >"$STORAGE_ROOT/mailinabox.version" chown "$STORAGE_USER:$STORAGE_USER" "$STORAGE_ROOT/mailinabox.version" fi # Save the global options in /etc/mailinabox.conf so that standalone # tools know where to look for data. The default MTA_STS_MODE setting # is blank unless set by an environment variable, but see web.sh for # how that is interpreted. cat >/etc/mailinabox.conf <