2014-08-25 12:09:37 +00:00
|
|
|
# Are we running as root?
|
|
|
|
if [[ $EUID -ne 0 ]]; then
|
|
|
|
echo "This script must be run as root. Please re-run like this:"
|
|
|
|
echo
|
2014-09-21 20:56:28 +00:00
|
|
|
echo "sudo $0"
|
2014-08-25 12:09:37 +00:00
|
|
|
echo
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2018-10-25 03:31:20 +00:00
|
|
|
# Check if on Linux
|
|
|
|
if ! echo "$OSTYPE" | grep -iq "linux"; then
|
|
|
|
echo "Error: This script must be run on Linux." >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
. /etc/os-release
|
|
|
|
|
|
|
|
# Check that we are running on Ubuntu 14.04 LTS (or 14.04.xx).
|
|
|
|
if ! echo "$ID" | grep -iq "ubuntu" || ! echo "$VERSION_ID" | grep -iq "18.04"; then
|
|
|
|
echo "Mail-in-a-Box only supports being installed on Ubuntu 18.04, sorry. You are running:" >&2
|
|
|
|
echo >&2
|
|
|
|
echo "${PRETTY_NAME:-$ID-$VERSION_ID}" >&2
|
|
|
|
echo >&2
|
|
|
|
echo "We can't write scripts that run on every possible setup, sorry." >&2
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Check for the Windows Subsystem for Linux (WSL)
|
2019-07-27 08:03:15 +00:00
|
|
|
KERNEL=$(uname -r)
|
|
|
|
if echo "$KERNEL" | grep -iq "microsoft"; then
|
2018-10-25 03:31:20 +00:00
|
|
|
echo "Warning: The Windows Subsystem for Linux (WSL) is not yet fully supported by this script."
|
2014-08-25 12:09:37 +00:00
|
|
|
fi
|
|
|
|
|
2015-01-11 14:09:21 +00:00
|
|
|
# Check that we have enough memory.
|
|
|
|
#
|
2016-10-15 19:41:25 +00:00
|
|
|
# /proc/meminfo reports free memory in kibibytes. Our baseline will be 512 MB,
|
|
|
|
# which is 500000 kibibytes.
|
|
|
|
#
|
|
|
|
# We will display a warning if the memory is below 768 MB which is 750000 kibibytes
|
2015-01-11 14:09:21 +00:00
|
|
|
#
|
|
|
|
# Skip the check if we appear to be running inside of Vagrant, because that's really just for testing.
|
2018-10-25 03:31:20 +00:00
|
|
|
TOTAL_PHYSICAL_MEM=$(awk '/^MemTotal:/ {print $2}' /proc/meminfo)
|
|
|
|
TOTAL_SWAP=$(awk '/^SwapTotal:/ {print $2}' /proc/meminfo)
|
|
|
|
if [ "$TOTAL_PHYSICAL_MEM" -lt 490000 ]; then
|
|
|
|
if [ ! -d /vagrant ]; then
|
|
|
|
echo "Your Mail-in-a-Box needs more memory (RAM) to function properly." >&2
|
|
|
|
echo "Please provision a machine with at least 512 MB, 1 GB (1024 MB) recommended." >&2
|
|
|
|
echo "This machine has $(printf "%'d" $((((TOTAL_PHYSICAL_MEM * 1024) / 1000) / 1000))) MB ($(printf "%'d" $((TOTAL_PHYSICAL_MEM / 1024))) MiB) memory."
|
|
|
|
exit 1
|
|
|
|
fi
|
2014-08-25 12:09:37 +00:00
|
|
|
fi
|
|
|
|
fi
|
2018-10-25 03:31:20 +00:00
|
|
|
if [ "$TOTAL_PHYSICAL_MEM" -lt 750000 ]; then
|
2016-10-15 19:41:25 +00:00
|
|
|
echo "WARNING: Your Mail-in-a-Box has less than 768 MB of memory."
|
|
|
|
echo " It might run unreliably when under heavy load."
|
|
|
|
fi
|
2016-02-21 17:43:04 +00:00
|
|
|
|
2018-10-25 03:31:20 +00:00
|
|
|
# Check connectivity
|
|
|
|
if ! ping -q -c 3 mailinabox.email > /dev/null 2>&1; then
|
|
|
|
echo "Error: Could not reach mailinabox.email, please check your internet connection and run this script again." >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2016-02-21 17:47:09 +00:00
|
|
|
# Check that tempfs is mounted with exec
|
2018-11-30 15:24:19 +00:00
|
|
|
MOUNTED_TMP_AS_NO_EXEC=$(grep "/tmp.*noexec" /proc/mounts || /bin/true)
|
2016-02-21 17:43:04 +00:00
|
|
|
if [ -n "$MOUNTED_TMP_AS_NO_EXEC" ]; then
|
|
|
|
echo "Mail-in-a-Box has to have exec rights on /tmp, please mount /tmp with exec"
|
|
|
|
exit
|
|
|
|
fi
|
2016-03-11 14:10:31 +00:00
|
|
|
|
|
|
|
# Check that no .wgetrc exists
|
|
|
|
if [ -e ~/.wgetrc ]; then
|
2016-03-11 14:14:37 +00:00
|
|
|
echo "Mail-in-a-Box expects no overrides to wget defaults, ~/.wgetrc exists"
|
2016-03-11 14:10:31 +00:00
|
|
|
exit
|
|
|
|
fi
|
2016-03-14 06:00:33 +00:00
|
|
|
|
2018-08-24 11:29:26 +00:00
|
|
|
# Check that we are running on x86_64 or i686 architecture, which are the only
|
|
|
|
# ones we support / test.
|
2018-10-25 03:31:20 +00:00
|
|
|
ARCHITECTURE=$(getconf LONG_BIT)
|
|
|
|
if [ "$HOSTTYPE" != "x86_64" ] && [ "$HOSTTYPE" != "i686" ]; then
|
|
|
|
echo "WARNING:" >&2
|
|
|
|
echo "Mail-in-a-Box has only been tested on x86_64 and i686 platform architectures." >&2
|
|
|
|
echo "Your architecture, $HOSTTYPE ($ARCHITECTURE-bit), may not work." >&2
|
|
|
|
echo "You are on your own." >&2
|
2016-03-14 06:00:33 +00:00
|
|
|
fi
|