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

Major Rainloop update

- Backup/restore scripts
- Updated to YNH 2.4
- Fetch from source and integrity check
- Remove autoversion (not needed)
- Remove ynh_login_mapping (creates LDAP errors plus is it really
needed?). The plugin is still installed but not activated
- Domain hooks
- Backup before upgrade, restore if fail
- Remove disabled domains (users may want to add gmail addresses)
- Added auto-domain-grab plugin with wildcard domain. Users can try to
add aliases without admin config
- Add the admin password in config in case the password is lost
This commit is contained in:
scith 2016-12-18 01:13:17 +01:00
parent ae879fe08c
commit 90a70807ad
7 changed files with 121 additions and 106 deletions

View file

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

View file

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

View file

@ -1,23 +1,32 @@
#!/bin/bash #!/bin/bash
# Exit on command errors and treat unset variables as an error # Exit on command errors and treat unset variables as an error
set -eu set -eu
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
rainloop_version='1.10.5.192'
# Retrieve arguments
domain=$1
path=${2%/}
is_public=$3
password=$4
ldap=$5
lang=$6
# Source app helpers # Source app helpers
. /usr/share/yunohost/helpers . /usr/share/yunohost/helpers
# Retrieve arguments
domain=$YNH_APP_ARG_DOMAIN
path=$YNH_APP_ARG_PATH
is_public=$YNH_APP_ARG_IS_PUBLIC
password=$YNH_APP_ARG_PASSWORD
ldap=$YNH_APP_ARG_LDAP
lang=$YNH_APP_ARG_LANG
# Correct path
if [ "${path:0:1}" != "/" ]; then
path="/$path"
fi
if [ "${path:${#path}-1}" == "/" ] && [ ${#path} -gt 1 ]; then
path="${path:0:${#path}-1}"
fi
# Check domain/path availability # Check domain/path availability
sudo yunohost app checkurl "${domain}${path}" -a "$app" \ sudo yunohost app checkurl "${domain}${path}" -a "$app" \
|| exit 1 || ynh_die "Path not available: ${domain}${path}"
# Use 'rainloop' as database name and user # Use 'rainloop' as database name and user
dbuser=$app dbuser=$app
@ -36,13 +45,20 @@ app=$YNH_APP_INSTANCE_NAME
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 wget -q https://github.com/RainLoop/rainloop-webmail/releases/download/v1.10.2.145/rainloop-community-1.10.2.145-74dc686dd82d9f29b0fef8ceb11c2903.zip sudo wget -q https://github.com/RainLoop/rainloop-webmail/releases/download/v${rainloop_version}/rainloop-community-${rainloop_version}.zip
#Check checksum sudo wget -q https://github.com/RainLoop/rainloop-webmail/releases/download/v${rainloop_version}/rainloop-community-${rainloop_version}.zip.asc
sudo unzip -qq rainloop-community-1.10.2.*.zip -d $rainloop_path/ 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/.
@ -61,13 +77,13 @@ app=$YNH_APP_INSTANCE_NAME
*) *)
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
ynh_app_setting_set "$app" plugins "$plugins" ynh_app_setting_set "$app" plugins "$plugins"
@ -80,22 +96,20 @@ app=$YNH_APP_INSTANCE_NAME
# 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
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
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

View file

@ -1,8 +1,8 @@
#!/bin/bash #!/bin/bash
# Exit on command errors and treat unset variables as an error # Exit on command errors and treat unset variables as an error
set -eu set -eu
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
# Source app helpers # Source app helpers
. /usr/share/yunohost/helpers . /usr/share/yunohost/helpers
@ -10,7 +10,6 @@ app=$YNH_APP_INSTANCE_NAME
# Retrieve arguments # Retrieve arguments
dbuser=$app dbuser=$app
dbname=$app dbname=$app
root_pwd=$(sudo cat /etc/yunohost/mysql)
domain=$(ynh_app_setting_get "$app" domain) domain=$(ynh_app_setting_get "$app" domain)
# Drop MySQL database and user # Drop MySQL database and user
@ -22,6 +21,9 @@ app=$YNH_APP_INSTANCE_NAME
sudo rm -f "/etc/php5/fpm/pool.d/${app}.conf" sudo rm -f "/etc/php5/fpm/pool.d/${app}.conf"
[[ -n $domain ]] && sudo rm -f "/etc/nginx/conf.d/${domain}.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 # Reload services
sudo service php5-fpm restart || true sudo service php5-fpm restart || true
sudo service nginx reload || true sudo service nginx reload || true

View file

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

View file

@ -1,8 +1,18 @@
#!/bin/bash #!/bin/bash
app=$YNH_APP_INSTANCE_NAME
rainloop_version='1.10.5.192'
# Exit on command errors and treat unset variables as an error # Backup the current version of the app, restore it if the upgrade fails
set -eu sudo yunohost backup delete $app-before-upgrade
app=$YNH_APP_INSTANCE_NAME sudo yunohost backup create --apps $app --name $app-before-upgrade --quiet
EXIT_PROPERLY () {
trap '' EXIT
set +eu
sudo yunohost backup restore $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 # Source app helpers
. /usr/share/yunohost/helpers . /usr/share/yunohost/helpers
@ -18,30 +28,40 @@ app=$YNH_APP_INSTANCE_NAME
db_user=$app db_user=$app
plugins=$(ynh_app_setting_get "$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 wget -q https://github.com/RainLoop/rainloop-webmail/releases/download/v1.10.2.145/rainloop-community-1.10.2.145-74dc686dd82d9f29b0fef8ceb11c2903.zip sudo wget -q https://repository.rainloop.net/RainLoop.asc
#Check checksum # Verify the integrity of sources
sudo unzip -qq rainloop-community-1.10.2.*.zip -d $rainloop_path/ sudo gpg --import --quiet RainLoop.asc
sudo gpg --verify --quiet rainloop-community-${rainloop_version}.zip.asc rainloop-community-${rainloop_version}.zip
# Update patch to auto load version sudo gpg --batch --delete-key --yes Rainloop
sudo cp ../sources/patch/index_auto_version.php $rainloop_path/index.php # 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
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
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

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);
}
?>