mirror of
				https://github.com/mail-in-a-box/mailinabox.git
				synced 2025-11-03 19:30:54 +00:00 
			
		
		
		
	NextClous&Webmail features to be disabled and shellcheck findings
This commit is contained in:
		
							parent
							
								
									b8feb77ef4
								
							
						
					
					
						commit
						f3bd2d9d42
					
				
							
								
								
									
										7
									
								
								Vagrantfile
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										7
									
								
								Vagrantfile
									
									
									
									
										vendored
									
									
								
							@ -19,7 +19,12 @@ Vagrant.configure("2") do |config|
 | 
				
			|||||||
    export PUBLIC_IP=auto
 | 
					    export PUBLIC_IP=auto
 | 
				
			||||||
    export PUBLIC_IPV6=auto
 | 
					    export PUBLIC_IPV6=auto
 | 
				
			||||||
    export PRIMARY_HOSTNAME=auto
 | 
					    export PRIMARY_HOSTNAME=auto
 | 
				
			||||||
    #export SKIP_NETWORK_CHECKS=1
 | 
					
 | 
				
			||||||
 | 
					    export SKIP_NETWORK_CHECKS=1
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    export NEXTCLOUD_ENABLE=0
 | 
				
			||||||
 | 
					    export WEBMAIL_ENABLE=0
 | 
				
			||||||
 | 
					    export ZPUSH_ENABLE=0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Start the setup script.
 | 
					    # Start the setup script.
 | 
				
			||||||
    cd /vagrant
 | 
					    cd /vagrant
 | 
				
			||||||
 | 
				
			|||||||
@ -1,10 +1,12 @@
 | 
				
			|||||||
 | 
					#!/bin/bash
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Turn on "strict mode." See http://redsymbol.net/articles/unofficial-bash-strict-mode/.
 | 
					# Turn on "strict mode." See http://redsymbol.net/articles/unofficial-bash-strict-mode/.
 | 
				
			||||||
# -e: exit if any command unexpectedly fails.
 | 
					# -e: exit if any command unexpectedly fails.
 | 
				
			||||||
# -u: exit if we have a variable typo.
 | 
					# -u: exit if we have a variable typo.
 | 
				
			||||||
# -o pipefail: don't ignore errors in the non-last command in a pipeline
 | 
					# -o pipefail: don't ignore errors in the non-last command in a pipeline
 | 
				
			||||||
set -euo pipefail
 | 
					set -euo pipefail
 | 
				
			||||||
 | 
					
 | 
				
			||||||
PHP_VER=8.0
 | 
					export PHP_VER=8.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function hide_output {
 | 
					function hide_output {
 | 
				
			||||||
	# This function hides the output of a command unless the command fails
 | 
						# This function hides the output of a command unless the command fails
 | 
				
			||||||
@ -16,7 +18,7 @@ function hide_output {
 | 
				
			|||||||
	# Execute command, redirecting stderr/stdout to the temporary file. Since we
 | 
						# Execute command, redirecting stderr/stdout to the temporary file. Since we
 | 
				
			||||||
	# check the return code ourselves, disable 'set -e' temporarily.
 | 
						# check the return code ourselves, disable 'set -e' temporarily.
 | 
				
			||||||
	set +e
 | 
						set +e
 | 
				
			||||||
	"$@" &> $OUTPUT
 | 
						"$@" &> "$OUTPUT"
 | 
				
			||||||
	E=$?
 | 
						E=$?
 | 
				
			||||||
	set -e
 | 
						set -e
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -5,6 +5,10 @@
 | 
				
			|||||||
source setup/functions.sh # load our functions
 | 
					source setup/functions.sh # load our functions
 | 
				
			||||||
source /etc/mailinabox.conf # load global vars
 | 
					source /etc/mailinabox.conf # load global vars
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if [ "$NEXTCLOUD_ENABLE" -ne "1" ]; then
 | 
				
			||||||
 | 
						echo "Skipping Nextcloud installation."
 | 
				
			||||||
 | 
					else
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# ### Installing Nextcloud
 | 
					# ### Installing Nextcloud
 | 
				
			||||||
 | 
					
 | 
				
			||||||
echo "Installing Nextcloud (contacts/calendar)..."
 | 
					echo "Installing Nextcloud (contacts/calendar)..."
 | 
				
			||||||
@ -378,3 +382,5 @@ chmod +x /etc/cron.d/mailinabox-nextcloud
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
# Enable PHP modules and restart PHP.
 | 
					# Enable PHP modules and restart PHP.
 | 
				
			||||||
restart_service php$PHP_VER-fpm
 | 
					restart_service php$PHP_VER-fpm
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
@ -1,3 +1,5 @@
 | 
				
			|||||||
 | 
					#!/bin/bash
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Are we running as root?
 | 
					# Are we running as root?
 | 
				
			||||||
if [[ $EUID -ne 0 ]]; then
 | 
					if [[ $EUID -ne 0 ]]; then
 | 
				
			||||||
	echo "This script must be run as root. Please re-run like this:"
 | 
						echo "This script must be run as root. Please re-run like this:"
 | 
				
			||||||
@ -7,7 +9,7 @@ if [[ $EUID -ne 0 ]]; then
 | 
				
			|||||||
	exit 1
 | 
						exit 1
 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Check that we are running on Ubuntu 20.04 LTS (or 20.04.xx).
 | 
					# Check that we are running on Ubuntu 22.04 LTS (or 22.04.xx).
 | 
				
			||||||
if [ "$( lsb_release --id --short )" != "Ubuntu" ] || [ "$( lsb_release --release --short )" != "22.04" ]; then
 | 
					if [ "$( lsb_release --id --short )" != "Ubuntu" ] || [ "$( lsb_release --release --short )" != "22.04" ]; then
 | 
				
			||||||
	echo "Mail-in-a-Box only supports being installed on Ubuntu 22.04, sorry. You are running:"
 | 
						echo "Mail-in-a-Box only supports being installed on Ubuntu 22.04, sorry. You are running:"
 | 
				
			||||||
	echo
 | 
						echo
 | 
				
			||||||
@ -26,7 +28,7 @@ fi
 | 
				
			|||||||
#
 | 
					#
 | 
				
			||||||
# Skip the check if we appear to be running inside of Vagrant, because that's really just for testing.
 | 
					# Skip the check if we appear to be running inside of Vagrant, because that's really just for testing.
 | 
				
			||||||
TOTAL_PHYSICAL_MEM=$(head -n 1 /proc/meminfo | awk '{print $2}')
 | 
					TOTAL_PHYSICAL_MEM=$(head -n 1 /proc/meminfo | awk '{print $2}')
 | 
				
			||||||
if [ $TOTAL_PHYSICAL_MEM -lt 490000 ]; then
 | 
					if [ "$TOTAL_PHYSICAL_MEM" -lt 490000 ]; then
 | 
				
			||||||
if [ ! -d /vagrant ]; then
 | 
					if [ ! -d /vagrant ]; then
 | 
				
			||||||
	TOTAL_PHYSICAL_MEM=$(expr \( \( $TOTAL_PHYSICAL_MEM \* 1024 \) / 1000 \) / 1000)
 | 
						TOTAL_PHYSICAL_MEM=$(expr \( \( $TOTAL_PHYSICAL_MEM \* 1024 \) / 1000 \) / 1000)
 | 
				
			||||||
	echo "Your Mail-in-a-Box needs more memory (RAM) to function properly."
 | 
						echo "Your Mail-in-a-Box needs more memory (RAM) to function properly."
 | 
				
			||||||
@ -35,7 +37,7 @@ if [ ! -d /vagrant ]; then
 | 
				
			|||||||
	exit
 | 
						exit
 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
if [ $TOTAL_PHYSICAL_MEM -lt 750000 ]; then
 | 
					if [ "$TOTAL_PHYSICAL_MEM" -lt 750000 ]; then
 | 
				
			||||||
	echo "WARNING: Your Mail-in-a-Box has less than 768 MB of memory."
 | 
						echo "WARNING: Your Mail-in-a-Box has less than 768 MB of memory."
 | 
				
			||||||
	echo "         It might run unreliably when under heavy load."
 | 
						echo "         It might run unreliably when under heavy load."
 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
 | 
				
			|||||||
@ -1,3 +1,5 @@
 | 
				
			|||||||
 | 
					#!/bin/bash
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if [ -z "${NONINTERACTIVE:-}" ]; then
 | 
					if [ -z "${NONINTERACTIVE:-}" ]; then
 | 
				
			||||||
	# Install 'dialog' so we can ask the user questions. The original motivation for
 | 
						# Install 'dialog' so we can ask the user questions. The original motivation for
 | 
				
			||||||
	# this was being able to ask the user for input even if stdin has been redirected,
 | 
						# this was being able to ask the user for input even if stdin has been redirected,
 | 
				
			||||||
@ -141,16 +143,20 @@ if [ -z "${PUBLIC_IPV6:-}" ]; then
 | 
				
			|||||||
			"Enter the public IPv6 address of this machine, as given to you by your ISP.
 | 
								"Enter the public IPv6 address of this machine, as given to you by your ISP.
 | 
				
			||||||
			\n\nLeave blank if the machine does not have an IPv6 address.
 | 
								\n\nLeave blank if the machine does not have an IPv6 address.
 | 
				
			||||||
			\n\nPublic IPv6 address:" \
 | 
								\n\nPublic IPv6 address:" \
 | 
				
			||||||
			${DEFAULT_PUBLIC_IPV6:-} \
 | 
								"${DEFAULT_PUBLIC_IPV6:-}" \
 | 
				
			||||||
			PUBLIC_IPV6
 | 
								PUBLIC_IPV6
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if [ ! $PUBLIC_IPV6_EXITCODE ]; then
 | 
							if [ ! "$PUBLIC_IPV6_EXITCODE" ]; then
 | 
				
			||||||
			# user hit ESC/cancel
 | 
								# user hit ESC/cancel
 | 
				
			||||||
			exit
 | 
								exit
 | 
				
			||||||
		fi
 | 
							fi
 | 
				
			||||||
	fi
 | 
						fi
 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export NEXTCLOUD_ENABLE=$NEXTCLOUD_ENABLE
 | 
				
			||||||
 | 
					export WEBMAIL_ENABLE=$WEBMAIL_ENABLE
 | 
				
			||||||
 | 
					export ZPUSH_ENABLE=$ZPUSH_ENABLE
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Get the IP addresses of the local network interface(s) that are connected
 | 
					# Get the IP addresses of the local network interface(s) that are connected
 | 
				
			||||||
# to the Internet. We need these when we want to have services bind only to
 | 
					# to the Internet. We need these when we want to have services bind only to
 | 
				
			||||||
# the public network interfaces (not loopback, not tunnel interfaces).
 | 
					# the public network interfaces (not loopback, not tunnel interfaces).
 | 
				
			||||||
 | 
				
			|||||||
@ -4,7 +4,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
source setup/functions.sh # load our functions
 | 
					source setup/functions.sh # load our functions
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Check system setup: Are we running as root on Ubuntu 18.04 on a
 | 
					# Check system setup: Are we running as root on Ubuntu 22.04 on a
 | 
				
			||||||
# machine with enough memory? Is /tmp mounted with exec.
 | 
					# machine with enough memory? Is /tmp mounted with exec.
 | 
				
			||||||
# If not, this shows an error and exits.
 | 
					# If not, this shows an error and exits.
 | 
				
			||||||
source setup/preflight.sh
 | 
					source setup/preflight.sh
 | 
				
			||||||
@ -35,11 +35,12 @@ if [ -f /etc/mailinabox.conf ]; then
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	# Load the old .conf file to get existing configuration options loaded
 | 
						# Load the old .conf file to get existing configuration options loaded
 | 
				
			||||||
	# into variables with a DEFAULT_ prefix.
 | 
						# into variables with a DEFAULT_ prefix.
 | 
				
			||||||
	cat /etc/mailinabox.conf | sed s/^/DEFAULT_/ > /tmp/mailinabox.prev.conf
 | 
						sed s/^/DEFAULT_/ /etc/mailinabox.conf > /tmp/mailinabox.prev.conf
 | 
				
			||||||
 | 
						# shellcheck source=/dev/null
 | 
				
			||||||
	source /tmp/mailinabox.prev.conf
 | 
						source /tmp/mailinabox.prev.conf
 | 
				
			||||||
	rm -f /tmp/mailinabox.prev.conf
 | 
						rm -f /tmp/mailinabox.prev.conf
 | 
				
			||||||
else
 | 
					else
 | 
				
			||||||
	FIRST_TIME_SETUP=1
 | 
						export FIRST_TIME_SETUP=1
 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Put a start script in a global location. We tell the user to run 'mailinabox'
 | 
					# Put a start script in a global location. We tell the user to run 'mailinabox'
 | 
				
			||||||
@ -75,17 +76,17 @@ fi
 | 
				
			|||||||
# migration (schema) number for the files stored there, assume this is a fresh
 | 
					# migration (schema) number for the files stored there, assume this is a fresh
 | 
				
			||||||
# installation to that directory and write the file to contain the current
 | 
					# installation to that directory and write the file to contain the current
 | 
				
			||||||
# migration number for this version of Mail-in-a-Box.
 | 
					# migration number for this version of Mail-in-a-Box.
 | 
				
			||||||
if ! id -u $STORAGE_USER >/dev/null 2>&1; then
 | 
					if ! id -u "$STORAGE_USER" >/dev/null 2>&1; then
 | 
				
			||||||
	useradd -m $STORAGE_USER
 | 
						useradd -m "$STORAGE_USER"
 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
if [ ! -d $STORAGE_ROOT ]; then
 | 
					if [ ! -d "$STORAGE_ROOT" ]; then
 | 
				
			||||||
	mkdir -p $STORAGE_ROOT
 | 
						mkdir -p "$STORAGE_ROOT"
 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
f=$STORAGE_ROOT
 | 
					f=$STORAGE_ROOT
 | 
				
			||||||
while [[ $f != / ]]; do chmod a+rx "$f"; f=$(dirname "$f"); done;
 | 
					while [[ $f != / ]]; do chmod a+rx "$f"; f=$(dirname "$f"); done;
 | 
				
			||||||
if [ ! -f $STORAGE_ROOT/mailinabox.version ]; then
 | 
					if [ ! -f "$STORAGE_ROOT/mailinabox.version" ]; then
 | 
				
			||||||
	setup/migrate.py --current > $STORAGE_ROOT/mailinabox.version
 | 
						setup/migrate.py --current > "$STORAGE_ROOT/mailinabox.version"
 | 
				
			||||||
	chown $STORAGE_USER.$STORAGE_USER $STORAGE_ROOT/mailinabox.version
 | 
						chown "$STORAGE_USER"."$STORAGE_USER" "$STORAGE_ROOT/mailinabox.version"
 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Save the global options in /etc/mailinabox.conf so that standalone
 | 
					# Save the global options in /etc/mailinabox.conf so that standalone
 | 
				
			||||||
@ -101,6 +102,9 @@ PUBLIC_IPV6=$PUBLIC_IPV6
 | 
				
			|||||||
PRIVATE_IP=$PRIVATE_IP
 | 
					PRIVATE_IP=$PRIVATE_IP
 | 
				
			||||||
PRIVATE_IPV6=$PRIVATE_IPV6
 | 
					PRIVATE_IPV6=$PRIVATE_IPV6
 | 
				
			||||||
MTA_STS_MODE=${DEFAULT_MTA_STS_MODE:-enforce}
 | 
					MTA_STS_MODE=${DEFAULT_MTA_STS_MODE:-enforce}
 | 
				
			||||||
 | 
					NEXTCLOUD_ENABLE=$NEXTCLOUD_ENABLE
 | 
				
			||||||
 | 
					WEBMAIL_ENABLE=$WEBMAIL_ENABLE
 | 
				
			||||||
 | 
					ZPUSH_ENABLE=$ZPUSH_ENABLE
 | 
				
			||||||
EOF
 | 
					EOF
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Start service configuration.
 | 
					# Start service configuration.
 | 
				
			||||||
@ -142,14 +146,14 @@ source setup/firstuser.sh
 | 
				
			|||||||
# We'd let certbot ask the user interactively, but when this script is
 | 
					# We'd let certbot ask the user interactively, but when this script is
 | 
				
			||||||
# run in the recommended curl-pipe-to-bash method there is no TTY and
 | 
					# run in the recommended curl-pipe-to-bash method there is no TTY and
 | 
				
			||||||
# certbot will fail if it tries to ask.
 | 
					# certbot will fail if it tries to ask.
 | 
				
			||||||
if [ ! -d $STORAGE_ROOT/ssl/lets_encrypt/accounts/acme-v02.api.letsencrypt.org/ ]; then
 | 
					if [ ! -d "$STORAGE_ROOT/ssl/lets_encrypt/accounts/acme-v02.api.letsencrypt.org/" ]; then
 | 
				
			||||||
echo
 | 
					echo
 | 
				
			||||||
echo "-----------------------------------------------"
 | 
					echo "-----------------------------------------------"
 | 
				
			||||||
echo "Mail-in-a-Box uses Let's Encrypt to provision free SSL/TLS certificates"
 | 
					echo "Mail-in-a-Box uses Let's Encrypt to provision free SSL/TLS certificates"
 | 
				
			||||||
echo "to enable HTTPS connections to your box. We're automatically"
 | 
					echo "to enable HTTPS connections to your box. We're automatically"
 | 
				
			||||||
echo "agreeing you to their subscriber agreement. See https://letsencrypt.org."
 | 
					echo "agreeing you to their subscriber agreement. See https://letsencrypt.org."
 | 
				
			||||||
echo
 | 
					echo
 | 
				
			||||||
certbot register --register-unsafely-without-email --agree-tos --config-dir $STORAGE_ROOT/ssl/lets_encrypt
 | 
					certbot register --register-unsafely-without-email --agree-tos --config-dir "$STORAGE_ROOT/ssl/lets_encrypt"
 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Done.
 | 
					# Done.
 | 
				
			||||||
@ -166,7 +170,7 @@ if management/status_checks.py --check-primary-hostname; then
 | 
				
			|||||||
	echo
 | 
						echo
 | 
				
			||||||
	echo "If you have a DNS problem put the box's IP address in the URL"
 | 
						echo "If you have a DNS problem put the box's IP address in the URL"
 | 
				
			||||||
	echo "(https://$PUBLIC_IP/admin) but then check the TLS fingerprint:"
 | 
						echo "(https://$PUBLIC_IP/admin) but then check the TLS fingerprint:"
 | 
				
			||||||
	openssl x509 -in $STORAGE_ROOT/ssl/ssl_certificate.pem -noout -fingerprint -sha256\
 | 
						openssl x509 -in "$STORAGE_ROOT/ssl/ssl_certificate.pem" -noout -fingerprint -sha256\
 | 
				
			||||||
        	| sed "s/SHA256 Fingerprint=//"
 | 
					        	| sed "s/SHA256 Fingerprint=//"
 | 
				
			||||||
else
 | 
					else
 | 
				
			||||||
	echo https://$PUBLIC_IP/admin
 | 
						echo https://$PUBLIC_IP/admin
 | 
				
			||||||
@ -174,7 +178,7 @@ else
 | 
				
			|||||||
	echo You will be alerted that the website has an invalid certificate. Check that
 | 
						echo You will be alerted that the website has an invalid certificate. Check that
 | 
				
			||||||
	echo the certificate fingerprint matches:
 | 
						echo the certificate fingerprint matches:
 | 
				
			||||||
	echo
 | 
						echo
 | 
				
			||||||
	openssl x509 -in $STORAGE_ROOT/ssl/ssl_certificate.pem -noout -fingerprint -sha256\
 | 
						openssl x509 -in "$STORAGE_ROOT/ssl/ssl_certificate.pem" -noout -fingerprint -sha256\
 | 
				
			||||||
        	| sed "s/SHA256 Fingerprint=//"
 | 
					        	| sed "s/SHA256 Fingerprint=//"
 | 
				
			||||||
	echo
 | 
						echo
 | 
				
			||||||
	echo Then you can confirm the security exception and continue.
 | 
						echo Then you can confirm the security exception and continue.
 | 
				
			||||||
 | 
				
			|||||||
@ -1,3 +1,5 @@
 | 
				
			|||||||
 | 
					#!/bin/bash
 | 
				
			||||||
 | 
					
 | 
				
			||||||
source /etc/mailinabox.conf
 | 
					source /etc/mailinabox.conf
 | 
				
			||||||
source setup/functions.sh # load our functions
 | 
					source setup/functions.sh # load our functions
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -11,8 +13,8 @@ source setup/functions.sh # load our functions
 | 
				
			|||||||
#
 | 
					#
 | 
				
			||||||
# First set the hostname in the configuration file, then activate the setting
 | 
					# First set the hostname in the configuration file, then activate the setting
 | 
				
			||||||
 | 
					
 | 
				
			||||||
echo $PRIMARY_HOSTNAME > /etc/hostname
 | 
					echo "$PRIMARY_HOSTNAME" > /etc/hostname
 | 
				
			||||||
hostname $PRIMARY_HOSTNAME
 | 
					hostname "$PRIMARY_HOSTNAME"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# ### Fix permissions
 | 
					# ### Fix permissions
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -43,7 +45,7 @@ chmod g-w /etc /etc/default /usr
 | 
				
			|||||||
# See https://www.digitalocean.com/community/tutorials/how-to-add-swap-on-ubuntu-14-04
 | 
					# See https://www.digitalocean.com/community/tutorials/how-to-add-swap-on-ubuntu-14-04
 | 
				
			||||||
# for reference
 | 
					# for reference
 | 
				
			||||||
 | 
					
 | 
				
			||||||
SWAP_MOUNTED=$(cat /proc/swaps | tail -n+2)
 | 
					SWAP_MOUNTED=$(tail -n+2 /proc/swaps)
 | 
				
			||||||
SWAP_IN_FSTAB=$(grep "swap" /etc/fstab || /bin/true)
 | 
					SWAP_IN_FSTAB=$(grep "swap" /etc/fstab || /bin/true)
 | 
				
			||||||
ROOT_IS_BTRFS=$(grep "\/ .*btrfs" /proc/mounts || /bin/true)
 | 
					ROOT_IS_BTRFS=$(grep "\/ .*btrfs" /proc/mounts || /bin/true)
 | 
				
			||||||
TOTAL_PHYSICAL_MEM=$(head -n 1 /proc/meminfo | awk '{print $2}' || /bin/true)
 | 
					TOTAL_PHYSICAL_MEM=$(head -n 1 /proc/meminfo | awk '{print $2}' || /bin/true)
 | 
				
			||||||
@ -53,14 +55,14 @@ if
 | 
				
			|||||||
	[ -z "$SWAP_IN_FSTAB" ] &&
 | 
						[ -z "$SWAP_IN_FSTAB" ] &&
 | 
				
			||||||
	[ ! -e /swapfile ] &&
 | 
						[ ! -e /swapfile ] &&
 | 
				
			||||||
	[ -z "$ROOT_IS_BTRFS" ] &&
 | 
						[ -z "$ROOT_IS_BTRFS" ] &&
 | 
				
			||||||
	[ $TOTAL_PHYSICAL_MEM -lt 1900000 ] &&
 | 
						[ "$TOTAL_PHYSICAL_MEM" -lt 1900000 ] &&
 | 
				
			||||||
	[ $AVAILABLE_DISK_SPACE -gt 5242880 ]
 | 
						[ "$AVAILABLE_DISK_SPACE" -gt 5242880 ]
 | 
				
			||||||
then
 | 
					then
 | 
				
			||||||
	echo "Adding a swap file to the system..."
 | 
						echo "Adding a swap file to the system..."
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	# Allocate and activate the swap file. Allocate in 1KB chuncks
 | 
						# Allocate and activate the swap file. Allocate in 1KB chuncks
 | 
				
			||||||
	# doing it in one go, could fail on low memory systems
 | 
						# doing it in one go, could fail on low memory systems
 | 
				
			||||||
	dd if=/dev/zero of=/swapfile bs=1024 count=$[1024*1024] status=none
 | 
						dd if=/dev/zero of=/swapfile bs=1024 count=$((1024*1024)) status=none
 | 
				
			||||||
	if [ -e /swapfile ]; then
 | 
						if [ -e /swapfile ]; then
 | 
				
			||||||
		chmod 600 /swapfile
 | 
							chmod 600 /swapfile
 | 
				
			||||||
		hide_output mkswap /swapfile
 | 
							hide_output mkswap /swapfile
 | 
				
			||||||
@ -164,7 +166,7 @@ fi
 | 
				
			|||||||
# not likely the user will want to change this, so we only ask on first
 | 
					# not likely the user will want to change this, so we only ask on first
 | 
				
			||||||
# setup.
 | 
					# setup.
 | 
				
			||||||
if [ -z "${NONINTERACTIVE:-}" ]; then
 | 
					if [ -z "${NONINTERACTIVE:-}" ]; then
 | 
				
			||||||
	if [ ! -f /etc/timezone ] || [ ! -z ${FIRST_TIME_SETUP:-} ]; then
 | 
						if [ ! -f /etc/timezone ] || [ -n "${FIRST_TIME_SETUP:-}" ]; then
 | 
				
			||||||
		# If the file is missing or this is the user's first time running
 | 
							# If the file is missing or this is the user's first time running
 | 
				
			||||||
		# Mail-in-a-Box setup, run the interactive timezone configuration
 | 
							# Mail-in-a-Box setup, run the interactive timezone configuration
 | 
				
			||||||
		# tool.
 | 
							# tool.
 | 
				
			||||||
@ -273,8 +275,8 @@ if [ -z "${DISABLE_FIREWALL:-}" ]; then
 | 
				
			|||||||
	if [ ! -z "$SSH_PORT" ]; then
 | 
						if [ ! -z "$SSH_PORT" ]; then
 | 
				
			||||||
	if [ "$SSH_PORT" != "22" ]; then
 | 
						if [ "$SSH_PORT" != "22" ]; then
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	echo Opening alternate SSH port $SSH_PORT. #NODOC
 | 
						echo Opening alternate SSH port "$SSH_PORT". #NODOC
 | 
				
			||||||
	ufw_limit $SSH_PORT #NODOC
 | 
						ufw_limit "$SSH_PORT" #NODOC
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	fi
 | 
						fi
 | 
				
			||||||
	fi
 | 
						fi
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										280
									
								
								setup/webmail.sh
									
									
									
									
									
								
							
							
						
						
									
										280
									
								
								setup/webmail.sh
									
									
									
									
									
								
							@ -5,131 +5,135 @@
 | 
				
			|||||||
source setup/functions.sh # load our functions
 | 
					source setup/functions.sh # load our functions
 | 
				
			||||||
source /etc/mailinabox.conf # load global vars
 | 
					source /etc/mailinabox.conf # load global vars
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# ### Installing Roundcube
 | 
					if [ "$WEBMAIL_ENABLE" -ne "1" ]; then
 | 
				
			||||||
 | 
						echo "Skipping Roundcube (webmail) installation."
 | 
				
			||||||
 | 
					else
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# We install Roundcube from sources, rather than from Ubuntu, because:
 | 
						# ### Installing Roundcube
 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# 1. Ubuntu's `roundcube-core` package has dependencies on Apache & MySQL, which we don't want.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# 2. The Roundcube shipped with Ubuntu is consistently out of date.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# 3. It's packaged incorrectly --- it seems to be missing a directory of files.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# So we'll use apt-get to manually install the dependencies of roundcube that we know we need,
 | 
					 | 
				
			||||||
# and then we'll manually install roundcube from source.
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
# These dependencies are from `apt-cache showpkg roundcube-core`.
 | 
						# We install Roundcube from sources, rather than from Ubuntu, because:
 | 
				
			||||||
echo "Installing Roundcube (webmail)..."
 | 
						#
 | 
				
			||||||
apt_install \
 | 
						# 1. Ubuntu's `roundcube-core` package has dependencies on Apache & MySQL, which we don't want.
 | 
				
			||||||
	dbconfig-common \
 | 
						#
 | 
				
			||||||
	php${PHP_VER}-cli php${PHP_VER}-sqlite3 php${PHP_VER}-intl php${PHP_VER}-common php${PHP_VER}-curl php${PHP_VER}-imap \
 | 
						# 2. The Roundcube shipped with Ubuntu is consistently out of date.
 | 
				
			||||||
	php${PHP_VER}-gd php${PHP_VER}-pspell php${PHP_VER}-mbstring libjs-jquery libjs-jquery-mousewheel libmagic1
 | 
						#
 | 
				
			||||||
 | 
						# 3. It's packaged incorrectly --- it seems to be missing a directory of files.
 | 
				
			||||||
 | 
						#
 | 
				
			||||||
 | 
						# So we'll use apt-get to manually install the dependencies of roundcube that we know we need,
 | 
				
			||||||
 | 
						# and then we'll manually install roundcube from source.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Install Roundcube from source if it is not already present or if it is out of date.
 | 
						# These dependencies are from `apt-cache showpkg roundcube-core`.
 | 
				
			||||||
# Combine the Roundcube version number with the commit hash of plugins to track
 | 
						echo "Installing Roundcube (webmail)..."
 | 
				
			||||||
# whether we have the latest version of everything.
 | 
						apt_install \
 | 
				
			||||||
# For the latest versions, see:
 | 
							dbconfig-common \
 | 
				
			||||||
#   https://github.com/roundcube/roundcubemail/releases
 | 
							php${PHP_VER}-cli php${PHP_VER}-sqlite3 php${PHP_VER}-intl php${PHP_VER}-common php${PHP_VER}-curl php${PHP_VER}-imap \
 | 
				
			||||||
#   https://github.com/mfreiholz/persistent_login/commits/master
 | 
							php${PHP_VER}-gd php${PHP_VER}-pspell php${PHP_VER}-mbstring libjs-jquery libjs-jquery-mousewheel libmagic1
 | 
				
			||||||
#   https://github.com/stremlau/html5_notifier/commits/master
 | 
					 | 
				
			||||||
#   https://github.com/mstilkerich/rcmcarddav/releases
 | 
					 | 
				
			||||||
# The easiest way to get the package hashes is to run this script and get the hash from
 | 
					 | 
				
			||||||
# the error message.
 | 
					 | 
				
			||||||
VERSION=1.6.0
 | 
					 | 
				
			||||||
HASH=fd84b4fac74419bb73e7a3bcae1978d5589c52de
 | 
					 | 
				
			||||||
PERSISTENT_LOGIN_VERSION=bde7b6840c7d91de627ea14e81cf4133cbb3c07a # version 5.2
 | 
					 | 
				
			||||||
HTML5_NOTIFIER_VERSION=68d9ca194212e15b3c7225eb6085dbcf02fd13d7 # version 0.6.4+
 | 
					 | 
				
			||||||
CARDDAV_VERSION=4.4.3
 | 
					 | 
				
			||||||
CARDDAV_HASH=74f8ba7aee33e78beb9de07f7f44b81f6071b644
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
UPDATE_KEY=$VERSION:$PERSISTENT_LOGIN_VERSION:$HTML5_NOTIFIER_VERSION:$CARDDAV_VERSION
 | 
						# Install Roundcube from source if it is not already present or if it is out of date.
 | 
				
			||||||
 | 
						# Combine the Roundcube version number with the commit hash of plugins to track
 | 
				
			||||||
 | 
						# whether we have the latest version of everything.
 | 
				
			||||||
 | 
						# For the latest versions, see:
 | 
				
			||||||
 | 
						#   https://github.com/roundcube/roundcubemail/releases
 | 
				
			||||||
 | 
						#   https://github.com/mfreiholz/persistent_login/commits/master
 | 
				
			||||||
 | 
						#   https://github.com/stremlau/html5_notifier/commits/master
 | 
				
			||||||
 | 
						#   https://github.com/mstilkerich/rcmcarddav/releases
 | 
				
			||||||
 | 
						# The easiest way to get the package hashes is to run this script and get the hash from
 | 
				
			||||||
 | 
						# the error message.
 | 
				
			||||||
 | 
						VERSION=1.6.0
 | 
				
			||||||
 | 
						HASH=fd84b4fac74419bb73e7a3bcae1978d5589c52de
 | 
				
			||||||
 | 
						PERSISTENT_LOGIN_VERSION=bde7b6840c7d91de627ea14e81cf4133cbb3c07a # version 5.2
 | 
				
			||||||
 | 
						HTML5_NOTIFIER_VERSION=68d9ca194212e15b3c7225eb6085dbcf02fd13d7 # version 0.6.4+
 | 
				
			||||||
 | 
						CARDDAV_VERSION=4.4.3
 | 
				
			||||||
 | 
						CARDDAV_HASH=74f8ba7aee33e78beb9de07f7f44b81f6071b644
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# paths that are often reused.
 | 
						UPDATE_KEY=$VERSION:$PERSISTENT_LOGIN_VERSION:$HTML5_NOTIFIER_VERSION:$CARDDAV_VERSION
 | 
				
			||||||
RCM_DIR=/usr/local/lib/roundcubemail
 | 
					 | 
				
			||||||
RCM_PLUGIN_DIR=${RCM_DIR}/plugins
 | 
					 | 
				
			||||||
RCM_CONFIG=${RCM_DIR}/config/config.inc.php
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
needs_update=0 #NODOC
 | 
						# paths that are often reused.
 | 
				
			||||||
if [ ! -f /usr/local/lib/roundcubemail/version ]; then
 | 
						RCM_DIR=/usr/local/lib/roundcubemail
 | 
				
			||||||
	# not installed yet #NODOC
 | 
						RCM_PLUGIN_DIR=${RCM_DIR}/plugins
 | 
				
			||||||
	needs_update=1 #NODOC
 | 
						RCM_CONFIG=${RCM_DIR}/config/config.inc.php
 | 
				
			||||||
elif [[ "$UPDATE_KEY" != $(cat /usr/local/lib/roundcubemail/version) ]]; then
 | 
					 | 
				
			||||||
	# checks if the version is what we want
 | 
					 | 
				
			||||||
	needs_update=1 #NODOC
 | 
					 | 
				
			||||||
fi
 | 
					 | 
				
			||||||
if [ $needs_update == 1 ]; then
 | 
					 | 
				
			||||||
  # if upgrading from 1.3.x, clear the temp_dir
 | 
					 | 
				
			||||||
  if [ -f /usr/local/lib/roundcubemail/version ]; then
 | 
					 | 
				
			||||||
    if [ "$(cat /usr/local/lib/roundcubemail/version | cut -c1-3)" == '1.3' ]; then
 | 
					 | 
				
			||||||
      find /var/tmp/roundcubemail/ -type f ! -name 'RCMTEMP*' -delete
 | 
					 | 
				
			||||||
    fi
 | 
					 | 
				
			||||||
  fi
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	# install roundcube
 | 
						needs_update=0 #NODOC
 | 
				
			||||||
	wget_verify \
 | 
						if [ ! -f /usr/local/lib/roundcubemail/version ]; then
 | 
				
			||||||
		https://github.com/roundcube/roundcubemail/releases/download/$VERSION/roundcubemail-$VERSION-complete.tar.gz \
 | 
							# not installed yet #NODOC
 | 
				
			||||||
		$HASH \
 | 
							needs_update=1 #NODOC
 | 
				
			||||||
		/tmp/roundcube.tgz
 | 
						elif [[ "$UPDATE_KEY" != $(cat /usr/local/lib/roundcubemail/version) ]]; then
 | 
				
			||||||
	tar -C /usr/local/lib --no-same-owner -zxf /tmp/roundcube.tgz
 | 
							# checks if the version is what we want
 | 
				
			||||||
	rm -rf /usr/local/lib/roundcubemail
 | 
							needs_update=1 #NODOC
 | 
				
			||||||
	mv /usr/local/lib/roundcubemail-$VERSION/ $RCM_DIR
 | 
						fi
 | 
				
			||||||
	rm -f /tmp/roundcube.tgz
 | 
						if [ $needs_update == 1 ]; then
 | 
				
			||||||
 | 
						# if upgrading from 1.3.x, clear the temp_dir
 | 
				
			||||||
 | 
						if [ -f /usr/local/lib/roundcubemail/version ]; then
 | 
				
			||||||
 | 
							if [ "$(cat /usr/local/lib/roundcubemail/version | cut -c1-3)" == '1.3' ]; then
 | 
				
			||||||
 | 
							find /var/tmp/roundcubemail/ -type f ! -name 'RCMTEMP*' -delete
 | 
				
			||||||
 | 
							fi
 | 
				
			||||||
 | 
						fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	# install roundcube persistent_login plugin
 | 
							# install roundcube
 | 
				
			||||||
	git_clone https://github.com/mfreiholz/Roundcube-Persistent-Login-Plugin.git $PERSISTENT_LOGIN_VERSION '' ${RCM_PLUGIN_DIR}/persistent_login
 | 
							wget_verify \
 | 
				
			||||||
 | 
								https://github.com/roundcube/roundcubemail/releases/download/$VERSION/roundcubemail-$VERSION-complete.tar.gz \
 | 
				
			||||||
 | 
								$HASH \
 | 
				
			||||||
 | 
								/tmp/roundcube.tgz
 | 
				
			||||||
 | 
							tar -C /usr/local/lib --no-same-owner -zxf /tmp/roundcube.tgz
 | 
				
			||||||
 | 
							rm -rf /usr/local/lib/roundcubemail
 | 
				
			||||||
 | 
							mv /usr/local/lib/roundcubemail-$VERSION/ $RCM_DIR
 | 
				
			||||||
 | 
							rm -f /tmp/roundcube.tgz
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	# install roundcube html5_notifier plugin
 | 
							# install roundcube persistent_login plugin
 | 
				
			||||||
	git_clone https://github.com/kitist/html5_notifier.git $HTML5_NOTIFIER_VERSION '' ${RCM_PLUGIN_DIR}/html5_notifier
 | 
							git_clone https://github.com/mfreiholz/Roundcube-Persistent-Login-Plugin.git $PERSISTENT_LOGIN_VERSION '' ${RCM_PLUGIN_DIR}/persistent_login
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	# download and verify the full release of the carddav plugin
 | 
							# install roundcube html5_notifier plugin
 | 
				
			||||||
	wget_verify \
 | 
							git_clone https://github.com/kitist/html5_notifier.git $HTML5_NOTIFIER_VERSION '' ${RCM_PLUGIN_DIR}/html5_notifier
 | 
				
			||||||
		https://github.com/mstilkerich/rcmcarddav/releases/download/v${CARDDAV_VERSION}/carddav-v${CARDDAV_VERSION}.tar.gz \
 | 
					 | 
				
			||||||
		$CARDDAV_HASH \
 | 
					 | 
				
			||||||
		/tmp/carddav.tar.gz
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	# unzip and cleanup
 | 
							# download and verify the full release of the carddav plugin
 | 
				
			||||||
	tar -C ${RCM_PLUGIN_DIR} -zxf /tmp/carddav.tar.gz
 | 
							wget_verify \
 | 
				
			||||||
	rm -f /tmp/carddav.tar.gz
 | 
								https://github.com/mstilkerich/rcmcarddav/releases/download/v${CARDDAV_VERSION}/carddav-v${CARDDAV_VERSION}.tar.gz \
 | 
				
			||||||
 | 
								$CARDDAV_HASH \
 | 
				
			||||||
 | 
								/tmp/carddav.tar.gz
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	# record the version we've installed
 | 
							# unzip and cleanup
 | 
				
			||||||
	echo $UPDATE_KEY > ${RCM_DIR}/version
 | 
							tar -C ${RCM_PLUGIN_DIR} -zxf /tmp/carddav.tar.gz
 | 
				
			||||||
fi
 | 
							rm -f /tmp/carddav.tar.gz
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# ### Configuring Roundcube
 | 
							# record the version we've installed
 | 
				
			||||||
 | 
							echo $UPDATE_KEY > ${RCM_DIR}/version
 | 
				
			||||||
 | 
						fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Generate a secret key of PHP-string-safe characters appropriate
 | 
						# ### Configuring Roundcube
 | 
				
			||||||
# for the cipher algorithm selected below.
 | 
					 | 
				
			||||||
SECRET_KEY=$(dd if=/dev/urandom bs=1 count=32 2>/dev/null | base64 | sed s/=//g)
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Create a configuration file.
 | 
						# Generate a secret key of PHP-string-safe characters appropriate
 | 
				
			||||||
#
 | 
						# for the cipher algorithm selected below.
 | 
				
			||||||
# For security, temp and log files are not stored in the default locations
 | 
						SECRET_KEY=$(dd if=/dev/urandom bs=1 count=32 2>/dev/null | base64 | sed s/=//g)
 | 
				
			||||||
# which are inside the roundcube sources directory. We put them instead
 | 
					
 | 
				
			||||||
# in normal places.
 | 
						# Create a configuration file.
 | 
				
			||||||
cat > $RCM_CONFIG <<EOF;
 | 
						#
 | 
				
			||||||
 | 
						# For security, temp and log files are not stored in the default locations
 | 
				
			||||||
 | 
						# which are inside the roundcube sources directory. We put them instead
 | 
				
			||||||
 | 
						# in normal places.
 | 
				
			||||||
 | 
						cat > $RCM_CONFIG <<EOF;
 | 
				
			||||||
<?php
 | 
					<?php
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
 * Do not edit. Written by Mail-in-a-Box. Regenerated on updates.
 | 
					* Do not edit. Written by Mail-in-a-Box. Regenerated on updates.
 | 
				
			||||||
 */
 | 
					*/
 | 
				
			||||||
\$config = array();
 | 
					\$config = array();
 | 
				
			||||||
\$config['log_dir'] = '/var/log/roundcubemail/';
 | 
					\$config['log_dir'] = '/var/log/roundcubemail/';
 | 
				
			||||||
\$config['temp_dir'] = '/var/tmp/roundcubemail/';
 | 
					\$config['temp_dir'] = '/var/tmp/roundcubemail/';
 | 
				
			||||||
\$config['db_dsnw'] = 'sqlite:///$STORAGE_ROOT/mail/roundcube/roundcube.sqlite?mode=0640';
 | 
					\$config['db_dsnw'] = 'sqlite:///$STORAGE_ROOT/mail/roundcube/roundcube.sqlite?mode=0640';
 | 
				
			||||||
\$config['imap_host'] = 'ssl://localhost:993';
 | 
					\$config['imap_host'] = 'ssl://localhost:993';
 | 
				
			||||||
\$config['imap_conn_options'] = array(
 | 
					\$config['imap_conn_options'] = array(
 | 
				
			||||||
  'ssl'         => array(
 | 
					'ssl'         => array(
 | 
				
			||||||
     'verify_peer'  => false,
 | 
						'verify_peer'  => false,
 | 
				
			||||||
     'verify_peer_name'  => false,
 | 
						'verify_peer_name'  => false,
 | 
				
			||||||
   ),
 | 
					),
 | 
				
			||||||
 );
 | 
					);
 | 
				
			||||||
\$config['imap_timeout'] = 15;
 | 
					\$config['imap_timeout'] = 15;
 | 
				
			||||||
\$config['smtp_host'] = 'tls://127.0.0.1';
 | 
					\$config['smtp_host'] = 'tls://127.0.0.1';
 | 
				
			||||||
\$config['smtp_conn_options'] = array(
 | 
					\$config['smtp_conn_options'] = array(
 | 
				
			||||||
  'ssl'         => array(
 | 
					'ssl'         => array(
 | 
				
			||||||
     'verify_peer'  => false,
 | 
						'verify_peer'  => false,
 | 
				
			||||||
     'verify_peer_name'  => false,
 | 
						'verify_peer_name'  => false,
 | 
				
			||||||
   ),
 | 
					),
 | 
				
			||||||
 );
 | 
					);
 | 
				
			||||||
\$config['support_url'] = 'https://mailinabox.email/';
 | 
					\$config['support_url'] = 'https://mailinabox.email/';
 | 
				
			||||||
\$config['product_name'] = '$PRIMARY_HOSTNAME Webmail';
 | 
					\$config['product_name'] = '$PRIMARY_HOSTNAME Webmail';
 | 
				
			||||||
\$config['cipher_method'] = 'AES-256-CBC'; # persistent login cookie and potentially other things
 | 
					\$config['cipher_method'] = 'AES-256-CBC'; # persistent login cookie and potentially other things
 | 
				
			||||||
@ -147,8 +151,8 @@ cat > $RCM_CONFIG <<EOF;
 | 
				
			|||||||
?>
 | 
					?>
 | 
				
			||||||
EOF
 | 
					EOF
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Configure CardDav
 | 
						# Configure CardDav
 | 
				
			||||||
cat > ${RCM_PLUGIN_DIR}/carddav/config.inc.php <<EOF;
 | 
						cat > ${RCM_PLUGIN_DIR}/carddav/config.inc.php <<EOF;
 | 
				
			||||||
<?php
 | 
					<?php
 | 
				
			||||||
/* Do not edit. Written by Mail-in-a-Box. Regenerated on updates. */
 | 
					/* Do not edit. Written by Mail-in-a-Box. Regenerated on updates. */
 | 
				
			||||||
\$prefs['_GLOBAL']['hide_preferences'] = true;
 | 
					\$prefs['_GLOBAL']['hide_preferences'] = true;
 | 
				
			||||||
@ -168,47 +172,49 @@ cat > ${RCM_PLUGIN_DIR}/carddav/config.inc.php <<EOF;
 | 
				
			|||||||
?>
 | 
					?>
 | 
				
			||||||
EOF
 | 
					EOF
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Create writable directories.
 | 
						# Create writable directories.
 | 
				
			||||||
mkdir -p /var/log/roundcubemail /var/tmp/roundcubemail $STORAGE_ROOT/mail/roundcube
 | 
						mkdir -p /var/log/roundcubemail /var/tmp/roundcubemail $STORAGE_ROOT/mail/roundcube
 | 
				
			||||||
chown -R www-data.www-data /var/log/roundcubemail /var/tmp/roundcubemail $STORAGE_ROOT/mail/roundcube
 | 
						chown -R www-data.www-data /var/log/roundcubemail /var/tmp/roundcubemail $STORAGE_ROOT/mail/roundcube
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Ensure the log file monitored by fail2ban exists, or else fail2ban can't start.
 | 
						# Ensure the log file monitored by fail2ban exists, or else fail2ban can't start.
 | 
				
			||||||
sudo -u www-data touch /var/log/roundcubemail/errors.log
 | 
						sudo -u www-data touch /var/log/roundcubemail/errors.log
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Password changing plugin settings
 | 
						# Password changing plugin settings
 | 
				
			||||||
# The config comes empty by default, so we need the settings
 | 
						# The config comes empty by default, so we need the settings
 | 
				
			||||||
# we're not planning to change in config.inc.dist...
 | 
						# we're not planning to change in config.inc.dist...
 | 
				
			||||||
cp ${RCM_PLUGIN_DIR}/password/config.inc.php.dist \
 | 
						cp ${RCM_PLUGIN_DIR}/password/config.inc.php.dist \
 | 
				
			||||||
	${RCM_PLUGIN_DIR}/password/config.inc.php
 | 
							${RCM_PLUGIN_DIR}/password/config.inc.php
 | 
				
			||||||
 | 
					
 | 
				
			||||||
tools/editconf.py ${RCM_PLUGIN_DIR}/password/config.inc.php \
 | 
						tools/editconf.py ${RCM_PLUGIN_DIR}/password/config.inc.php \
 | 
				
			||||||
	"\$config['password_minimum_length']=8;" \
 | 
							"\$config['password_minimum_length']=8;" \
 | 
				
			||||||
	"\$config['password_db_dsn']='sqlite:///$STORAGE_ROOT/mail/users.sqlite';" \
 | 
							"\$config['password_db_dsn']='sqlite:///$STORAGE_ROOT/mail/users.sqlite';" \
 | 
				
			||||||
	"\$config['password_query']='UPDATE users SET password=%D WHERE email=%u';" \
 | 
							"\$config['password_query']='UPDATE users SET password=%D WHERE email=%u';" \
 | 
				
			||||||
	"\$config['password_dovecotpw']='/usr/bin/doveadm pw';" \
 | 
							"\$config['password_dovecotpw']='/usr/bin/doveadm pw';" \
 | 
				
			||||||
	"\$config['password_dovecotpw_method']='SHA512-CRYPT';" \
 | 
							"\$config['password_dovecotpw_method']='SHA512-CRYPT';" \
 | 
				
			||||||
	"\$config['password_dovecotpw_with_method']=true;"
 | 
							"\$config['password_dovecotpw_with_method']=true;"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# so PHP can use doveadm, for the password changing plugin
 | 
						# so PHP can use doveadm, for the password changing plugin
 | 
				
			||||||
usermod -a -G dovecot www-data
 | 
						usermod -a -G dovecot www-data
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# set permissions so that PHP can use users.sqlite
 | 
						# set permissions so that PHP can use users.sqlite
 | 
				
			||||||
# could use dovecot instead of www-data, but not sure it matters
 | 
						# could use dovecot instead of www-data, but not sure it matters
 | 
				
			||||||
chown root.www-data $STORAGE_ROOT/mail
 | 
						chown root.www-data $STORAGE_ROOT/mail
 | 
				
			||||||
chmod 775 $STORAGE_ROOT/mail
 | 
						chmod 775 $STORAGE_ROOT/mail
 | 
				
			||||||
chown root.www-data $STORAGE_ROOT/mail/users.sqlite
 | 
						chown root.www-data $STORAGE_ROOT/mail/users.sqlite
 | 
				
			||||||
chmod 664 $STORAGE_ROOT/mail/users.sqlite
 | 
						chmod 664 $STORAGE_ROOT/mail/users.sqlite
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Fix Carddav permissions:
 | 
						# Fix Carddav permissions:
 | 
				
			||||||
chown -f -R root.www-data ${RCM_PLUGIN_DIR}/carddav
 | 
						chown -f -R root.www-data ${RCM_PLUGIN_DIR}/carddav
 | 
				
			||||||
# root.www-data need all permissions, others only read
 | 
						# root.www-data need all permissions, others only read
 | 
				
			||||||
chmod -R 774 ${RCM_PLUGIN_DIR}/carddav
 | 
						chmod -R 774 ${RCM_PLUGIN_DIR}/carddav
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Run Roundcube database migration script (database is created if it does not exist)
 | 
						# Run Roundcube database migration script (database is created if it does not exist)
 | 
				
			||||||
php$PHP_VER ${RCM_DIR}/bin/updatedb.sh --dir ${RCM_DIR}/SQL --package roundcube
 | 
						php$PHP_VER ${RCM_DIR}/bin/updatedb.sh --dir ${RCM_DIR}/SQL --package roundcube
 | 
				
			||||||
chown www-data:www-data $STORAGE_ROOT/mail/roundcube/roundcube.sqlite
 | 
						chown www-data:www-data $STORAGE_ROOT/mail/roundcube/roundcube.sqlite
 | 
				
			||||||
chmod 664 $STORAGE_ROOT/mail/roundcube/roundcube.sqlite
 | 
						chmod 664 $STORAGE_ROOT/mail/roundcube/roundcube.sqlite
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Enable PHP modules.
 | 
						# Enable PHP modules.
 | 
				
			||||||
phpenmod -v $PHP_VER imap
 | 
						phpenmod -v $PHP_VER imap
 | 
				
			||||||
restart_service php$PHP_VER-fpm
 | 
						restart_service php$PHP_VER-fpm
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
							
								
								
									
										134
									
								
								setup/zpush.sh
									
									
									
									
									
								
							
							
						
						
									
										134
									
								
								setup/zpush.sh
									
									
									
									
									
								
							@ -13,81 +13,85 @@
 | 
				
			|||||||
source setup/functions.sh # load our functions
 | 
					source setup/functions.sh # load our functions
 | 
				
			||||||
source /etc/mailinabox.conf # load global vars
 | 
					source /etc/mailinabox.conf # load global vars
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Prereqs.
 | 
					if [ "$ZPUSH_ENABLE" -ne "1" ]; then
 | 
				
			||||||
 | 
						echo "Skipping Roundcube (webmail) installation."
 | 
				
			||||||
 | 
					else
 | 
				
			||||||
 | 
					
 | 
				
			||||||
echo "Installing Z-Push (Exchange/ActiveSync server)..."
 | 
						# Prereqs.
 | 
				
			||||||
apt_install \
 | 
					 | 
				
			||||||
       php${PHP_VER}-soap php${PHP_VER}-imap libawl-php php$PHP_VER-xml
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
phpenmod -v $PHP_VER imap
 | 
						echo "Installing Z-Push (Exchange/ActiveSync server)..."
 | 
				
			||||||
 | 
						apt_install \
 | 
				
			||||||
 | 
							php${PHP_VER}-soap php${PHP_VER}-imap libawl-php php$PHP_VER-xml
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Copy Z-Push into place.
 | 
						phpenmod -v $PHP_VER imap
 | 
				
			||||||
VERSION=2.6.2
 | 
					 | 
				
			||||||
TARGETHASH=f0e8091a8030e5b851f5ba1f9f0e1a05b8762d80
 | 
					 | 
				
			||||||
needs_update=0 #NODOC
 | 
					 | 
				
			||||||
if [ ! -f /usr/local/lib/z-push/version ]; then
 | 
					 | 
				
			||||||
	needs_update=1 #NODOC
 | 
					 | 
				
			||||||
elif [[ $VERSION != $(cat /usr/local/lib/z-push/version) ]]; then
 | 
					 | 
				
			||||||
	# checks if the version
 | 
					 | 
				
			||||||
	needs_update=1 #NODOC
 | 
					 | 
				
			||||||
fi
 | 
					 | 
				
			||||||
if [ $needs_update == 1 ]; then
 | 
					 | 
				
			||||||
	# Download
 | 
					 | 
				
			||||||
	wget_verify "https://github.com/Z-Hub/Z-Push/archive/refs/tags/$VERSION.zip" $TARGETHASH /tmp/z-push.zip
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	# Extract into place.
 | 
						# Copy Z-Push into place.
 | 
				
			||||||
	rm -rf /usr/local/lib/z-push /tmp/z-push
 | 
						VERSION=2.6.2
 | 
				
			||||||
	unzip -q /tmp/z-push.zip -d /tmp/z-push
 | 
						TARGETHASH=f0e8091a8030e5b851f5ba1f9f0e1a05b8762d80
 | 
				
			||||||
	mv /tmp/z-push/*/src /usr/local/lib/z-push
 | 
						needs_update=0 #NODOC
 | 
				
			||||||
	rm -rf /tmp/z-push.zip /tmp/z-push
 | 
						if [ ! -f /usr/local/lib/z-push/version ]; then
 | 
				
			||||||
 | 
							needs_update=1 #NODOC
 | 
				
			||||||
 | 
						elif [[ $VERSION != $(cat /usr/local/lib/z-push/version) ]]; then
 | 
				
			||||||
 | 
							# checks if the version
 | 
				
			||||||
 | 
							needs_update=1 #NODOC
 | 
				
			||||||
 | 
						fi
 | 
				
			||||||
 | 
						if [ $needs_update == 1 ]; then
 | 
				
			||||||
 | 
							# Download
 | 
				
			||||||
 | 
							wget_verify "https://github.com/Z-Hub/Z-Push/archive/refs/tags/$VERSION.zip" $TARGETHASH /tmp/z-push.zip
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	rm -f /usr/sbin/z-push-{admin,top}
 | 
							# Extract into place.
 | 
				
			||||||
	echo $VERSION > /usr/local/lib/z-push/version
 | 
							rm -rf /usr/local/lib/z-push /tmp/z-push
 | 
				
			||||||
fi
 | 
							unzip -q /tmp/z-push.zip -d /tmp/z-push
 | 
				
			||||||
 | 
							mv /tmp/z-push/*/src /usr/local/lib/z-push
 | 
				
			||||||
 | 
							rm -rf /tmp/z-push.zip /tmp/z-push
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Configure default config.
 | 
							rm -f /usr/sbin/z-push-{admin,top}
 | 
				
			||||||
sed -i "s^define('TIMEZONE', .*^define('TIMEZONE', '$(cat /etc/timezone)');^" /usr/local/lib/z-push/config.php
 | 
							echo $VERSION > /usr/local/lib/z-push/version
 | 
				
			||||||
sed -i "s/define('BACKEND_PROVIDER', .*/define('BACKEND_PROVIDER', 'BackendCombined');/" /usr/local/lib/z-push/config.php
 | 
						fi
 | 
				
			||||||
sed -i "s/define('USE_FULLEMAIL_FOR_LOGIN', .*/define('USE_FULLEMAIL_FOR_LOGIN', true);/" /usr/local/lib/z-push/config.php
 | 
					 | 
				
			||||||
sed -i "s/define('LOG_MEMORY_PROFILER', .*/define('LOG_MEMORY_PROFILER', false);/" /usr/local/lib/z-push/config.php
 | 
					 | 
				
			||||||
sed -i "s/define('BUG68532FIXED', .*/define('BUG68532FIXED', false);/" /usr/local/lib/z-push/config.php
 | 
					 | 
				
			||||||
sed -i "s/define('LOGLEVEL', .*/define('LOGLEVEL', LOGLEVEL_ERROR);/" /usr/local/lib/z-push/config.php
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Configure BACKEND
 | 
						# Configure default config.
 | 
				
			||||||
rm -f /usr/local/lib/z-push/backend/combined/config.php
 | 
						sed -i "s^define('TIMEZONE', .*^define('TIMEZONE', '$(cat /etc/timezone)');^" /usr/local/lib/z-push/config.php
 | 
				
			||||||
cp conf/zpush/backend_combined.php /usr/local/lib/z-push/backend/combined/config.php
 | 
						sed -i "s/define('BACKEND_PROVIDER', .*/define('BACKEND_PROVIDER', 'BackendCombined');/" /usr/local/lib/z-push/config.php
 | 
				
			||||||
 | 
						sed -i "s/define('USE_FULLEMAIL_FOR_LOGIN', .*/define('USE_FULLEMAIL_FOR_LOGIN', true);/" /usr/local/lib/z-push/config.php
 | 
				
			||||||
 | 
						sed -i "s/define('LOG_MEMORY_PROFILER', .*/define('LOG_MEMORY_PROFILER', false);/" /usr/local/lib/z-push/config.php
 | 
				
			||||||
 | 
						sed -i "s/define('BUG68532FIXED', .*/define('BUG68532FIXED', false);/" /usr/local/lib/z-push/config.php
 | 
				
			||||||
 | 
						sed -i "s/define('LOGLEVEL', .*/define('LOGLEVEL', LOGLEVEL_ERROR);/" /usr/local/lib/z-push/config.php
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Configure IMAP
 | 
						# Configure BACKEND
 | 
				
			||||||
rm -f /usr/local/lib/z-push/backend/imap/config.php
 | 
						rm -f /usr/local/lib/z-push/backend/combined/config.php
 | 
				
			||||||
cp conf/zpush/backend_imap.php /usr/local/lib/z-push/backend/imap/config.php
 | 
						cp conf/zpush/backend_combined.php /usr/local/lib/z-push/backend/combined/config.php
 | 
				
			||||||
sed -i "s%STORAGE_ROOT%$STORAGE_ROOT%" /usr/local/lib/z-push/backend/imap/config.php
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Configure CardDav
 | 
						# Configure IMAP
 | 
				
			||||||
rm -f /usr/local/lib/z-push/backend/carddav/config.php
 | 
						rm -f /usr/local/lib/z-push/backend/imap/config.php
 | 
				
			||||||
cp conf/zpush/backend_carddav.php /usr/local/lib/z-push/backend/carddav/config.php
 | 
						cp conf/zpush/backend_imap.php /usr/local/lib/z-push/backend/imap/config.php
 | 
				
			||||||
 | 
						sed -i "s%STORAGE_ROOT%$STORAGE_ROOT%" /usr/local/lib/z-push/backend/imap/config.php
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Configure CalDav
 | 
						# Configure CardDav
 | 
				
			||||||
rm -f /usr/local/lib/z-push/backend/caldav/config.php
 | 
						rm -f /usr/local/lib/z-push/backend/carddav/config.php
 | 
				
			||||||
cp conf/zpush/backend_caldav.php /usr/local/lib/z-push/backend/caldav/config.php
 | 
						cp conf/zpush/backend_carddav.php /usr/local/lib/z-push/backend/carddav/config.php
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Configure Autodiscover
 | 
						# Configure CalDav
 | 
				
			||||||
rm -f /usr/local/lib/z-push/autodiscover/config.php
 | 
						rm -f /usr/local/lib/z-push/backend/caldav/config.php
 | 
				
			||||||
cp conf/zpush/autodiscover_config.php /usr/local/lib/z-push/autodiscover/config.php
 | 
						cp conf/zpush/backend_caldav.php /usr/local/lib/z-push/backend/caldav/config.php
 | 
				
			||||||
sed -i "s/PRIMARY_HOSTNAME/$PRIMARY_HOSTNAME/" /usr/local/lib/z-push/autodiscover/config.php
 | 
					 | 
				
			||||||
sed -i "s^define('TIMEZONE', .*^define('TIMEZONE', '$(cat /etc/timezone)');^" /usr/local/lib/z-push/autodiscover/config.php
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Some directories it will use.
 | 
						# Configure Autodiscover
 | 
				
			||||||
 | 
						rm -f /usr/local/lib/z-push/autodiscover/config.php
 | 
				
			||||||
 | 
						cp conf/zpush/autodiscover_config.php /usr/local/lib/z-push/autodiscover/config.php
 | 
				
			||||||
 | 
						sed -i "s/PRIMARY_HOSTNAME/$PRIMARY_HOSTNAME/" /usr/local/lib/z-push/autodiscover/config.php
 | 
				
			||||||
 | 
						sed -i "s^define('TIMEZONE', .*^define('TIMEZONE', '$(cat /etc/timezone)');^" /usr/local/lib/z-push/autodiscover/config.php
 | 
				
			||||||
 | 
					
 | 
				
			||||||
mkdir -p /var/log/z-push
 | 
						# Some directories it will use.
 | 
				
			||||||
mkdir -p /var/lib/z-push
 | 
					 | 
				
			||||||
chmod 750 /var/log/z-push
 | 
					 | 
				
			||||||
chmod 750 /var/lib/z-push
 | 
					 | 
				
			||||||
chown www-data:www-data /var/log/z-push
 | 
					 | 
				
			||||||
chown www-data:www-data /var/lib/z-push
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Add log rotation
 | 
						mkdir -p /var/log/z-push
 | 
				
			||||||
 | 
						mkdir -p /var/lib/z-push
 | 
				
			||||||
 | 
						chmod 750 /var/log/z-push
 | 
				
			||||||
 | 
						chmod 750 /var/lib/z-push
 | 
				
			||||||
 | 
						chown www-data:www-data /var/log/z-push
 | 
				
			||||||
 | 
						chown www-data:www-data /var/lib/z-push
 | 
				
			||||||
 | 
					
 | 
				
			||||||
cat > /etc/logrotate.d/z-push <<EOF;
 | 
						# Add log rotation
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						cat > /etc/logrotate.d/z-push <<EOF;
 | 
				
			||||||
/var/log/z-push/*.log {
 | 
					/var/log/z-push/*.log {
 | 
				
			||||||
	weekly
 | 
						weekly
 | 
				
			||||||
	missingok
 | 
						missingok
 | 
				
			||||||
@ -98,10 +102,12 @@ cat > /etc/logrotate.d/z-push <<EOF;
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
EOF
 | 
					EOF
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Restart service.
 | 
						# Restart service.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
restart_service php$PHP_VER-fpm
 | 
						restart_service php$PHP_VER-fpm
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Fix states after upgrade
 | 
						# Fix states after upgrade
 | 
				
			||||||
 | 
					
 | 
				
			||||||
hide_output php$PHP_VER /usr/local/lib/z-push/z-push-admin.php -a fixstates
 | 
						hide_output php$PHP_VER /usr/local/lib/z-push/z-push-admin.php -a fixstates
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user