From 74d9e21092e5c2ab284a951daa417f7758d82e27 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 30 Jun 2016 21:23:23 -0700 Subject: [PATCH] Inital commit for Rainloop to replace Roundcube --- conf/nginx-alldomains.conf | 8 +- setup/webmail.sh | 546 +++++++++++++++++++++++++++++-------- 2 files changed, 432 insertions(+), 122 deletions(-) diff --git a/conf/nginx-alldomains.conf b/conf/nginx-alldomains.conf index 995745e4..199a7f87 100644 --- a/conf/nginx-alldomains.conf +++ b/conf/nginx-alldomains.conf @@ -19,14 +19,14 @@ alias /var/lib/mailinabox/mozilla-autoconfig.xml; } - # Roundcube Webmail configuration. + # Rainloop Webmail configuration. rewrite ^/mail$ /mail/ redirect; rewrite ^/mail/$ /mail/index.php; location /mail/ { index index.php; - alias /usr/local/lib/roundcubemail/; + alias /usr/local/lib/rainloop/; } - location ~ /mail/config/.* { + location ~ /mail/data/.* { # A ~-style location is needed to give this precedence over the next block. return 403; } @@ -35,7 +35,7 @@ include fastcgi_params; fastcgi_split_path_info ^/mail(/.*)()$; fastcgi_index index.php; - fastcgi_param SCRIPT_FILENAME /usr/local/lib/roundcubemail/$fastcgi_script_name; + fastcgi_param SCRIPT_FILENAME /usr/local/lib/rainloop/$fastcgi_script_name; fastcgi_pass php-fpm; # Outgoing mail also goes through this endpoint, so increase the maximum diff --git a/setup/webmail.sh b/setup/webmail.sh index bf29c6ab..420888dd 100755 --- a/setup/webmail.sh +++ b/setup/webmail.sh @@ -5,23 +5,18 @@ source setup/functions.sh # load our functions source /etc/mailinabox.conf # load global vars -# ### Installing Roundcube +# ### Installing Roundloop -# We install Roundcube from sources, rather than from Ubuntu, because: -# -# 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. +# Roundloop's webpage (http://www.rainloop.net/downloads/) does not easily # +# list versions as the need for VERSION_FILENAME below. # -# These dependencies are from `apt-cache showpkg roundcube-core`. -echo "Installing Roundcube (webmail)..." +# +# Dependancies are from Roundcube, not all may be needed for Rainloop # + +echo "Installing Rainloop (webmail)..." apt_install \ dbconfig-common \ + unzip \ php5 php5-sqlite php5-mcrypt php5-intl php5-json php5-common php-auth php-net-smtp php-net-socket php-net-sieve php-mail-mime php-crypt-gpg php5-gd php5-pspell \ tinymce libjs-jquery libjs-jquery-mousewheel libmagic1 apt_get_quiet remove php-mail-mimedecode # no longer needed since Roundcube 1.1.3 @@ -34,14 +29,12 @@ apt-get purge -qq -y roundcube* #NODOC # 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 vacation_sieve to track # whether we have the latest version. -VERSION=1.2.0 -HASH=2088985fb613b4e4e3373933ca44b26fce0489fb -VACATION_SIEVE_VERSION=91ea6f52216390073d1f5b70b5f6bea0bfaee7e5 -PERSISTENT_LOGIN_VERSION=1e9d724476a370ce917a2fcd5b3217b0c306c24e -HTML5_NOTIFIER_VERSION=4b370e3cd60dabd2f428a26f45b677ad1b7118d5 -UPDATE_KEY=$VERSION:$VACATION_SIEVE_VERSION:$PERSISTENT_LOGIN_VERSION:$HTML5_NOTIFIER_VERSION:a +VERSION=v1.10.1.127 +VERSION_FILENAME="rainloop-community-1.10.1.127-18d553ae9cd96eb102059b04fdee62e0.zip" +HASH=bf2b42c99a6d8be151e2c1dc3442604ca709e1ba +UPDATE_KEY=$VERSION:a needs_update=0 #NODOC -if [ ! -f /usr/local/lib/roundcubemail/version ]; then +if [ ! -f /usr/local/lib/rainloop/version ]; then # not installed yet #NODOC needs_update=1 #NODOC elif [[ "$UPDATE_KEY" != `cat /usr/local/lib/roundcubemail/version` ]]; then @@ -49,120 +42,437 @@ elif [[ "$UPDATE_KEY" != `cat /usr/local/lib/roundcubemail/version` ]]; then needs_update=1 #NODOC fi if [ $needs_update == 1 ]; then - # install roundcube + # install rainloop wget_verify \ - https://github.com/roundcube/roundcubemail/releases/download/$VERSION/roundcubemail-$VERSION.tar.gz \ + https://github.com/RainLoop/rainloop-webmail/releases/download/$VERSION/$VERSION_FILENAME \ $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/ /usr/local/lib/roundcubemail - rm -f /tmp/roundcube.tgz + /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 - # install roundcube autoreply/vacation plugin - git_clone https://github.com/arodier/Roundcube-Plugins.git $VACATION_SIEVE_VERSION plugins/vacation_sieve /usr/local/lib/roundcubemail/plugins/vacation_sieve - - # install roundcube persistent_login plugin - git_clone https://github.com/mfreiholz/Roundcube-Persistent-Login-Plugin.git $PERSISTENT_LOGIN_VERSION '' /usr/local/lib/roundcubemail/plugins/persistent_login - - # install roundcube html5_notifier plugin - git_clone https://github.com/kitist/html5_notifier.git $HTML5_NOTIFIER_VERSION '' /usr/local/lib/roundcubemail/plugins/html5_notifier # record the version we've installed - echo $UPDATE_KEY > /usr/local/lib/roundcubemail/version + echo $UPDATE_KEY > /usr/local/lib/rainloop/version fi -# ### Configuring Roundcube - -# Generate a safe 24-character secret key of safe characters. -SECRET_KEY=$(dd if=/dev/urandom bs=1 count=18 2>/dev/null | base64 | fold -w 24 | head -n 1) +# ### Configuring Rainloop # Create a configuration file. # -# 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 > /usr/local/lib/roundcubemail/config/config.inc.php < + +# 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 + +curl -s -L https://$PRIMARY_HOSTNAME/mail/ > /dev/null + + +# Set customized configuration +# Rainloop has a default password set, not sure yet how to integrate with userlist +# for now we should change it from the default +# Methods for changing password: https://github.com/RainLoop/rainloop-webmail/issues/28 +# +# Untested: edit admin_password = "????" below +# +# or use the Rainloop API: +# /index.php'; +# +# $oConfig = \RainLoop\Api::Config(); +# $oConfig->SetPassword('pa$$wOrd'); +# echo $oConfig->Save() ? 'Done' : 'Error'; +# +# ?> + +# This can be improved, need to take a look at editconf.py for multi line edits as +# there are multiple "enable = On" but we should only edit them per category. + +cat > /usr/local/lib/rainloop/data/_data_/_default_/configs/application.ini < /usr/local/lib/roundcubemail/plugins/vacation_sieve/config.inc.php < 'd/m/Y', - 'working_hours' => array(8,18), - 'msg_format' => 'text', - 'logon_transform' => array('#([a-z])[a-z]+(\.|\s)([a-z])#i', '\$1\$3'), - 'transfer' => array( - 'mode' => 'managesieve', - 'ms_activate_script' => true, - 'host' => '127.0.0.1', - 'port' => '4190', - 'usetls' => false, - 'path' => 'vacation', - ) -); +# Add localhost imap/smtp + +cat > /usr/local/lib/rainloop/data/_data_/_default_/domains/default.ini <