1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/rainloop_ynh.git synced 2024-09-03 20:16:18 +02:00

Merge pull request #11 from scith/master

Major Rainloop update
This commit is contained in:
Jeff 2017-02-09 17:26:59 +01:00 committed by GitHub
commit d36dedc2aa
23 changed files with 560 additions and 146 deletions

View file

@ -1,6 +1,6 @@
# Rainloop for YunoHost # Rainloop for YunoHost
* [rainloop](http://rainloop.net/ ): 1.9.3.365 * [rainloop](http://rainloop.net/ ): 1.10.5.192
## English ## English
Rainloop is a lightweight webmail. Rainloop is a lightweight webmail.
@ -9,15 +9,16 @@ To configure it, go to http://DOMAIN.TLD/rainloop/app/?admin
- The default login is : admin - The default login is : admin
- The default password is : Password chosen during install - The default password is : Password chosen during install
- If you lost the admin password, you can retrieve it using ``sudo yunohost app settings rainloop password``
Each user can add a remote carddav server from their own parameters interface. Each user can add a remote carddav server from their own parameters interface.
If you use baikal, the CardDav address is :
https://DOMAIN.TLD/baikal/card.php/addressbooks/USER/default/
- to upgrade the app once a new rainloop version is available, simply run in a local shell via ssh or otherwise : - If you use baikal, the CardDav address is: https://DOMAIN.TLD/baikal/card.php/addressbooks/USER/default/
- for testing use - If you use NextCloud, the CardDav address is: https://DOMAIN.TLD/nextcloud/remote.php/carddav/addressbooks/USER/contacts
``sudo yunohostapp upgrade -u https://github.com/YunoHostPlugins-Testing/rainloop_ynh rainloop``
- for release Rainloop saves your PGP private keys in the browser storage. This means that you will loose your private keys if you clear your browser storage (e.g., private browsing, different computer...). This packages integrates [PGPback by chtixof](https://github.com/chtixof/pgpback_ynh) so you can store your PGP private keys on the server securely. Go to **http://DOMAIN.TLD/rainloop/pgpback** to backup your PGP keys on the server or restore them.
To upgrade the app once a new rainloop version is available, simply run in a local shell via ssh or otherwise :
``sudo yunohost app upgrade -u https://github.com/YunoHost-Apps/rainloop_ynh rainloop`` ``sudo yunohost app upgrade -u https://github.com/YunoHost-Apps/rainloop_ynh rainloop``
@ -28,14 +29,15 @@ Pour le configurer après l'installation, veuillez vous rendre sur http://DOMAIN
- Le nom d'utilisateur admin par défaut est : admin - Le nom d'utilisateur admin par défaut est : admin
- Le mot de passe admin par défaut est : Mot de passe choisi lors de l'installation - Le mot de passe admin par défaut est : Mot de passe choisi lors de l'installation
- Si vous avez oublié votre mot de passe, vous pouvez le retrouver avec ``sudo yunohost app settings rainloop password``
Chaque utilisateur peut ajouter un carnet d'adresse distant CardDav via leur propre paramètres. Chaque utilisateur peut ajouter un carnet d'adresse distant CardDav via leur propre paramètres.
Si vous utilisez Baikal, l'adresse à renseigner est du type :
https://DOMAIN.TLD/baikal/card.php/addressbooks/UTILISATEUR/default/
- Si vous utilisez Baikal, l'adresse à renseigner est du type : https://DOMAIN.TLD/baikal/card.php/addressbooks/UTILISATEUR/default/
- Si vous utilisez NextCloud, l'adresse à renseigner est du type : https://DOMAIN.TLD/nextcloud/remote.php/carddav/addressbooks/USER/contacts
- pour mettre à jour rainloop lorsqu'une nouvelle version est disponible, lancez en console locale (ssh ou autre) : Rainloop stocke les clés PGP privées dans le stockage de navigateur. Cela implique que vos clés seront perdues quand vous videz le stockage de navigateur (navigation incognito, changement d'ordinateur, ...). Ce paquet intègre [PGPback de chtixof](https://github.com/chtixof/pgpback_ynh) pour que vous puissiez stocker vos clés privées PGP de manière sécurisée sur le serveur. Rendez-vous **http://DOMAIN.TLD/rainloop/pgpback** pour stocker vos clés privées PGP sur le serveur ou les restaurer dans un nouveau navigateur.
``sudo yunohost app upgrade -u https://github.com/YunoHostPlugins-Testing/rainloop_ynh rainloop`` Pour mettre à jour rainloop lorsqu'une nouvelle version est disponible, lancez en console locale (ssh ou autre) :
``sudo yunohost app upgrade -u https://github.com/YunoHost-Apps/rainloop_ynh rainloop`` ``sudo yunohost app upgrade -u https://github.com/YunoHost-Apps/rainloop_ynh rainloop``

52
check_process Normal file
View file

@ -0,0 +1,52 @@
;; Test Rainloop LDAP suggestions
auto_remove=1
; Manifest
domain="domain.tld" (DOMAIN)
path="/rainloop" (PATH)
is_public="No" (PUBLIC|public=Yes|private=No)
password="password" (PASSWORD)
ldap="Yes" (LDAP)
lang="English" (LANG)
; Checks
pkg_linter=1
setup_sub_dir=1
setup_root=1
setup_nourl=0
setup_private=1
setup_public=1
upgrade=1
backup_restore=1
multi_instance=0
wrong_user=1
wrong_path=1
incorrect_path=1
corrupt_source=0
fail_download_source=0
port_already_use=0
final_path_already_use=0
;; Test Rainloop no LDAP suggestions
auto_remove=1
; Manifest
domain="domain.tld" (DOMAIN)
path="/rainloop" (PATH)
is_public="No" (PUBLIC|public=Yes|private=No)
password="password" (PASSWORD)
ldap="No" (LDAP)
lang="English" (LANG)
; Checks
pkg_linter=1
setup_sub_dir=1
setup_root=1
setup_nourl=0
setup_private=1
setup_public=1
upgrade=1
backup_restore=1
multi_instance=0
wrong_user=1
wrong_path=1
incorrect_path=1
corrupt_source=0
fail_download_source=0
port_already_use=0
final_path_already_use=0

View file

@ -0,0 +1,16 @@
imap_host = "auto"
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 = "auto"
smtp_port = 465
smtp_secure = "SSL"
smtp_short_login = Off
smtp_auth = On
smtp_php_mail = Off
white_list = ""

View file

@ -1 +0,0 @@
gmail.com,outlook.com,qq.com,yahoo.com,

View file

@ -2,11 +2,11 @@ imap_host = "localhost"
imap_port = 993 imap_port = 993
imap_secure = "SSL" imap_secure = "SSL"
imap_short_login = On imap_short_login = On
sieve_use = Off sieve_use = On
sieve_allow_raw = Off sieve_allow_raw = On
sieve_host = "" sieve_host = "localhost"
sieve_port = 4190 sieve_port = 4190
sieve_secure = "None" sieve_secure = "TLS"
smtp_host = "localhost" smtp_host = "localhost"
smtp_port = 465 smtp_port = 465
smtp_secure = "SSL" smtp_secure = "SSL"

View file

@ -5,12 +5,16 @@ location PATHTOCHANGE {
rewrite ^ https://$server_name$request_uri? permanent; rewrite ^ https://$server_name$request_uri? permanent;
} }
location ^~ PATHTOCHANGEapp/data { location ^~ PATHTOCHANGE/app/data {
deny all;
}
location ^~ PATHTOCHANGE/pgpback/keys {
deny all; deny all;
} }
client_max_body_size 10G; client_max_body_size 10G;
index index.php; index index.php index.html;
try_files $uri $uri/ index.php; try_files $uri $uri/ index.php;
location ~ [^/]\.php(/|$) { location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^(.+?\.php)(/.*)$; fastcgi_split_path_info ^(.+?\.php)(/.*)$;

7
hooks/post_domain_add Normal file
View file

@ -0,0 +1,7 @@
#!/bin/bash
app='rainloop' # This could never work with multi-instance. Need to find a better way
domain=$1
rainloop_path=/var/www/$app/app
sudo cp ../conf/data/domains/domain.tld.ini $rainloop_path/data/_data_/_default_/domains/$domain.ini

7
hooks/post_domain_remove Normal file
View file

@ -0,0 +1,7 @@
#!/bin/bash
app='rainloop' # This could never work with multi-instance. Need to find a better way
domain=$1
rainloop_path=/var/www/$app/app
sudo rm $rainloop_path/data/_data_/_default_/domains/$domain.ini

View file

@ -1,22 +1,25 @@
{ {
"packaging_format": 1,
"name": "Rainloop", "name": "Rainloop",
"id": "rainloop", "id": "rainloop",
"description": { "description": {
"en": "Lightweight webmail", "en": "Lightweight multi-account webmail",
"fr": "Webmail leger" "fr": "Webmail léger multi-comptes"
}, },
"url": "http://rainloop.net/", "url": "http://rainloop.net/",
"license": "free", "license": "free",
"maintainer": { "maintainer": {
"name": "scith, Djip007", "name": "scith, Djip007"
"email": "none@domaine.org"
}, },
"multi_instance": "false", "multi_instance": false,
"services": [ "services": [
"nginx", "nginx",
"php5-fpm", "php5-fpm",
"mysql" "mysql"
], ],
"requirements": {
"yunohost": ">= 2.4.0"
},
"arguments": { "arguments": {
"install" : [ "install" : [
{ {

27
scripts/backup Normal file
View file

@ -0,0 +1,27 @@
#!/bin/bash
# Exit on command errors and treat unset variables as an error
set -eu
app=$YNH_APP_INSTANCE_NAME
# Set app specific variables
dbname=$app
dbuser=$app
# Source app helpers
. /usr/share/yunohost/helpers
# Retrieve app settings
domain=$(ynh_app_setting_get "$app" domain)
path=$(ynh_app_setting_get "$app" path)
dbpass=$(ynh_app_setting_get "$app" mysqlpwd)
# Copy the app files
DESTDIR="/var/www/$app"
ynh_backup "$DESTDIR" "sources"
# Copy the conf files
ynh_backup "/etc/nginx/conf.d/${domain}.d/${app}.conf" "nginx.conf"
# Dump the database
mysqldump -u "$dbuser" -p"$dbpass" --no-create-db "$dbname" > ./dump.sql

View file

@ -1,53 +1,64 @@
#!/bin/bash #!/bin/bash
set -e
app=rainloop # Exit on command errors and treat unset variables as an error
set -eu
app=$YNH_APP_INSTANCE_NAME
rainloop_version='1.10.5.192'
# Source app helpers
. /usr/share/yunohost/helpers
# Retrieve arguments # Retrieve arguments
domain=$1 domain=$YNH_APP_ARG_DOMAIN
path=$2 path=$YNH_APP_ARG_PATH
is_public=$3 is_public=$YNH_APP_ARG_IS_PUBLIC
password=$4 password=$YNH_APP_ARG_PASSWORD
ldap=$5 ldap=$YNH_APP_ARG_LDAP
lang=$6 lang=$YNH_APP_ARG_LANG
# Removal of trailing / # Correct path
if [ $path = "/" ] if [ "${path:0:1}" != "/" ]; then
then path="/$path"
echo "Installation on the root of the domain" fi
else if [ "${path:${#path}-1}" == "/" ] && [ ${#path} -gt 1 ]; then
path=${path%/} path="${path:0:${#path}-1}"
fi fi
# Check domain/path availability # Check domain/path availability
sudo yunohost app checkurl $domain$path -a rainloop sudo yunohost app checkurl "${domain}${path}" -a "$app" \
if [[ ! $? -eq 0 ]]; then || ynh_die "Path not available: ${domain}${path}"
exit 1
fi
# Generate random password
db_pwd=$(dd if=/dev/urandom bs=1 count=200 2> /dev/null | tr -c -d 'A-Za-z0-9' | sed -n 's/\(.\{24\}\).*/\1/p')
# Use 'rainloop' as database name and user # Use 'rainloop' as database name and user
db_user=$app dbuser=$app
dbname=$app
dbpass=$(ynh_string_random)
# Initialize database and store mysql password for upgrade # Initialize database and store mysql password for upgrade
sudo yunohost app initdb $db_user -p $db_pwd ynh_mysql_create_db "$dbname" "$dbuser" "$dbpass"
sudo yunohost app setting $app mysqlpwd -v $db_pwd ynh_app_setting_set "$app" mysqlpwd "$dbpass"
# Create the final path and copy sources # Create the final path and copy sources
final_path=/var/www/$app final_path=/var/www/$app
rainloop_path=${final_path}/app rainloop_path=${final_path}/app
#rainloop_path=${final_path}
sudo rm -rf $final_path sudo rm -rf $final_path
sudo mkdir -p $final_path sudo mkdir -p $final_path
sudo mkdir -p $rainloop_path sudo mkdir -p $rainloop_path
# Use of latest community edition # Download sources and keys
sudo unzip -q ../sources/rainloop-community.zip -d $rainloop_path/ sudo wget -q https://github.com/RainLoop/rainloop-webmail/releases/download/v${rainloop_version}/rainloop-community-${rainloop_version}.zip
sudo wget -q https://github.com/RainLoop/rainloop-webmail/releases/download/v${rainloop_version}/rainloop-community-${rainloop_version}.zip.asc
sudo wget -q https://repository.rainloop.net/RainLoop.asc
# Verify the integrity of sources
sudo gpg --import --quiet RainLoop.asc
sudo gpg --verify --quiet rainloop-community-${rainloop_version}.zip.asc rainloop-community-${rainloop_version}.zip || ynh_die "Download failed"
sudo gpg --batch --delete-key --yes Rainloop
# Unzip
sudo unzip -qq rainloop-community-${rainloop_version}.zip -d $rainloop_path/
# Install plugins # Install plugins
sudo mkdir -p $rainloop_path/data/_data_/_default_/plugins sudo mkdir -p $rainloop_path/data/_data_/_default_/plugins
sudo cp -rf ../sources/plugins/auto-domain-grab $rainloop_path/data/_data_/_default_/plugins/.
sudo cp -rf ../sources/plugins/ynh-login-mapping $rainloop_path/data/_data_/_default_/plugins/. sudo cp -rf ../sources/plugins/ynh-login-mapping $rainloop_path/data/_data_/_default_/plugins/.
sudo cp -rf ../sources/plugins/ynh-ldap-suggestions $rainloop_path/data/_data_/_default_/plugins/. sudo cp -rf ../sources/plugins/ynh-ldap-suggestions $rainloop_path/data/_data_/_default_/plugins/.
@ -66,52 +77,48 @@ app=rainloop
*) *)
lang="en" lang="en"
esac esac
ynh_app_setting_set "$app" lang "$lang"
# Set plugins # Set plugins
plugins="ynh-login-mapping" plugins="auto-domain-grab" # This plugin is trying to automatically grab unknown domains if users want to add external email accounts
if [ "$ldap" = "Yes" ]; if [ "$ldap" = "Yes" ];
then then
plugins="$plugins,ynh-ldap-suggestions" plugins="$plugins,ynh-ldap-suggestions" # This plugin is to suggest YunoHost users in recipients list
fi fi
sudo yunohost app setting $app plugins -v $plugins ynh_app_setting_set "$app" plugins "$plugins"
sudo cp ../conf/data/configs/application.ini $application_file sudo cp ../conf/data/configs/application.ini $application_file
sudo sed -i "s@domain.tld@$domain@g" $application_file sudo sed -i "s@domain.tld@$domain@g" $application_file
sudo sed -i "s@MYSQLUSER@$db_user@g" $application_file sudo sed -i "s@MYSQLUSER@$dbuser@g" $application_file
sudo sed -i "s@MYSQLPASSWORD@$db_pwd@g" $application_file sudo sed -i "s@MYSQLPASSWORD@$dbpass@g" $application_file
sudo sed -i "s@LANGTOCHANGE@$lang@g" $application_file sudo sed -i "s@LANGTOCHANGE@$lang@g" $application_file
sudo sed -i "s@PLUGINSTOENABLE@$plugins@g" $application_file sudo sed -i "s@PLUGINSTOENABLE@$plugins@g" $application_file
# Set admin password # Set admin password
sudo php ../conf/config.php --index="$rainloop_path/index.php" --password="$password" sudo php ../conf/config.php --index="$rainloop_path/index.php" --password="$password"
ynh_app_setting_set "$app" password "$password"
# Add default domain configs by looping through all the domains already added # Add default domain configs by looping through all the domains already added
sudo mkdir -p $rainloop_path/data/_data_/_default_/domains/ sudo mkdir -p $rainloop_path/data/_data_/_default_/domains/
# get list of ldap domains # get list of ldap domains
alldomains=`ldapsearch -LLL -x -b ou=domains,dc=yunohost,dc=org -s one "objectclass=top" virtualdomain | grep -v "dn:" | sed "s/virtualdomain://" ` alldomains=`ldapsearch -LLL -x -b ou=domains,dc=yunohost,dc=org -s one "objectclass=top" virtualdomain | grep -v "dn:" | sed "s/virtualdomain://" `
for ldomain in $alldomains ; do for ldomain in $alldomains ; do
sudo cp ../conf/data/domains/domain.tld.ini $rainloop_path/data/_data_/_default_/domains/$ldomain.ini sudo cp ../conf/data/domains/domain.tld.ini $rainloop_path/data/_data_/_default_/domains/$ldomain.ini
done done
sudo cp ../conf/data/domains/disabled $rainloop_path/data/_data_/_default_/domains/disabled # Add wildcard domain for auto-grab
sudo cp ../conf/data/domains/default.ini $rainloop_path/data/_data_/_default_/domains/default.ini
# Hooks for domains are not implemented yet, so new domains will not be added automatically # install SSO - at the moment the index is the SSO and rainloop is installed in /app
# install SSO and auto version - at the moment the index is the SSO and rainloop is installed in /app
if [ $final_path == $rainloop_path ]
then
# use modified version of master index.php that implement sso
sudo cp ../sources/sso/index.php $final_path/index.php
else
# use only sso on master
sudo cp ../sources/sso/sso.php $final_path/index.php sudo cp ../sources/sso/sso.php $final_path/index.php
sudo cp ../sources/patch/index_auto_version.php $rainloop_path/index.php
fi
sudo sed -i "s@domain.tld@$domain@g" $final_path/index.php sudo sed -i "s@domain.tld@$domain@g" $final_path/index.php
sudo sed -i "s@PATHTOCHANGE@$path@g" $final_path/index.php sudo sed -i "s@PATHTOCHANGE@$path@g" $final_path/index.php
# Install PGPback by chtixof to allow users to backup/restore their PGP private keys on the server
sudo cp -rf ../sources/pgpback $final_path/.
# Set permissions to rainloop directory # Set permissions to rainloop directory
sudo find $final_path/. -type d -exec chmod 755 {} \;
sudo find $final_path/. -type f -exec chmod 644 {} \;
sudo chown -R www-data:www-data $final_path sudo chown -R www-data:www-data $final_path
# Install Nginx configuration file # Install Nginx configuration file
@ -130,13 +137,12 @@ app=rainloop
sudo chmod 644 $finalphpconf sudo chmod 644 $finalphpconf
# Make app public if necessary # Make app public if necessary
sudo yunohost app setting $app is_public -v "$is_public" ynh_app_setting_set "$app" is_public "$is_public"
if [ "$is_public" = "Yes" ]; if [ "$is_public" = "Yes" ];
then then
sudo yunohost app setting $app skipped_uris -v "/" ynh_app_setting_set "$app" skipped_uris "/"
fi fi
# Reload Nginx and regenerate SSOwat conf # Reload services
sudo service php5-fpm reload sudo service php5-fpm restart || true
sudo service nginx reload sudo service nginx reload || true
sudo yunohost app ssowatconf

View file

@ -1,18 +1,29 @@
#!/bin/bash #!/bin/bash
set -e
app=rainloop
db_user=$app # Exit on command errors and treat unset variables as an error
db_name=$app set -eu
root_pwd=$(sudo cat /etc/yunohost/mysql) app=$YNH_APP_INSTANCE_NAME
domain=$(sudo yunohost app setting $app domain)
mysql -u root -p$root_pwd -e "DROP DATABASE $db_name ; DROP USER $db_user@localhost ;" # Source app helpers
sudo rm -rf /var/www/$app . /usr/share/yunohost/helpers
sudo rm -f /etc/nginx/conf.d/$domain.d/$app.conf
sudo rm -f /etc/php5/fpm/pool.d/$app.conf
sudo service php5-fpm restart # Retrieve arguments
sudo service nginx reload dbuser=$app
sudo yunohost app ssowatconf dbname=$app
domain=$(ynh_app_setting_get "$app" domain)
# Drop MySQL database and user
ynh_mysql_drop_db "$dbname" 2>&1 || true
ynh_mysql_drop_user "$dbuser" 2>&1 || true
# Delete app directory and configurations
sudo rm -rf "/var/www/${app}"
sudo rm -f "/etc/php5/fpm/pool.d/${app}.conf"
[[ -n $domain ]] && sudo rm -f "/etc/nginx/conf.d/${domain}.d/${app}.conf"
# Remove GPG key
sudo gpg --batch --delete-key --yes Rainloop
# Reload services
sudo service php5-fpm restart || true
sudo service nginx reload || true

56
scripts/restore Normal file
View file

@ -0,0 +1,56 @@
#!/bin/bash
# Exit on command errors and treat unset variables as an error
set -eu
# Get multi-instances specific variables
app=$YNH_APP_INSTANCE_NAME
# Source app helpers
. /usr/share/yunohost/helpers
# Retrieve old app settings
domain=$(ynh_app_setting_get "$app" domain)
path=$(ynh_app_setting_get "$app" path)
dbname=$app
dbuser=$app
dbpass=$(ynh_app_setting_get "$app" mysqlpwd)
# Check domain/path availability
sudo yunohost app checkurl "${domain}${path}" -a "$app" \
|| exit 1
# Check destination directory
DESTDIR="/var/www/$app"
[[ -d $DESTDIR ]] && ynh_die \
"The destination directory '$DESTDIR' already exists.\
You should safely delete it before restoring this app."
# Check configuration files
nginx_conf="/etc/nginx/conf.d/${domain}.d/${app}.conf"
[[ -f $nginx_conf ]] && ynh_die \
"The NGINX configuration already exists at '${nginx_conf}'.
You should safely delete it before restoring this app."
phpfpm_conf="/etc/php5/fpm/pool.d/${app}.conf"
[[ -f $phpfpm_conf ]] && ynh_die \
"The PHP FPM configuration already exists at '${phpfpm_conf}'.
You should safely delete it before restoring this app."
# Restore the app files
sudo cp -a ./sources "$DESTDIR"
# Create and restore the database
ynh_mysql_create_db $dbname $dbuser $dbpass
ynh_mysql_connect_as $dbuser $dbpass $dbname < ./dump.sql
# Fix installation directories and permissions
sudo mkdir -p "${DESTDIR}/logs" "${DESTDIR}/temp"
sudo chown -R www-data: "$DESTDIR"
# Restore configuration files
sudo cp -a ./nginx.conf "$nginx_conf"
sudo cp -a ./php-fpm.conf "$phpfpm_conf"
# Reload services
sudo service php5-fpm restart || true
sudo service nginx reload || true

View file

@ -1,48 +1,76 @@
#!/bin/bash #!/bin/bash
set -e app=$YNH_APP_INSTANCE_NAME
app=rainloop rainloop_version='1.10.5.192'
# Backup the current version of the app, restore it if the upgrade fails
sudo yunohost backup delete $app-before-upgrade
sudo yunohost backup create --ignore-hooks --apps $app --name $app-before-upgrade --quiet
EXIT_PROPERLY () {
trap '' EXIT
set +eu
sudo yunohost backup restore --ignore-hooks $app-before-upgrade --apps $app --force --quiet # Restore the backup if upgrade failed
ynh_die "Upgrade failed. The app was restored to the way it was before the failed upgrade."
}
set -eu
trap EXIT_PROPERLY ERR
# Source app helpers
. /usr/share/yunohost/helpers
# Retrieve arguments # Retrieve arguments
domain=$(sudo yunohost app setting $app domain) domain=$(ynh_app_setting_get "$app" domain)
path=$(sudo yunohost app setting $app path) path=$(ynh_app_setting_get "$app" path)
is_public=$(sudo yunohost app setting $app is_public) is_public=$(ynh_app_setting_get "$app" is_public)
dp_pwd=$(sudo yunohost app setting $app mysqlpwd) password=$(ynh_app_setting_get "$app" password)
ldap=$(ynh_app_setting_get "$app" ldap)
lang=$(ynh_app_setting_get "$app" lang)
dp_pwd=$(ynh_app_setting_get "$app" mysqlpwd)
db_user=$app db_user=$app
plugins=$(sudo yunohost app setting $app plugins) plugins=$(ynh_app_setting_get "$app" plugins)
# Correct path
if [ "${path:0:1}" != "/" ]; then
path="/$path"
fi
if [ "${path:${#path}-1}" == "/" ] && [ ${#path} -gt 1 ]; then
path="${path:0:${#path}-1}"
fi
# no update for db now... # no update for db now...
# Create the final path and copy sources # Copy the new sources
final_path=/var/www/$app final_path=/var/www/$app
rainloop_path=${final_path}/app rainloop_path=${final_path}/app
sudo rm -rf $rainloop_path/rainloop # Remove the previous Rainloop files except data
# the old version is not deleted... the new version is in a new path # Download sources and keys
sudo wget -q https://github.com/RainLoop/rainloop-webmail/releases/download/v${rainloop_version}/rainloop-community-${rainloop_version}.zip
# Use of latest community edition sudo wget -q https://github.com/RainLoop/rainloop-webmail/releases/download/v${rainloop_version}/rainloop-community-${rainloop_version}.zip.asc
sudo unzip -q ../sources/rainloop-community.zip -d $rainloop_path/ sudo wget -q https://repository.rainloop.net/RainLoop.asc
# Verify the integrity of sources
# Update patch to auto load version sudo gpg --import --quiet RainLoop.asc
sudo cp ../sources/patch/index_auto_version.php $rainloop_path/index.php sudo gpg --verify --quiet rainloop-community-${rainloop_version}.zip.asc rainloop-community-${rainloop_version}.zip
sudo gpg --batch --delete-key --yes Rainloop
# Unzip and overwrite
sudo unzip -qq -o rainloop-community-${rainloop_version}.zip -d $rainloop_path/
# Update ynh plugins: # Update ynh plugins:
sudo mkdir -p $rainloop_path/data/_data_/_default_/plugins sudo mkdir -p $rainloop_path/data/_data_/_default_/plugins
sudo cp -rf ../sources/plugins/auto-domain-grab $rainloop_path/data/_data_/_default_/plugins/.
sudo cp -rf ../sources/plugins/ynh-login-mapping $rainloop_path/data/_data_/_default_/plugins/. sudo cp -rf ../sources/plugins/ynh-login-mapping $rainloop_path/data/_data_/_default_/plugins/.
sudo cp -rf ../sources/plugins/ynh-ldap-suggestions $rainloop_path/data/_data_/_default_/plugins/. sudo cp -rf ../sources/plugins/ynh-ldap-suggestions $rainloop_path/data/_data_/_default_/plugins/.
# update SSO and auto version # update SSO
if [ $final_path == $rainloop_path ]
then
# use modified version of master index.php that implement sso
sudo cp ../sources/sso/index.php $final_path/index.php
else
# use only sso on master
sudo cp ../sources/sso/sso.php $final_path/index.php sudo cp ../sources/sso/sso.php $final_path/index.php
sudo cp ../sources/patch/index_auto_version.php $rainloop_path/index.php
fi
sudo sed -i "s@domain.tld@$domain@g" $final_path/index.php sudo sed -i "s@domain.tld@$domain@g" $final_path/index.php
sudo sed -i "s@PATHTOCHANGE@$path@g" $final_path/index.php sudo sed -i "s@PATHTOCHANGE@$path@g" $final_path/index.php
# Install PGPback by chtixof to allow users to backup/restore their PGP private keys on the server
sudo cp -rf ../sources/pgpback $final_path/.
# Set permissions to rainloop directory # Set permissions to rainloop directory
sudo find $final_path/. -type d -exec chmod 755 {} \;
sudo find $final_path/. -type f -exec chmod 644 {} \;
sudo chown -R www-data:www-data $final_path sudo chown -R www-data:www-data $final_path
# Update Nginx configuration file # Update Nginx configuration file
@ -60,7 +88,6 @@ app=rainloop
sudo chown root: $finalphpconf sudo chown root: $finalphpconf
sudo chmod 644 $finalphpconf sudo chmod 644 $finalphpconf
# Reload Nginx and regenerate SSOwat conf # Reload services
sudo service php5-fpm reload sudo service php5-fpm restart || true
sudo service nginx reload sudo service nginx reload || true
sudo yunohost app ssowatconf

View file

@ -1,18 +0,0 @@
<?php
if (!defined('APP_VERSION')) {
$version = file_get_contents('/var/www/rainloop/app/data/VERSION');
if ($version) {
define('APP_VERSION', $version);
define('APP_INDEX_ROOT_FILE', __FILE__);
define('APP_INDEX_ROOT_PATH', str_replace('\\', '/', rtrim(dirname(__FILE__), '\\/').'/'));
}
}
if (file_exists(APP_INDEX_ROOT_PATH.'rainloop/v/'.APP_VERSION.'/include.php')) {
include APP_INDEX_ROOT_PATH.'rainloop/v/'.APP_VERSION.'/include.php';
} else {
echo '[105] Missing version directory';
exit(105);
}
?>

23
sources/pgpback/fav.php Normal file
View file

@ -0,0 +1,23 @@
<?php
$text=file_get_contents('php://input');
$user=$_SERVER["PHP_AUTH_USER"];
$file='keys/pk_'.$user.'.json';
if ($user=="") {
$out='{"rc":-2,"pk":[]}';
} else if ($text=="") {
$fread=file_get_contents($file);
if ($fread==""){
$out='{"rc":-3,"pk":[]}';
} else {
$out='{"rc":-1,"pk":'.file_get_contents($file).'}';
}
} else {
$fstatus=file_put_contents($file,$text) ;
$out='{"rc":'.$fstatus.',"pk":[]}';
}
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Content-Type: application/json; charset=utf-8");
echo json_encode($out);
?>

View file

@ -0,0 +1,90 @@
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<title>PGPBack
</title>
<style>
body {
background: #41444f;
color: #bbb;
}
a {
color: #fff;
text-decoration:none;
}
a:hover {
color: #fff;
text-decoration:underline;
}
</style>
</head>
<body>
<h1>PGPBack : OpenPGP keys backup for Rainloop</h1>
PGPBack has been tested with Chrome. It enables the following:<br><br>
<a id="arestorels" href="javascript:void(0)">Set the local OpenPGP keys from the server</a><br/><br/>
<a id="asavels" href="javascript:void(0)">Backup the local OpenPGP keys onto the server</a><br/><br/>
<a id="aclearls" href="javascript:void(0)">Clear the local OpenPGP keys (for security reasons)</a><br/><br/>
<script src="lib/jquery-1.11.2.min.js"></script>
<script>
$(document).ready(function() {
$('#asavels').click(function() {
if (confirm('The local OpenPGP keys will be loaded onto the server')) {
$.ajax("fav.php", {
data : JSON.stringify([localStorage["openpgp-private-keys"],localStorage["openpgp-public-keys"]]),
contentType : 'application/json',
type : 'POST',
dataType: 'json',
success: function (data) {
parseddata=JSON.parse(data);
switch (parseddata.rc){
case -2:
alert("User not logged in Yunohost. Keys not saved.");
break;
case -1:
case -3:
alert("No keys to save.");
break;
case 0:
alert("Problem when writing the data. Keys not saved.");
break;
default:
alert("Keys saved ("+parseddata.rc+" bytes).");
}
}
});
}
});
$('#aclearls').click(function() {
if (confirm('The local OpenPGP keys will be deleted')) {
delete localStorage["openpgp-private-keys"];
delete localStorage["openpgp-public-keys"];
}
});
$('#arestorels').click(function() {
if (confirm('The local OpenPGP keys will be replaced by those from the server')) {
$.ajax("fav.php", {
contentType : 'application/json',
type : 'POST',
dataType: 'json',
success: function (data) {
parseddata=JSON.parse(data);
switch (parseddata.rc){
case -2:
alert("User not logged in Yunohost. Keys not set.");
break;
case -3:
alert("No data found. Keys not set.");
break;
default:
localStorage["openpgp-private-keys"]=parseddata.pk[0];
localStorage["openpgp-public-keys"]=parseddata.pk[1];
alert("Keys set from the server.");
}
}
});
}
});
})
</script>
</body>
</html>

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,27 @@
This plugin, written by https://github.com/jas8522
and optimised by
https://github.com/rhyswilliamsza
https://github.com/rhysit
https://github.com/RainLoop
is released under:
The MIT License (MIT)
Copyright (c) 2015 https://github.com/jas8522
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.

View file

@ -0,0 +1,14 @@
What is it?
In essense, this plugin allows for multiple users across multiple servers to use one RainLoop installation,
all without the administrator needing to create each domain separately. This plugin detects the required
hostname from the inputted email address (for example, it would detect "example.com" as the hostname if
"info@example.com" is inputted). This hostname is then used for IMAP and SMTP communication.
How to Use:
1) Activate plugin
2) Visit Settings, and add a new wildcard domain "*"
3) Set your ports/ssl requirements as needed. These will not be changed by the plugin.
4) In the SMTP and/or IMAP host fields, place the single word "auto". This will be replaced when the plugin is active.
5) That's it! The plugin should now work!

View file

@ -0,0 +1 @@
1.1

View file

@ -0,0 +1,56 @@
<?php
/**
* This plug-in automatically detects the IMAP and SMTP settings by extracting them from the email address itself.
* For example, user inputs: "info@example.com"
* This plugin sets the IMAP and SMTP host to "example.com" upon login, and then connects to it.
*
* Based on:
* https://github.com/RainLoop/rainloop-webmail/blob/master/plugins/override-smtp-credentials/index.php
*
*/
class AutoDomainGrabPlugin extends \RainLoop\Plugins\AbstractPlugin
{
public function Init()
{
$this->addHook('filter.smtp-credentials', 'FilterSmtpCredentials');
$this->addHook('filter.imap-credentials', 'FilterImapCredentials');
}
/**
* This function detects the IMAP Host, and if it is set to "auto", replaces it with the email domain.
*
* @param \RainLoop\Model\Account $oAccount
* @param array $aImapCredentials
*/
public function FilterImapCredentials($oAccount, &$aImapCredentials)
{
if ($oAccount instanceof \RainLoop\Model\Account && \is_array($aImapCredentials))
{
// Check for mail.$DOMAIN as entered value in RL settings
if (!empty($aImapCredentials['Host']) && 'auto' === $aImapCredentials['Host'])
{
$aImapCredentials['Host'] = \MailSo\Base\Utils::GetDomainFromEmail($oAccount->Email());
}
}
}
/**
* This function detects the SMTP Host, and if it is set to "auto", replaces it with the email domain.
*
* @param \RainLoop\Model\Account $oAccount
* @param array $aSmtpCredentials
*/
public function FilterSmtpCredentials($oAccount, &$aSmtpCredentials)
{
if ($oAccount instanceof \RainLoop\Model\Account && \is_array($aSmtpCredentials))
{
// Check for mail.$DOMAIN as entered value in RL settings
if (!empty($aSmtpCredentials['Host']) && 'auto' === $aSmtpCredentials['Host'])
{
$aSmtpCredentials['Host'] = \MailSo\Base\Utils::GetDomainFromEmail($oAccount->Email());
}
}
}
}

Binary file not shown.