2014-10-20 20:20:24 +00:00
|
|
|
#!/bin/bash
|
2016-07-03 01:19:11 +00:00
|
|
|
# Webmail with Rainloop
|
2014-09-21 20:05:11 +00:00
|
|
|
# ----------------------
|
2013-09-07 20:53:25 +00:00
|
|
|
|
2014-06-03 11:12:38 +00:00
|
|
|
source setup/functions.sh # load our functions
|
2014-03-17 00:46:59 +00:00
|
|
|
source /etc/mailinabox.conf # load global vars
|
|
|
|
|
2016-07-01 05:32:00 +00:00
|
|
|
# ### Installing Rainloop
|
2014-09-21 20:05:11 +00:00
|
|
|
|
2016-07-01 05:32:00 +00:00
|
|
|
# Rainloop's webpage (http://www.rainloop.net/downloads/) does not easily #
|
2016-07-01 04:23:23 +00:00
|
|
|
# list versions as the need for VERSION_FILENAME below. #
|
|
|
|
|
|
|
|
#
|
|
|
|
# Dependancies are from Roundcube, not all may be needed for Rainloop #
|
2014-04-25 12:25:47 +00:00
|
|
|
|
2016-07-01 04:23:23 +00:00
|
|
|
echo "Installing Rainloop (webmail)..."
|
2014-05-01 19:13:00 +00:00
|
|
|
apt_install \
|
2016-07-01 04:23:23 +00:00
|
|
|
unzip \
|
2016-07-03 01:19:11 +00:00
|
|
|
php5 php5-mcrypt php5-cli php5-curl php5-sqlite php-net-sieve php5-common \
|
|
|
|
crudini
|
2015-11-05 11:03:34 +00:00
|
|
|
apt_get_quiet remove php-mail-mimedecode # no longer needed since Roundcube 1.1.3
|
2013-09-07 20:53:25 +00:00
|
|
|
|
2014-10-04 21:57:26 +00:00
|
|
|
# We used to install Roundcube from Ubuntu, without triggering the dependencies #NODOC
|
|
|
|
# on Apache and MySQL, by downloading the debs and installing them manually. #NODOC
|
|
|
|
# Now that we're beyond that, get rid of those debs before installing from source. #NODOC
|
|
|
|
apt-get purge -qq -y roundcube* #NODOC
|
2013-09-07 20:53:25 +00:00
|
|
|
|
2014-09-24 12:46:42 +00:00
|
|
|
# Install Roundcube from source if it is not already present or if it is out of date.
|
2015-03-08 19:02:49 +00:00
|
|
|
# Combine the Roundcube version number with the commit hash of vacation_sieve to track
|
|
|
|
# whether we have the latest version.
|
2016-07-01 04:23:23 +00:00
|
|
|
VERSION=v1.10.1.127
|
|
|
|
VERSION_FILENAME="rainloop-community-1.10.1.127-18d553ae9cd96eb102059b04fdee62e0.zip"
|
|
|
|
HASH=bf2b42c99a6d8be151e2c1dc3442604ca709e1ba
|
2016-07-01 04:31:03 +00:00
|
|
|
UPDATE_KEY=$VERSION
|
2014-09-24 12:46:42 +00:00
|
|
|
needs_update=0 #NODOC
|
2016-07-01 04:23:23 +00:00
|
|
|
if [ ! -f /usr/local/lib/rainloop/version ]; then
|
2014-10-04 21:57:26 +00:00
|
|
|
# not installed yet #NODOC
|
2014-09-24 12:46:42 +00:00
|
|
|
needs_update=1 #NODOC
|
2016-07-03 01:19:11 +00:00
|
|
|
first_install=1
|
2016-07-01 04:31:03 +00:00
|
|
|
elif [[ "$UPDATE_KEY" != "$(cat /usr/local/lib/rainloop/version)" ]]; then
|
2014-09-24 12:46:42 +00:00
|
|
|
# checks if the version is what we want
|
|
|
|
needs_update=1 #NODOC
|
|
|
|
fi
|
|
|
|
if [ $needs_update == 1 ]; then
|
2016-07-01 04:23:23 +00:00
|
|
|
# install rainloop
|
2015-04-11 19:21:38 +00:00
|
|
|
wget_verify \
|
2016-07-01 04:23:23 +00:00
|
|
|
https://github.com/RainLoop/rainloop-webmail/releases/download/$VERSION/$VERSION_FILENAME \
|
2015-04-11 19:21:38 +00:00
|
|
|
$HASH \
|
2016-07-01 04:23:23 +00:00
|
|
|
/tmp/rainloop.zip
|
|
|
|
# Per documentation, updates can overwrite existing files
|
|
|
|
unzip -q -o /tmp/rainloop.zip -d /usr/local/lib/rainloop
|
|
|
|
rm -f /tmp/rainloop.zip
|
2013-09-07 20:53:25 +00:00
|
|
|
|
2015-09-05 21:33:19 +00:00
|
|
|
|
2015-03-08 19:02:49 +00:00
|
|
|
# record the version we've installed
|
2016-07-01 04:23:23 +00:00
|
|
|
echo $UPDATE_KEY > /usr/local/lib/rainloop/version
|
2014-07-08 00:37:53 +00:00
|
|
|
fi
|
2013-09-07 20:53:25 +00:00
|
|
|
|
2016-07-01 04:23:23 +00:00
|
|
|
# ### Configuring Rainloop
|
2014-07-08 00:37:53 +00:00
|
|
|
|
2016-07-03 01:19:11 +00:00
|
|
|
# Create a configuration file.
|
2014-07-08 00:37:53 +00:00
|
|
|
#
|
2016-07-03 01:19:11 +00:00
|
|
|
|
|
|
|
# Some application paths are not created until the application is launched
|
|
|
|
# this should include the internal process it has when upgrading between versions
|
|
|
|
|
|
|
|
# Fix permissions
|
|
|
|
find /usr/local/lib/rainloop -type d -exec chmod 755 {} \;
|
|
|
|
find /usr/local/lib/rainloop -type f -exec chmod 644 {} \;
|
|
|
|
chown -R www-data:www-data /usr/local/lib/rainloop
|
|
|
|
|
|
|
|
# Fixing permissions needs to happen first or else curl gets
|
|
|
|
# this error: [105] Missing version directory
|
|
|
|
|
|
|
|
# works manually, not in cli?
|
|
|
|
/usr/bin/php /usr/local/lib/rainloop/index.php > /dev/null
|
|
|
|
|
|
|
|
|
|
|
|
if [ $first_install == 1 ]; then
|
|
|
|
|
|
|
|
# Set customized configuration
|
|
|
|
# Rainloop has a default password set, not sure yet how to integrate with userlist
|
2016-07-01 04:23:23 +00:00
|
|
|
# for now we should change it from the default
|
|
|
|
# Methods for changing password: https://github.com/RainLoop/rainloop-webmail/issues/28
|
|
|
|
#
|
2016-07-03 01:19:11 +00:00
|
|
|
# Using the Rainloop API:
|
|
|
|
random_admin_pw=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 8 | head -n 1)
|
2016-07-01 04:23:23 +00:00
|
|
|
|
2016-07-03 01:19:11 +00:00
|
|
|
echo "<?php
|
|
|
|
|
|
|
|
\$_ENV['RAINLOOP_INCLUDE_AS_API'] = true;
|
|
|
|
include '/usr/local/lib/rainloop/index.php';
|
|
|
|
|
|
|
|
\$oConfig = \RainLoop\Api::Config();
|
|
|
|
\$oConfig->SetPassword('$random_admin_pw');
|
|
|
|
echo \$oConfig->Save() ? 'Done' : 'Error';
|
|
|
|
|
|
|
|
?>" | /usr/bin/php
|
2016-07-01 04:23:23 +00:00
|
|
|
|
2016-07-03 01:19:11 +00:00
|
|
|
|
|
|
|
crudini --set --existing /usr/local/lib/rainloop/data/_data_/_default_/configs/application.ini \
|
|
|
|
contacts enable On
|
|
|
|
crudini --set --existing /usr/local/lib/rainloop/data/_data_/_default_/configs/application.ini \
|
|
|
|
contacts allow_sync On
|
|
|
|
crudini --set --existing /usr/local/lib/rainloop/data/_data_/_default_/configs/application.ini \
|
|
|
|
login determine_user_domain On
|
|
|
|
crudini --set --existing /usr/local/lib/rainloop/data/_data_/_default_/configs/application.ini \
|
|
|
|
login default_domain $PRIMARY_HOSTNAME
|
|
|
|
|
|
|
|
# Disable google imap login in Rainloop
|
|
|
|
echo -n ",gmail.com" >> /usr/local/lib/rainloop/data/_data_/_default_/domains/disabled
|
2014-07-08 00:37:53 +00:00
|
|
|
|
2016-07-01 04:23:23 +00:00
|
|
|
# Add localhost imap/smtp
|
2016-07-03 01:19:11 +00:00
|
|
|
|
2016-07-01 04:23:23 +00:00
|
|
|
cat > /usr/local/lib/rainloop/data/_data_/_default_/domains/default.ini <<EOF;
|
|
|
|
imap_host = "127.0.0.1"
|
|
|
|
imap_port = 993
|
|
|
|
imap_secure = "SSL"
|
|
|
|
imap_short_login = Off
|
|
|
|
sieve_use = On
|
|
|
|
sieve_allow_raw = Off
|
|
|
|
sieve_host = "127.0.0.1"
|
|
|
|
sieve_port = 4190
|
|
|
|
sieve_secure = "None"
|
|
|
|
smtp_host = "127.0.0.1"
|
|
|
|
smtp_port = 587
|
|
|
|
smtp_secure = "TLS"
|
|
|
|
smtp_short_login = Off
|
|
|
|
smtp_auth = On
|
|
|
|
smtp_php_mail = Off
|
2015-02-21 15:01:27 +00:00
|
|
|
EOF
|
|
|
|
|
2016-07-03 01:19:11 +00:00
|
|
|
|
2016-07-01 04:23:23 +00:00
|
|
|
# Fix permissions after editing configs
|
|
|
|
|
|
|
|
find /usr/local/lib/rainloop -type d -exec chmod 755 {} \;
|
|
|
|
find /usr/local/lib/rainloop -type f -exec chmod 644 {} \;
|
|
|
|
chown -R www-data:www-data /usr/local/lib/rainloop
|
2016-06-02 11:47:32 +00:00
|
|
|
|
2016-07-03 01:19:11 +00:00
|
|
|
fi
|
|
|
|
|
2014-04-18 00:17:24 +00:00
|
|
|
# Enable PHP modules.
|
|
|
|
php5enmod mcrypt
|
2014-08-12 11:00:54 +00:00
|
|
|
restart_service php5-fpm
|
2016-07-01 04:23:23 +00:00
|
|
|
|
|
|
|
# remove Roundcube
|
2016-07-02 05:49:30 +00:00
|
|
|
rm -rf /usr/local/lib/roundcube
|