Преглед изворни кода

[Feature] Rainloop + Flexible Webmail client support (#1548)

* Add rainloop support to Hestia 
Default activated plugins:
- add-x-originating-ip-header (from rainloop github)
-hestia-change-password (from local source)
Changes made:
- Change default admin username 
- Change default admin password
- Change default admin key
- Enabled contacts / adressbook via mysql on default
- Enabled the plugins listed + set up default settings

File get created in ~/.rainloop with the default login data!

* Update readme + hide output message

* Add upgrade routine rainloop + fix for roundcube

* Add webinterface for switching
CLI for switching 
Minor bug fixes

* Add “Webmail” template to v-rebuild-mail-domain
Jaap Marcus пре 5 година
родитељ
комит
970dc0e58e
33 измењених фајлова са 912 додато и 34 уклоњено
  1. 2 2
      bin/v-add-mail-domain
  2. 165 0
      bin/v-add-sys-rainloop
  3. 6 4
      bin/v-add-sys-roundcube
  4. 39 12
      bin/v-add-sys-webmail
  5. 2 0
      bin/v-delete-sys-webmail
  6. 6 4
      bin/v-list-mail-domain
  7. 6 4
      bin/v-list-mail-domains
  8. 1 0
      bin/v-list-sys-config
  9. 80 0
      bin/v-list-sys-webmail
  10. 2 1
      bin/v-rebuild-mail-domain
  11. 22 3
      func/upgrade.sh
  12. 23 0
      install/deb/rainloop/change_password.php
  13. 16 0
      install/deb/rainloop/default.ini
  14. 146 0
      install/deb/rainloop/plugins/hestia-change-password/HestiaChangePasswordDriver.php
  15. 20 0
      install/deb/rainloop/plugins/hestia-change-password/LICENSE
  16. 3 0
      install/deb/rainloop/plugins/hestia-change-password/README
  17. 1 0
      install/deb/rainloop/plugins/hestia-change-password/VERSION
  18. 55 0
      install/deb/rainloop/plugins/hestia-change-password/index.php
  19. 3 0
      install/deb/rainloop/plugins/plugin-add-x-originating-ip-header.ini
  20. 4 0
      install/deb/rainloop/plugins/plugin-hestia-change-password.ini
  21. 31 0
      install/deb/templates/mail/apache2/rainloop.stpl
  22. 25 0
      install/deb/templates/mail/apache2/rainloop.tpl
  23. 38 0
      install/deb/templates/mail/nginx/default_rainloop.stpl
  24. 40 0
      install/deb/templates/mail/nginx/default_rainloop.tpl
  25. 45 0
      install/deb/templates/mail/nginx/rainloop.stpl
  26. 42 0
      install/deb/templates/mail/nginx/rainloop.tpl
  27. 1 1
      install/deb/templates/web/php-fpm/default.tpl
  28. 6 1
      install/upgrade/upgrade.conf
  29. 6 0
      src/deb/hestia/postinst
  30. 20 2
      web/add/mail/index.php
  31. 14 0
      web/edit/mail/index.php
  32. 21 0
      web/templates/admin/add_mail.html
  33. 21 0
      web/templates/admin/edit_mail.html

+ 2 - 2
bin/v-add-mail-domain

@@ -72,7 +72,7 @@ fi
 new_timestamp
 
 # Adding domain to mail.conf
-s="DOMAIN='$domain' ANTIVIRUS='$antivirus' ANTISPAM='$antispam' DKIM='$dkim'"
+s="DOMAIN='$domain' ANTIVIRUS='$antivirus' ANTISPAM='$antispam' DKIM='$dkim' WEBMAIL=''"
 s="$s SSL='no' LETSENCRYPT='no' CATCHALL='' ACCOUNTS='0' U_DISK='0' SUSPENDED='no' TIME='$time'"
 s="$s DATE='$date'"
 echo $s >> $USER_DATA/mail.conf
@@ -169,7 +169,7 @@ fi
 # Add webmail configuration to mail domain
 if [ ! -z "$WEB_SYSTEM" ] || [ ! -z "$PROXY_SYSTEM" ]; then
     if [ ! -z "$IMAP_SYSTEM" ]; then
-        $BIN/v-add-sys-webmail $user $domain ''
+        $BIN/v-add-sys-webmail $user $domain '' ''
     fi
 fi
     

+ 165 - 0
bin/v-add-sys-rainloop

@@ -0,0 +1,165 @@
+#!/bin/bash
+# info: Install Rainloop in HestiaCP
+# options: [MODE]
+# labels: hestia
+#
+# The function installs Rainloop
+
+#----------------------------------------------------------#
+#                    Variable&Function                     #
+#----------------------------------------------------------#
+
+# Includes
+source $HESTIA/func/main.sh
+source $HESTIA/conf/hestia.conf
+source $HESTIA/install/upgrade/upgrade.conf
+
+MODE=$2
+UPDATE="no"
+# Version and Download paths
+# Version to be moved to upgrade script
+RL_FILE="rainloop-community-latest.zip"
+# For removal of folder
+RL_EXTRACT_MAIN="rainloop"
+
+# Downloading full version
+RL_URL="https://www.rainloop.net/repository/webmail/rainloop-community-latest.zip"
+
+# Folder paths
+RL_INSTALL_DIR="/var/lib/rainloop"
+RL_CONFIG_DIR="/etc/rainloop"
+RL_LOG="/var/log/rainloop"
+
+#----------------------------------------------------------#
+#                    Verifications                         #
+#----------------------------------------------------------#
+
+# Checking root permissions
+if [ "x$(id -u)" != 'x0' ]; then
+    echo "ERROR: v-add-sys-rainloop can be run executed only by root user"
+    exit 10
+fi
+
+# Ensure that $HESTIA (/usr/local/hestia/) and other variables are valid.
+if [ -z "$HESTIA" ]; then
+    HESTIA="/usr/local/hestia"
+fi
+
+if [ -z "$HOMEDIR" ] || [ -z "$HESTIA_INSTALL_DIR" ]; then
+    echo "ERROR: Environment variables not present, installation aborted."
+    exit 2
+fi
+
+# Get current version 
+if [ -f "/var/lib/rainloop/data/VERSION" ]; then
+    version=$(cat $RL_INSTALL_DIR/data/VERSION);
+    if [ "$version" == "$rl_v" ]; then
+        echo "Error: Installed version ($version) is equal as the availble version ($rc_v)"
+        exit 2;
+    else 
+        UPDATE="yes"
+    fi
+fi
+
+# Perform verification if read-only mode is enabled
+check_hestia_demo_mode
+
+#----------------------------------------------------------#
+#                       Action                             #
+#----------------------------------------------------------#
+
+if [ "$UPDATE" == "no" ]; then
+    rm -f -r $RL_INSTALL_DIR
+    rm -f -r $RL_CONFIG_DIR
+
+    mkdir $RL_INSTALL_DIR
+    mkdir $RL_CONFIG_DIR
+    
+    cd "$RL_INSTALL_DIR"
+    [ ! -f "${RC_INSTALL_DIR}/${RC_FILE}" ] && wget "$RL_URL" --quiet -O "${RL_INSTALL_DIR}/${RL_FILE}"
+    
+    key=$(openssl rand -hex 4);
+    
+    admin_account="admin_$key"
+    admin_password=$(generate_password)
+    r=$(generate_password)
+
+    echo "Username: admin_$key" > ~/.rainloop
+    echo "Password: $admin_password" >> ~/.rainloop
+    echo "Secret key: admin_$key" >> ~/.rainloop
+    
+    unzip -q $RL_FILE
+    
+    mv ./data $RL_CONFIG_DIR/
+    ln -s $RL_CONFIG_DIR/data/ ./data
+
+    SALT=$(openssl rand -base64 64)
+    cp ./data/VERSION ./data/INSTALLED
+    echo "<?php //$SALT" >  ./data/SALT.php
+    echo "Forbidden" >  ./data/index.php
+    echo "Forbidden" >  ./data/index.html
+
+    # Create database
+    mysql -e "DROP DATABASE rainloop"
+    mysql -e "DROP USER rainloop@localhost"
+    mysql -e "CREATE DATABASE rainloop"
+    # Mysql available on system
+    r=$(generate_password)
+    mysql -e "GRANT ALL ON rainloop.*
+     TO rainloop@localhost IDENTIFIED BY '$r'"
+
+    mkdir -p $RL_CONFIG_DIR/data/_data_/_default_/configs
+    php -f $HESTIA_INSTALL_DIR/rainloop/change_password.php "admin_$key" "$admin_password" "$r"
+    mkdir -p $RL_CONFIG_DIR/data/_data_/_default_/domains
+    cp -f $HESTIA_INSTALL_DIR/rainloop/default.ini $RL_CONFIG_DIR/data/_data_/_default_/domains
+    mkdir -p $RL_CONFIG_DIR/data/_data_/_default_/plugins
+    cp -f -r $HESTIA_INSTALL_DIR/rainloop/plugins/hestia-change-password/ $RL_CONFIG_DIR/data/_data_/_default_/plugins
+    mkdir -p $RL_CONFIG_DIR/data/_data_/_default_/plugins/add-x-originating-ip-header
+    # Download add-x-originating-ip-header from rainloop github
+    wget --quiet -O $RL_CONFIG_DIR/data/_data_/_default_/plugins/add-x-originating-ip-header/index.php https://raw.githubusercontent.com/RainLoop/rainloop-webmail/master/plugins/add-x-originating-ip-header/index.php
+    wget --quiet -O $RL_CONFIG_DIR/data/_data_/_default_/plugins/add-x-originating-ip-header/VERSION https://raw.githubusercontent.com/RainLoop/rainloop-webmail/master/plugins/add-x-originating-ip-header/VERSION
+    wget --quiet -O $RL_CONFIG_DIR/data/_data_/_default_/plugins/add-x-originating-ip-header/README https://raw.githubusercontent.com/RainLoop/rainloop-webmail/master/plugins/add-x-originating-ip-header/README
+    wget --quiet -O $RL_CONFIG_DIR/data/_data_/_default_/plugins/add-x-originating-ip-header/LICENSE https://raw.githubusercontent.com/RainLoop/rainloop-webmail/master/plugins/add-x-originating-ip-header/LICENSE
+    
+    cp -f $HESTIA_INSTALL_DIR/rainloop/plugins/plugin-add-x-originating-ip-header.ini $RL_CONFIG_DIR/data/_data_/_default_/configs/plugin-add-x-originating-ip-header.ini
+    cp -f $HESTIA_INSTALL_DIR/rainloop/plugins/plugin-hestia-change-password.ini $RL_CONFIG_DIR/data/_data_/_default_/configs/plugin-hestia-change-password.ini
+    
+    sed -i "s/%hostname%/$(hostname)/g" $RL_CONFIG_DIR/data/_data_/_default_/configs/plugin-hestia-change-password.ini
+    sed -i "s/%port%/$BACKEND_PORT/g" $RL_CONFIG_DIR/data/_data_/_default_/configs/plugin-hestia-change-password.ini
+    
+    
+    chown -R  www-data:www-data ./data
+    chown -R  www-data:www-data $RL_CONFIG_DIR/
+    
+    rm  ${RL_INSTALL_DIR}/${RL_FILE}  
+    # Add robots.txt
+    echo "User-agent: *" > $RL_INSTALL_DIR/robots.txt
+    echo "Disallow: /" >> $RL_INSTALL_DIR/robots.txt
+    
+    # Updating hestia.conf
+    if [ -z "$(grep WEBMAIL_SYSTEM $HESTIA/conf/hestia.conf)" ]; then
+        $BIN/v-change-sys-config-value 'WEBMAIL_SYSTEM' 'rainloop'
+    else
+        if [  -z "$(echo "$WEBMAIL_SYSTEM" | grep -w 'rainloop')" ]; then
+           if [ ! -z "$WEBMAIL_SYSTEM" ]; then
+               $BIN/v-change-sys-config-value 'WEBMAIL_SYSTEM' "rainloop,$WEBMAIL_SYSTEM"
+           else
+               $BIN/v-change-sys-config-value 'WEBMAIL_SYSTEM' "rainloop"
+           fi
+        fi
+    fi
+
+else
+   [ ! -f "${RC_INSTALL_DIR}/${RC_FILE}" ] && wget "$RL_URL" --quiet -O "${RL_INSTALL_DIR}/${RL_FILE}"
+   unzip -q -o $RL_FILE
+   rm $RL_INSTALL_DIR/$RL_FILE
+fi
+
+#----------------------------------------------------------#
+#                       Logging                            #
+#----------------------------------------------------------#
+
+
+
+log_history "Rouncube successfuly installed" '' 'admin'
+log_event "$OK" "$ARGUMENTS"

+ 6 - 4
bin/v-add-sys-roundcube

@@ -152,10 +152,12 @@ if [ "$UPDATE" == "no" ]; then
     if [ -z "$(grep WEBMAIL_SYSTEM $HESTIA/conf/hestia.conf)" ]; then
         $BIN/v-change-sys-config-value 'WEBMAIL_SYSTEM' 'roundcube'
     else
-        if [ -z "$(echo "$WEBMAIL_SYSTEM" | grep -w 'roundcube')" ]; then
-            $BIN/v-change-sys-config-value 'WEBMAIL_SYSTEM' "roundcube"
-        else
-            $BIN/v-change-sys-config-value 'WEBMAIL_SYSTEM' "roundcube,$WEBMAIL_SYSTEM"
+        if [  -z "$(echo "$WEBMAIL_SYSTEM" | grep -w 'roundcube')" ]; then
+           if [ ! -z "$WEBMAIL_SYSTEM" ]; then
+               $BIN/v-change-sys-config-value 'WEBMAIL_SYSTEM' "roundcube,$WEBMAIL_SYSTEM"
+           else
+               $BIN/v-change-sys-config-value 'WEBMAIL_SYSTEM' "roundcube"
+           fi
         fi
     fi
     

+ 39 - 12
bin/v-add-sys-webmail

@@ -1,6 +1,6 @@
 #!/bin/bash
 # info: add webmail support for a domain
-# options: USER DOMAIN [RESTART] [QUIET]
+# options: USER DOMAIN WEBMAIL [RESTART] [QUIET]
 # labels: hestia
 #
 # example: v-add-sys-webmail user domain.com
@@ -15,8 +15,9 @@
 # Argument definition
 user=$1
 domain=$2
-restart="$3"
-quiet=$4
+webmail=$3
+restart="$4"
+quiet=$5
 
 # Additional argument formatting
 if [[ "$domain" =~ [[:upper:]] ]]; then
@@ -46,10 +47,17 @@ format_domain_idn
 #                    Verifications                         #
 #----------------------------------------------------------#
 
-check_args '2' "$#" 'USER DOMAIN [RESTART]'
+if [ -z "$webmail" ]; then
+    for client in ${WEBMAIL_SYSTEM//,/ };do
+        webmail="$client"
+    done
+fi
+
+check_args '3' "$#" 'USER DOMAIN WEBMAIL [RESTART]'
 is_format_valid 'user' 'domain'
 is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM'
 is_system_enabled "$IMAP_SYSTEM" 'IMAP_SYSTEM'
+is_type_valid "$WEBMAIL_SYSTEM" "$webmail"
 is_object_valid 'user' 'USER' "$user"
 is_object_unsuspended 'user' 'USER' "$user"
 is_object_valid 'mail' 'DOMAIN' "$domain"
@@ -95,16 +103,28 @@ else
             fi
         fi
     fi
-
-    # Add webmail configuration to mail domain
-    WEBMAIL_TEMPLATE="default"
-    if [ "$WEB_SYSTEM" = "nginx" ]; then
-        WEBMAIL_TEMPLATE="web_system"
+    
+    if [ "$webmail" == "roundcube" ]; then
+        WEBMAIL_TEMPLATE="default"
+        if [ ! -z "$PROXY_SYSTEM" ]; then
+            PROXY_TEMPLATE="default"
+        fi
+        # Add webmail configuration to mail domain
+        WEBMAIL_TEMPLATE="default"
+        if [ "$WEB_SYSTEM" = "nginx" ]; then
+            WEBMAIL_TEMPLATE="web_system"
+        fi
+    else
+        WEBMAIL_TEMPLATE="rainloop"
+        if [ ! -z "$PROXY_SYSTEM" ]; then
+            PROXY_TEMPLATE="default_rainloop"
+        fi
     fi
+    
     add_webmail_config "$WEB_SYSTEM" "${WEBMAIL_TEMPLATE}.tpl"
 
     if [ ! -z "$PROXY_SYSTEM" ]; then
-        add_webmail_config "$PROXY_SYSTEM" "default.tpl"
+        add_webmail_config "$PROXY_SYSTEM" "${PROXY_TEMPLATE}.tpl"
     fi
 
     # Enable SSL for webmail if available
@@ -112,16 +132,23 @@ else
         add_webmail_config "$WEB_SYSTEM" "${WEBMAIL_TEMPLATE}.stpl"
 
         if [ ! -z "$PROXY_SYSTEM" ]; then
-            add_webmail_config "$PROXY_SYSTEM" "default.stpl"
+            add_webmail_config "$PROXY_SYSTEM" "${PROXY_TEMPLATE}.stpl"
         fi
     fi
 fi
 
+WEBMAIL=$(get_object_value 'web' 'DOMAIN' "$domain" "$WEBMAIL")
+if [ -z "$WEBMAIL" ]; then
+    add_object_key 'mail' 'DOMAIN' "$domain" 'WEBMAIL' 'SSL'
+fi
+
+# Set SSL as enabled in configuration
+update_object_value 'mail' 'DOMAIN' "$domain" '$WEBMAIL' "$webmail"
 #----------------------------------------------------------#
 #                       Hestia                             #
 #----------------------------------------------------------#
 
-if [ "$3" = 'yes' ]; then 
+if [ "$restart" = 'yes' ]; then 
     # Restarting web server
     $BIN/v-restart-web $restart
     check_result $? "Web restart failed" >/dev/null

+ 2 - 0
bin/v-delete-sys-webmail

@@ -68,6 +68,8 @@ else
     echo "Error: WEBMAIL_ALIAS is not defined in hestia.conf."
 fi
 
+# Set SSL as enabled in configuration
+update_object_value 'mail' 'DOMAIN' "$domain" '$WEBMAIL' ""
 #----------------------------------------------------------#
 #                       Hestia                              #
 #----------------------------------------------------------#

+ 6 - 4
bin/v-list-mail-domain

@@ -37,7 +37,8 @@ json_list() {
         "SUSPENDED": "'$SUSPENDED'",
         "TIME": "'$TIME'",
         "DATE": "'$DATE'",
-        "WEBMAIL_ALIAS": "'$WEBMAIL_ALIAS.$domain'"
+        "WEBMAIL_ALIAS": "'$WEBMAIL_ALIAS.$domain'",
+        "WEBMAIL":"'$WEBMAIL'"
         }'
     echo '}'
 }
@@ -57,20 +58,21 @@ shell_list() {
     echo "TIME:           $TIME"
     echo "DATE:           $DATE"
     echo "WEBMAIL_ALIAS:  $WEBMAIL_ALIAS.$domain"
+    echo "WEBMAIL:        $WEBMAIL"
 }
 
 # PLAIN list function
 plain_list() {
     echo -ne "$DOMAIN\t$ANTIVIRUS\t$ANTISPAM\t$DKIM\t$CATCHALL\t"
-    echo -e "$ACCOUNTS\t$U_DISK\t$SSL\t$LETSENCRYPT\t$SUSPENDED\t$TIME\t$DATE\t$WEBMAIL_ALIAS.$domain"
+    echo -e "$ACCOUNTS\t$U_DISK\t$SSL\t$LETSENCRYPT\t$SUSPENDED\t$TIME\t$DATE\t$WEBMAIL_ALIAS.$domain\t$WEBMAIL"
 }
 
 # CSV list function
 csv_list() {
     echo -n "DOMAIN,ANTIVIRUS,ANTISPAM,DKIM,CATCHALL,ACCOUNTS,U_DISK,"
-    echo "SSL,LETSENCRYPT,SUSPENDED,TIME,DATE"
+    echo "SSL,LETSENCRYPT,SUSPENDED,TIME,DATE,WEBMAIL_ALIAS,WEBMAIL"
     echo -n "$DOMAIN,$ANTIVIRUS,$ANTISPAM,$DKIM,$CATCHALL,$ACCOUNTS,$U_DISK"
-    echo "$SSL,$LETSENCRYPT,$SUSPENDED,$TIME,$DATE,$WEBMAIL_ALIAS.$domain"
+    echo "$SSL,$LETSENCRYPT,$SUSPENDED,$TIME,$DATE,$WEBMAIL_ALIAS.$domain,$WEBMAIL"
 }
 
 

+ 6 - 4
bin/v-list-mail-domains

@@ -37,7 +37,9 @@ json_list() {
         "SSL": "'$SSL'",
         "SUSPENDED": "'$SUSPENDED'",
         "TIME": "'$TIME'",
-        "DATE": "'$DATE'"
+        "DATE": "'$DATE'",
+        "WEBMAIL_ALIAS": "'$WEBMAIL_ALIAS'",
+        "WEBMAIL": "'$WEBMAIL'"
     }'
         if [ "$i" -lt "$objects" ]; then
             echo ','
@@ -67,7 +69,7 @@ plain_list() {
     while read str; do
         parse_object_kv_list "$str"
         echo -ne "$DOMAIN\t$ANTIVIRUS\t$ANTISPAM\t$DKIM\t$SSL\$CATCHALL\t"
-        echo -e "$ACCOUNTS\t$U_DISK\t$SUSPENDED\t$TIME\t$DATE"
+        echo -e "$ACCOUNTS\t$U_DISK\t$SUSPENDED\t$TIME\t$DATE\t$WEBMAIL_ALIAS\t$WEBMAIL"
     done < <(cat $USER_DATA/mail.conf)
 }
 
@@ -75,11 +77,11 @@ plain_list() {
 csv_list() {
     IFS=$'\n'
     echo -n "DOMAIN,ANTIVIRUS,ANTISPAM,DKIM,SSL,CATCHALL,ACCOUNTS,U_DISK,"
-    echo "SUSPENDED,TIME,DATE"
+    echo "SUSPENDED,TIME,DATE,WEBMAIL_ALIAS,WEBMAIL"
     while read str; do
         parse_object_kv_list "$str"
         echo -n "$DOMAIN,$ANTIVIRUS,$ANTISPAM,$DKIM,$SSL,$CATCHALL,$ACCOUNTS,"
-        echo "'$U_DISK,$SUSPENDED,$TIME,$DATE"
+        echo "'$U_DISK,$SUSPENDED,$TIME,$DATE,$WEBMAIL_ALIAS,$WEBMAIL"
         echo
     done < <(cat $USER_DATA/mail.conf)
 }

+ 1 - 0
bin/v-list-sys-config

@@ -58,6 +58,7 @@ json_list() {
         "BACKUP": "'$BACKUP'",
         "BACKUP_MODE": "'$BACKUP_MODE'",
         "WEBMAIL_ALIAS": "'$WEBMAIL_ALIAS'",
+        "WEBMAIL_SYSTEM": "'$WEBMAIL_SYSTEM'",
         "DB_PMA_ALIAS": "'$DB_PMA_ALIAS'",
         "DB_PGA_ALIAS": "'$DB_PGA_ALIAS'",
         "LOGIN_STYLE": "'$LOGIN_STYLE'",

+ 80 - 0
bin/v-list-sys-webmail

@@ -0,0 +1,80 @@
+#!/bin/bash
+# info: listing available webmail clients
+# options: [FORMAT]
+# labels: hestia mail
+#
+# example: v-list-sys-webmail
+#
+# List available webmail clients
+
+
+#----------------------------------------------------------#
+#                    Variable&Function                     #
+#----------------------------------------------------------#
+
+# Argument definition
+format=${1-shell}
+
+# Includes
+source $HESTIA/func/main.sh
+source $HESTIA/conf/hestia.conf
+
+# JSON list function
+json_list() {
+    i=1
+    objects=$(echo -e "${WEBMAIL_SYSTEM//,/\\n}" |wc -l)
+    echo '['
+    for client in ${WEBMAIL_SYSTEM//,/ };do
+        if [ "$i" -ne "$objects" ]; then
+            echo -e  "\t\"$client\","
+        else
+            echo -e  "\t\"$client\""
+        fi
+        (( ++i))
+    done
+    echo ']'  
+}
+
+# SHELL list function
+shell_list() {
+    echo "Webmail Client"
+    echo "--------"
+    for client in ${WEBMAIL_SYSTEM//,/ };do
+        echo "$client"
+    done
+}
+
+# PLAIN list function
+plain_list() {
+    for client in ${WEBMAIL_SYSTEM//,/ };do
+        echo "$client"
+    done
+}
+
+# CSV list function
+csv_list() {
+    echo "CLIENT"
+    for client in ${WEBMAIL_SYSTEM//,/ };do
+        echo "$client"
+    done
+}
+
+
+#----------------------------------------------------------#
+#                       Action                             #
+#----------------------------------------------------------#
+
+# Listing data
+case $format in
+    json)   json_list ;;
+    plain)  plain_list ;;
+    csv)    csv_list ;;
+    shell)  shell_list ;;
+esac
+
+
+#----------------------------------------------------------#
+#                       Hestia                             #
+#----------------------------------------------------------#
+
+exit

+ 2 - 1
bin/v-rebuild-mail-domain

@@ -57,8 +57,9 @@ rebuild_mail_domain_conf
 # Rebuild webmail configuration
 if [ ! -z "$WEB_SYSTEM" ] || [ ! -z "$PROXY_SYSTEM" ]; then
     if [ ! -z "$IMAP_SYSTEM" ]; then
+        WEBMAIL=$(get_object_value 'web' 'DOMAIN' "$domain" "$WEBMAIL")
         $BIN/v-delete-sys-webmail $user $domain '' 'yes'
-        $BIN/v-add-sys-webmail $user $domain '' 'yes'
+        $BIN/v-add-sys-webmail $user $domain $WEBMAIL '' 'yes'
     fi
 fi
 

+ 22 - 3
func/upgrade.sh

@@ -126,9 +126,16 @@ upgrade_health_check() {
         echo "[ ! ] Adding missing variable to hestia.conf: LOGIN_STYLE ('default')"
         $BIN/v-change-sys-config-value "LOGIN_STYLE" "default"
     fi
+    
+    # Webmail clients
     if [ -z "$WEBMAIL_SYSTEM" ]; then
-        echo "[ ! ] Adding missing variable to hestia.conf: WEBMAIL_SYSTEM ('')"
-        $BIN/v-change-sys-config-value "WEBMAIL_SYSTEM" ""
+        if [ -d "/var/lib/roundcube" ]; then 
+            echo "[ ! ] Adding missing variable to hestia.conf: WEBMAIL_SYSTEM ('roundcube')"
+            $BIN/v-change-sys-config-value "WEBMAIL_SYSTEM" "roundcube"
+        else
+            echo "[ ! ] Adding missing variable to hestia.conf: WEBMAIL_SYSTEM ('')"
+            $BIN/v-change-sys-config-value "WEBMAIL_SYSTEM" ""
+        fi
     fi
 
     # Inactive session timeout
@@ -637,7 +644,7 @@ upgrade_filemanager_update_config() {
 upgrade_roundcube(){
     if [ "UPGRADE_UPDATE_ROUNDCUBE" = "true" ]; then
         if [ ! -z "$(echo "$WEBMAIL_SYSTEM" | grep -w 'roundcube')" ]; then
-            rc_version=$(cat $RC_INSTALL_DIR/index.php | grep -o -E '[0-9].[0-9].[0-9]+' | head -1);
+            rc_version=$(cat /var/lib/roundcube/index.php | grep -o -E '[0-9].[0-9].[0-9]+' | head -1);
             if [ "$rc_version" == "$rc_v" ]; then
                 echo "[ * ] Upgrading RoundCube to version v$rc_v..."
                 $HESTIA/bin/v-add-sys-roundcube
@@ -646,6 +653,18 @@ upgrade_roundcube(){
     fi
 }
 
+upgrade_rainloop(){
+    if [ "UPGRADE_UPDATE_RAINLOOP" = "true" ]; then
+        if [ ! -z "$(echo "$WEBMAIL_SYSTEM" | grep -w 'rainloop')" ]; then
+            rc_version=$(cat /var/lib/rainloop/data/VERSION);
+            if [ "$rc_version" == "$rc_v" ]; then
+                echo "[ * ] Upgrading rainloop to version v$rc_v..."
+                $HESTIA/bin/v-add-sys-rainloop
+            fi
+        fi
+    fi
+}
+
 upgrade_rebuild_web_templates() {
     if [ "$UPGRADE_UPDATE_WEB_TEMPLATES" = "true" ]; then
         echo "[ ! ] Updating default web domain templates..."

+ 23 - 0
install/deb/rainloop/change_password.php

@@ -0,0 +1,23 @@
+<?php
+// Example usage 
+// change_password.php "admin_account admin_password mysql_password"
+$_ENV['RAINLOOP_INCLUDE_AS_API'] = true;
+include '/var/lib/rainloop/index.php';
+
+$oConfig = \RainLoop\Api::Config();
+// Change default login data / key
+$oConfig->Set('security', 'admin_login', $argv[1]);
+$oConfig->Set('security', 'admin_panel_key', $argv[1]);
+$oConfig->SetPassword($argv[2]);
+// Allow Contacts to be saved in database
+$oConfig->Set('contacts', 'enable', 'On');
+$oConfig->Set('contacts', 'allow_sync', 'On');
+$oConfig->Set('contacts', 'type', 'mysql');
+$oConfig->Set('contacts', 'pdo_dsn', 'mysql:host=127.0.0.1;port=3306;dbname=rainloop');
+$oConfig->Set('contacts', 'pdo_user', 'rainloop');
+$oConfig->Set('contacts', 'pdo_password', $argv[3]);
+// Plugins
+$oConfig->Set('plugins', 'enable', 'On');
+$oConfig->Set('plugins', 'enabled_list', 'add-x-originating-ip-header,hestia-change-password');
+$oConfig->Save();
+?>

+ 16 - 0
install/deb/rainloop/default.ini

@@ -0,0 +1,16 @@
+imap_host = "localhost"
+imap_port = 993
+imap_secure = "SSL"
+imap_short_login = Off
+sieve_use = Off
+sieve_allow_raw = Off
+sieve_host = ""
+sieve_port = 4190
+sieve_secure = "None"
+smtp_host = "localhost"
+smtp_port = 465
+smtp_secure = "SSL"
+smtp_short_login = Off
+smtp_auth = On
+smtp_php_mail = Off
+white_list = ""

+ 146 - 0
install/deb/rainloop/plugins/hestia-change-password/HestiaChangePasswordDriver.php

@@ -0,0 +1,146 @@
+<?php
+
+class HestiaChangePasswordDriver implements \RainLoop\Providers\ChangePassword\ChangePasswordInterface
+{
+    /**
+     * @var string
+     */
+    private $sHost = '';
+
+    /**
+     * @var string
+     */
+    private $iPort = 8083;
+
+    /**
+     * @var string
+     */
+    private $sAllowedEmails = '';
+
+    /**
+     * @var \MailSo\Log\Logger
+     */
+    private $oLogger = null;
+
+    /**
+     * @param string $sHost
+     * @param int $iPort
+     *
+     * @return \HestiaChangePasswordDriver
+     */
+    public function SetConfig($sHost, $iPort)
+    {
+        $this->sHost = $sHost;
+        $this->iPort = $iPort;
+
+        return $this;
+    }
+
+    /**
+     * @param string $sAllowedEmails
+     *
+     * @return \HestiaChangePasswordDriver
+     */
+    public function SetAllowedEmails($sAllowedEmails)
+    {
+        $this->sAllowedEmails = $sAllowedEmails;
+        return $this;
+    }
+
+    /**
+     * @param \MailSo\Log\Logger $oLogger
+     *
+     * @return \HestiaChangePasswordDriver
+     */
+    public function SetLogger($oLogger)
+    {
+        if ($oLogger instanceof \MailSo\Log\Logger)
+        {
+            $this->oLogger = $oLogger;
+        }
+
+        return $this;
+    }
+
+    /**
+     * @param \RainLoop\Account $oAccount
+     *
+     * @return bool
+     */
+    public function PasswordChangePossibility($oAccount)
+    {
+        return $oAccount && $oAccount->Email() &&
+            \RainLoop\Plugins\Helper::ValidateWildcardValues($oAccount->Email(), $this->sAllowedEmails);
+    }
+
+    /**
+     * @param \RainLoop\Account $oAccount
+     * @param string $sPrevPassword
+     * @param string $sNewPassword
+     *
+     * @return bool
+     */
+    public function ChangePassword(\RainLoop\Account $oAccount, $sPrevPassword, $sNewPassword)
+    {
+        if ($this->oLogger)
+        {
+            $this->oLogger->Write('Hestia: Try to change password for '.$oAccount->Email());
+        }
+
+        $bResult = false;
+        if (!empty($this->sHost) && 0 < $this->iPort && $oAccount)
+        {
+            $sEmail = \trim(\strtolower($oAccount->Email()));
+
+            $sHost = \trim($this->sHost);
+            $sHost = \str_replace('{user:host-imap}', $oAccount->Domain()->IncHost(), $sHost);
+            $sHost = \str_replace('{user:host-smtp}', $oAccount->Domain()->OutHost(), $sHost);
+            $sHost = \str_replace('{user:domain}', \MailSo\Base\Utils::GetDomainFromEmail($sEmail), $sHost);
+            $sHost = \rtrim($this->sHost, '/\\');
+            $sHost = 'https://'.$sHost;
+
+            $sUrl = $sHost.':'.$this->iPort.'/reset/mail/';
+
+            $iCode = 0;
+            $oHttp = \MailSo\Base\Http::SingletonInstance();
+
+            if ($this->oLogger)
+            {
+                $this->oLogger->Write('Hestia[Api Request]:'.$sUrl);
+            }
+
+            $mResult = $oHttp->SendPostRequest($sUrl,
+                array(
+                    'email'         => $sEmail,
+                    'password'   => $sPrevPassword,
+                    'new'     => $sNewPassword,
+                ), 'MailSo Http User Agent (v1)', $iCode, $this->oLogger);
+
+            if (false !== $mResult && 200 === $iCode)
+            {
+                $aRes = null;
+                @\parse_str($mResult, $aRes);
+                if (is_array($aRes) && (!isset($aRes['error']) || (int) $aRes['error'] !== 1))
+                {
+                    $bResult = true;
+                }
+                else
+                {
+                    if ($this->oLogger)
+                    {
+                        $this->oLogger->Write('Hestia[Error]: Response: '.$mResult);
+                    }
+                }
+            }
+            else
+            {
+                if ($this->oLogger)
+                {
+                    $this->oLogger->Write('Hestia[Error]: Empty Response: Code:'.$iCode);
+                }
+            }
+        }
+
+        return $bResult;
+    }
+}

+ 20 - 0
install/deb/rainloop/plugins/hestia-change-password/LICENSE

@@ -0,0 +1,20 @@
+The MIT License (MIT)
+
+Copyright (c) 2013 RainLoop Team
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+the Software, and to permit persons to whom the Software is furnished to do so,
+subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

+ 3 - 0
install/deb/rainloop/plugins/hestia-change-password/README

@@ -0,0 +1,3 @@
+Plugin that adds functionality to change the email account password (Hestia Control Panel).
+Script has been altered / modified to use Hestia naming
+See https://github.com/RainLoop/rainloop-webmail/tree/master/plugins/vesta-change-password for original

+ 1 - 0
install/deb/rainloop/plugins/hestia-change-password/VERSION

@@ -0,0 +1 @@
+1.0

+ 55 - 0
install/deb/rainloop/plugins/hestia-change-password/index.php

@@ -0,0 +1,55 @@
+<?php
+
+class HestiaChangePasswordPlugin extends \RainLoop\Plugins\AbstractPlugin
+{
+    public function Init()
+    {
+        $this->addHook('main.fabrica', 'MainFabrica');
+    }
+
+    /**
+     * @param string $sName
+     * @param mixed $oProvider
+     */
+    public function MainFabrica($sName, &$oProvider)
+    {
+        switch ($sName)
+        {
+            case 'change-password':
+
+                $sHost = \trim($this->Config()->Get('plugin', 'hestia_host', ''));
+                $iPort = (int) $this->Config()->Get('plugin', 'hestia_port', 8083);
+
+                if (!empty($sHost) && 0 < $iPort)
+                {
+                    include_once __DIR__.'/HestiaChangePasswordDriver.php';
+
+                    $oProvider = new HestiaChangePasswordDriver();
+                    $oProvider->SetLogger($this->Manager()->Actions()->Logger());
+                    $oProvider->SetConfig($sHost, $iPort);
+                    $oProvider->SetAllowedEmails(\strtolower(\trim($this->Config()->Get('plugin', 'allowed_emails', ''))));
+                }
+
+                break;
+        }
+    }
+
+    /**
+     * @return array
+     */
+    public function configMapping()
+    {
+        return array(
+            \RainLoop\Plugins\Property::NewInstance('hestia_host')->SetLabel('Hestia Host')
+                ->SetDefaultValue('')
+                ->SetDescription('Ex: localhost or domain.com'),
+            \RainLoop\Plugins\Property::NewInstance('hestia_port')->SetLabel('Hestia Port')
+                ->SetType(\RainLoop\Enumerations\PluginPropertyType::INT)
+                ->SetDefaultValue(8083),
+            \RainLoop\Plugins\Property::NewInstance('allowed_emails')->SetLabel('Allowed emails')
+                ->SetType(\RainLoop\Enumerations\PluginPropertyType::STRING_TEXT)
+                ->SetDescription('Allowed emails, space as delimiter, wildcard supported. Example: user1@domain1.net user2@domain1.net *@domain2.net')
+                ->SetDefaultValue('*')
+        );
+    }
+}

+ 3 - 0
install/deb/rainloop/plugins/plugin-add-x-originating-ip-header.ini

@@ -0,0 +1,3 @@
+; RainLoop Webmail plugin (add-x-originating-ip-header)
+[plugin]
+check_proxy = On

+ 4 - 0
install/deb/rainloop/plugins/plugin-hestia-change-password.ini

@@ -0,0 +1,4 @@
+[plugin]
+hestia_host = "%hostname%"
+hestia_port = %port%
+allowed_emails = "*"

+ 31 - 0
install/deb/templates/mail/apache2/rainloop.stpl

@@ -0,0 +1,31 @@
+<VirtualHost %ip%:%web_ssl_port%>
+ServerName %domain%
+ServerAlias %alias%
+Alias / /var/lib/rainloop/
+Alias /error/ %home%/%user%/web/%root_domain%/document_errors/
+#SuexecUserGroup %user% %group%
+
+SSLEngine on
+SSLVerifyClient none
+SSLCertificateFile         %home%/%user%/conf/mail/%root_domain%/ssl/%root_domain%.crt
+SSLCertificateKeyFile      %home%/%user%/conf/mail/%root_domain%/ssl/%root_domain%.key
+
+<Directory /var/lib/roundcube/>
+    Options +FollowSymLinks
+    # This is needed to parse /var/lib/roundcube/.htaccess. See its
+    # content before setting AllowOverride to None.
+    AllowOverride All
+    order allow,deny
+    allow from all
+</Directory>
+
+# Protecting basic directories:
+<Directory /var/lib/rainloop/data>
+        Options -FollowSymLinks
+        AllowOverride None
+</Directory>
+
+
+IncludeOptional %home%/%user%/conf/mail/%root_domain%/%web_system%.ssl.conf_*
+
+</VirtualHost>

+ 25 - 0
install/deb/templates/mail/apache2/rainloop.tpl

@@ -0,0 +1,25 @@
+<VirtualHost %ip%:%web_port%>
+    ServerName %domain%
+    ServerAlias %alias%
+    Alias / /var/lib/rainloop/
+    Alias /error/ %home%/%user%/web/%root_domain%/document_errors/
+    #SuexecUserGroup %user% %group%
+        
+    IncludeOptional %home%/%user%/conf/mail/%root_domain%/apache2.forcessl.conf*
+
+    <Directory /var/lib/rainloop/>
+        Options +FollowSymLinks
+        # This is needed to parse /var/lib/rainloop/.htaccess. See its
+        # content before setting AllowOverride to None.
+        AllowOverride All
+        order allow,deny
+        allow from all
+    </Directory>
+
+    # Protecting basic directories:
+    <Directory /var/lib/rainloop/data>
+            Options -FollowSymLinks
+            AllowOverride None
+    </Directory>
+    IncludeOptional %home%/%user%/conf/mail/%root_domain%/%web_system%.conf_*
+</VirtualHost>

+ 38 - 0
install/deb/templates/mail/nginx/default_rainloop.stpl

@@ -0,0 +1,38 @@
+server {
+listen      %ip%:%proxy_ssl_port% ssl http2;
+server_name %domain% %alias%;
+root        /var/lib/rainloop;
+index       index.php index.html index.htm;
+access_log /var/log/nginx/domains/%domain%.log combined;
+error_log  /var/log/nginx/domains/%domain%.error.log error;
+
+ssl_certificate     %ssl_pem%;
+ssl_certificate_key %ssl_key%;
+ssl_stapling on;
+ssl_stapling_verify on;
+
+location ~ ^/(README.md|config|temp|logs|bin|SQL|INSTALL|LICENSE|CHANGELOG|UPGRADING)$ {
+    deny all;
+    return 404;
+}
+
+location / {
+    proxy_pass https://%ip%:%web_ssl_port%;
+    try_files $uri $uri/ =404;
+    alias /var/lib/rainloop/;
+    location ~* ^.+\.(ogg|ogv|svg|svgz|swf|eot|otf|woff|woff2|mov|mp3|mp4|webm|flv|ttf|rss|atom|jpg|jpeg|gif|png|ico|bmp|mid|midi|wav|rtf|css|js|jar)$ {
+        expires 7d;
+        fastcgi_hide_header "Set-Cookie";
+    }
+}
+
+location /error/ {
+    alias /var/www/document_errors/;
+}
+
+location @fallback {
+    proxy_pass https://%ip%:%web_ssl_port%;
+}
+
+include %home%/%user%/conf/mail/%root_domain%/%proxy_system%.conf_*;
+}

+ 40 - 0
install/deb/templates/mail/nginx/default_rainloop.tpl

@@ -0,0 +1,40 @@
+server {
+listen      %ip%:%proxy_port%;
+server_name %domain% %alias%;
+root        /var/lib/rainloop;
+index       index.php index.html index.htm;
+access_log /var/log/nginx/domains/%domain%.log combined;
+error_log  /var/log/nginx/domains/%domain%.error.log error;
+
+include %home%/%user%/conf/mail/%root_domain%/nginx.forcessl.conf*;
+
+location ~ /\.(?!well-known\/) {
+    deny all;
+    return 404;
+}
+
+location ~ /data/ {
+    deny all;
+    return 404;
+}
+
+location / {
+    proxy_pass http://%ip%:%web_port%;
+    try_files $uri $uri/ =404;
+    alias /var/lib/rainloop/;
+    location ~* ^.+\.(ogg|ogv|svg|svgz|swf|eot|otf|woff|woff2|mov|mp3|mp4|webm|flv|ttf|rss|atom|jpg|jpeg|gif|png|ico|bmp|mid|midi|wav|rtf|css|js|jar)$ {
+        expires 7d;
+        fastcgi_hide_header "Set-Cookie";
+    }
+}
+
+location /error/ {
+    alias /var/www/document_errors/;
+}
+
+location @fallback {
+    proxy_pass http://%ip%:%web_port%;
+}
+
+include %home%/%user%/conf/mail/%root_domain%/%proxy_system%.conf_*;
+}

+ 45 - 0
install/deb/templates/mail/nginx/rainloop.stpl

@@ -0,0 +1,45 @@
+server {
+listen      %ip%:%web_ssl_port% ssl http2;
+server_name %domain% %alias%;
+root        /var/lib/rainloop;
+index       index.php index.html index.htm;
+access_log /var/log/nginx/domains/%domain%.log combined;
+error_log  /var/log/nginx/domains/%domain%.error.log error;
+
+ssl_certificate     %ssl_pem%;
+ssl_certificate_key %ssl_key%;
+ssl_stapling on;
+ssl_stapling_verify on;
+
+location ~ /\.(?!well-known\/) {
+    deny all;
+    return 404;
+}
+
+location ~ ^/(README.md|config|temp|logs|bin|SQL|INSTALL|LICENSE|CHANGELOG|UPGRADING)$ {
+    deny all;
+    return 404;
+}
+
+location / {
+    try_files $uri $uri/ =404;
+    location ~* ^.+\.(ogg|ogv|svg|svgz|swf|eot|otf|woff|woff2|mov|mp3|mp4|webm|flv|ttf|rss|atom|jpg|jpeg|gif|png|ico|bmp|mid|midi|wav|rtf|css|js|jar)$ {
+        expires 7d;
+        fastcgi_hide_header "Set-Cookie";
+    }
+
+    location ~ ^/(.*\.php)$ {
+        alias /var/lib/rainloop/$1;
+        fastcgi_pass 127.0.0.1:9000;
+        fastcgi_index index.php;
+        include fastcgi_params;
+        fastcgi_param SCRIPT_FILENAME $request_filename;
+    }
+}
+
+location /error/ {
+    alias /var/www/document_errors/;
+}
+
+include %home%/%user%/conf/mail/%root_domain%/%web_system%.conf_*;
+}

+ 42 - 0
install/deb/templates/mail/nginx/rainloop.tpl

@@ -0,0 +1,42 @@
+server {
+listen      %ip%:%web_port%;
+server_name %domain% %alias%;
+root        /var/lib/rainloop;
+index       index.php index.html index.htm;
+access_log /var/log/nginx/domains/%domain%.log combined;
+error_log  /var/log/nginx/domains/%domain%.error.log error;
+
+include %home%/%user%/conf/mail/%root_domain%/nginx.forcessl.conf*;
+
+location ~ /\.(?!well-known\/) {
+    deny all;
+    return 404;
+}
+
+location ~ ^/(README.md|config|temp|logs|bin|SQL|INSTALL|LICENSE|CHANGELOG|UPGRADING)$ {
+    deny all;
+    return 404;
+}
+
+location / {
+    try_files $uri $uri/ =404;
+    location ~* ^.+\.(ogg|ogv|svg|svgz|swf|eot|otf|woff|woff2|mov|mp3|mp4|webm|flv|ttf|rss|atom|jpg|jpeg|gif|png|ico|bmp|mid|midi|wav|rtf|css|js|jar)$ {
+        expires 7d;
+        fastcgi_hide_header "Set-Cookie";
+    }
+
+    location ~ ^/(.*\.php)$ {
+        alias /var/lib/rainloop/$1;
+        fastcgi_pass 127.0.0.1:9000;
+        fastcgi_index index.php;
+        include fastcgi_params;
+        fastcgi_param SCRIPT_FILENAME $request_filename;
+    }
+}
+
+location /error/ {
+    alias /var/www/document_errors/;
+}
+
+include %home%/%user%/conf/mail/%root_domain%/%web_system%.conf_*;
+}

+ 1 - 1
install/deb/templates/web/php-fpm/default.tpl

@@ -17,7 +17,7 @@ pm.status_path = /status
 
 php_admin_value[upload_tmp_dir] = /home/%user%/tmp
 php_admin_value[session.save_path] = /home/%user%/tmp
-php_admin_value[open_basedir] = /home/%user%/web/%domain%/public_html:/home/%user%/web/%domain%/private:/home/%user%/web/%domain%/public_shtml:/home/%user%/tmp:/var/www/html:/etc/phpmyadmin:/var/lib/phpmyadmin:/etc/phppgadmin:/etc/roundcube:/var/lib/roundcube:/tmp:/bin:/usr/bin:/usr/local/bin:/usr/share:/opt
+php_admin_value[open_basedir] = /home/%user%/web/%domain%/public_html:/home/%user%/web/%domain%/private:/home/%user%/web/%domain%/public_shtml:/home/%user%/tmp:/var/www/html:/etc/phpmyadmin:/var/lib/phpmyadmin:/etc/phppgadmin:/etc/roundcube:/var/lib/roundcube:/etc/rainloop:/var/lib/rainloop:/tmp:/bin:/usr/bin:/usr/local/bin:/usr/share:/opt
 php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f admin@%domain%
 
 env[HOSTNAME] = $HOSTNAME

+ 6 - 1
install/upgrade/upgrade.conf

@@ -31,6 +31,9 @@ UPGRADE_UPDATE_PHPMYADMIN='true'
 # Update roundcube to the latest version during upgrade
 UPGRADE_UPDATE_ROUNDCUBE='true'
 
+# Update rainloop to the latest version during upgrade
+UPGRADE_UPDATE_RAINLOOP='true'
+
 # Update the File Manager or it's configuration file
 # UPGRADE_UPDATE_FILEMANAGER: Performs an upgrade/repair install of the File Manager
 # UPGRADE_UPDATE_FILEMANAGER: Updates only the configuration file
@@ -49,4 +52,6 @@ UPGRADE_RESTART_SERVICES='true'
 pma_v='5.0.4'
 # Set version of RoundCube (Webmail) to update during upgrade if not already installed
 # Note: only aplies to "non-apt installs >= 1.4.0 or manualy phased out"
-rc_v="1.4.10"
+rc_v="1.4.10"
+# Set version of Rainloop (Webmail) to update during upgrade if not already installed
+rl_v="1.14.0"

+ 6 - 0
src/deb/hestia/postinst

@@ -66,6 +66,12 @@ upgrade_rebuild_dns_templates | tee -a $LOG
 # Upgrade phpMyAdmin if applicable
 upgrade_phpmyadmin | tee -a $LOG
 
+# Upgrade Roundcube if applicable
+upgrade_roundcube | tee -a $LOG
+
+# Upgrade Rainloop if applicable
+upgrade_rainloop | tee -a $LOG
+
 # Set new version number in hestia.conf
 upgrade_set_version $new_version
 

+ 20 - 2
web/add/mail/index.php

@@ -1,5 +1,5 @@
 <?php
-error_reporting(NULL);
+#error_reporting(NULL);
 ob_start();
 $TAB = 'MAIL';
 
@@ -12,6 +12,10 @@ $user_domains = json_decode(implode('', $output), true);
 $user_domains = array_keys($user_domains);
 unset($output);
 
+exec (HESTIA_CMD."v-list-sys-webmail json", $output, $return_var);
+$webmail_clients = json_decode(implode('', $output), true);
+unset($output);
+
 $v_domain = $_GET['domain'];
 if(!empty($v_domain)){
     if(!in_array($v_domain, $user_domains)) {
@@ -85,6 +89,15 @@ if (!empty($_POST['ok'])) {
         $_SESSION['ok_msg'] = sprintf(_('MAIL_DOMAIN_CREATED_OK'),htmlentities($_POST['v_domain']),htmlentities($_POST['v_domain']));
         unset($v_domain);
     }
+    
+    if (!empty($_SESSION['IMAP_SYSTEM']) && !empty($_SESSION['WEBMAIL_SYSTEM'])){
+        if(!empty($_POST['v_webmail'])){
+            $v_webmail = escapeshellarg($_POST['v_webmail']);
+            exec (HESTIA_CMD."v-add-sys-webmail ".$user." ".$v_domain." ".$v_webmail, $output, $return_var);
+            check_return_code($return_var,$output);
+            unset($output);
+        }
+    }
 }
 
 
@@ -238,7 +251,12 @@ if (!empty($_POST['ok_acc'])) {
 // Render page
 if (empty($_GET['domain'])) {
     // Display body for mail domain
-
+    if( !empty($_POST['v_webmail']) ){
+        $v_webmail  = $_POST['v_webmail'];
+    }else{
+        //default is always roundcube unless it hasn't been installed. Then picks the first one in order
+        $v_webmail  = 'roundcube';
+    }
     render_page($user, $TAB, 'add_mail');
 } else {
     // Display body for mail account

+ 14 - 0
web/edit/mail/index.php

@@ -24,6 +24,10 @@ $user_domains = json_decode(implode('', $output), true);
 $user_domains = array_keys($user_domains);
 unset($output);
 
+exec (HESTIA_CMD."v-list-sys-webmail json", $output, $return_var);
+$webmail_clients = json_decode(implode('', $output), true);
+unset($output);
+
 // List mail domain
 if ((!empty($_GET['domain'])) && (empty($_GET['account']))) {
 
@@ -46,6 +50,7 @@ if ((!empty($_GET['domain'])) && (empty($_GET['account']))) {
     $v_time = $data[$v_domain]['TIME'];
     $v_suspended = $data[$v_domain]['SUSPENDED'];
     $v_webmail_alias = $data[$v_domain]['WEBMAIL_ALIAS'];
+    $v_webmail = $data[$v_domain]['WEBMAIL'];
     
     if ( $v_suspended == 'yes' ) {
         $v_status =  'suspended';
@@ -210,6 +215,15 @@ if ((!empty($_POST['save'])) && (!empty($_GET['domain'])) && (empty($_GET['accou
         check_return_code($return_var,$output);
         unset($output);
     }
+    if (!empty($_SESSION['IMAP_SYSTEM']) && !empty($_SESSION['WEBMAIL_SYSTEM'])){
+        // Update webmail
+        if ((!empty($_POST['v_webmail'])) && $_POST['v_webmail'] != $v_webmail && (empty($_SESSION['error_msg']))) {
+            $v_webmail = escapeshellarg($_POST['v_webmail']);
+            exec (HESTIA_CMD."v-add-sys-webmail ".$v_username." ".escapeshellarg($v_domain)." ".$v_webmail." yes", $output, $return_var);
+            check_return_code($return_var,$output);
+            unset($output);
+        }
+    }
     
     // Change SSL certificate
     if (( $v_letsencrypt == 'no' ) && (empty($_POST['v_letsencrypt'])) && ( $v_ssl == 'yes' ) && (!empty($_POST['v_ssl'])) && (empty($_SESSION['error_msg']))) {

+ 21 - 0
web/templates/admin/add_mail.html

@@ -61,6 +61,27 @@
                                     <input type="text" size="20" class="vst-input" name="v_domain" value="<?=htmlentities(trim($v_domain, "'"))?>">
                                 </td>
                             </tr>
+                            <?php if($_SESSION['IMAP_SYSTEM']){?>                            
+                                <tr>
+                                    <td class="vst-text step-top">
+                                        <?php print _('Webmail Client');?>
+                                    </td>
+                                </tr>
+                                <tr>
+                                    <td>
+                                        <select class="vst-list" name="v_webmail" tabindex="6" >
+                                            <?php foreach ($webmail_clients as $client){
+                                            echo "\t\t\t\t<option value=\"".htmlentities($client)."\"";
+                                            if ((!empty($v_webmail)) && ( $v_webmail == $client )) {
+                                                echo ' selected' ;
+                                            }
+                                            echo ">".htmlentities(ucfirst($client))."</option>\n";
+                                            }
+                                            ?>
+                                        </select>
+                                    </td>
+                                </tr>
+                            <?php } ?>
                             <tr>
                                 <td class="vst-text input-label">
                                     <label><input type="checkbox" size="20" class="vst-checkbox" name="v_antispam" <?php if ((empty($v_antispam)) || ($v_antispam == 'yes')) echo "checked=yes"; ?>> <?php print _('AntiSpam Support');?></label>

+ 21 - 0
web/templates/admin/edit_mail.html

@@ -64,6 +64,27 @@
                                   <input type="hidden" name="v_domain" value="<?=htmlentities(trim($v_domain, "'"))?>">
                                 </td>
                             </tr>
+                            <?php if($_SESSION['IMAP_SYSTEM']){?>                            
+                                <tr>
+                                    <td class="vst-text step-top">
+                                        <?php print _('Webmail Client');?>
+                                    </td>
+                                </tr>
+                                <tr>
+                                    <td>
+                                        <select class="vst-list" name="v_webmail" tabindex="6" >
+                                            <?php foreach ($webmail_clients as $client){
+                                            echo "\t\t\t\t<option value=\"".htmlentities($client)."\"";
+                                            if ((!empty($v_webmail)) && ( $v_webmail == $client )) {
+                                                echo ' selected' ;
+                                            }
+                                            echo ">".htmlentities(ucfirst($client))."</option>\n";
+                                            }
+                                            ?>
+                                        </select>
+                                    </td>
+                                </tr>
+                            <?php } ?>
                             <tr>
                                 <td class="vst-text input-label">
                                     <?php print _('Catchall email');?>