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:
parent
ae879fe08c
commit
90a70807ad
7 changed files with 121 additions and 106 deletions
|
@ -1 +0,0 @@
|
|||
gmail.com,outlook.com,qq.com,yahoo.com,
|
|
@ -1,29 +1,27 @@
|
|||
#!/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
|
||||
set -eu
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
# Set app specific variables
|
||||
dbname=$app
|
||||
dbuser=$app
|
||||
dbname=$app
|
||||
dbuser=$app
|
||||
|
||||
# Source app helpers
|
||||
. /usr/share/yunohost/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)
|
||||
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"
|
||||
DESTDIR="/var/www/$app"
|
||||
ynh_backup "$DESTDIR" "sources"
|
||||
|
||||
# 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
|
||||
mysqldump -u "$dbuser" -p"$dbpass" --no-create-db "$dbname" > ./dump.sql
|
||||
mysqldump -u "$dbuser" -p"$dbpass" --no-create-db "$dbname" > ./dump.sql
|
||||
|
|
|
@ -1,23 +1,32 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Exit on command errors and treat unset variables as an error
|
||||
set -eu
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
# Retrieve arguments
|
||||
domain=$1
|
||||
path=${2%/}
|
||||
is_public=$3
|
||||
password=$4
|
||||
ldap=$5
|
||||
lang=$6
|
||||
set -eu
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
rainloop_version='1.10.5.192'
|
||||
|
||||
# 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
|
||||
sudo yunohost app checkurl "${domain}${path}" -a "$app" \
|
||||
|| exit 1
|
||||
|| ynh_die "Path not available: ${domain}${path}"
|
||||
|
||||
# Use 'rainloop' as database name and user
|
||||
dbuser=$app
|
||||
|
@ -36,13 +45,20 @@ app=$YNH_APP_INSTANCE_NAME
|
|||
sudo mkdir -p $final_path
|
||||
sudo mkdir -p $rainloop_path
|
||||
|
||||
# Use of latest community edition
|
||||
sudo wget -q https://github.com/RainLoop/rainloop-webmail/releases/download/v1.10.2.145/rainloop-community-1.10.2.145-74dc686dd82d9f29b0fef8ceb11c2903.zip
|
||||
#Check checksum
|
||||
sudo unzip -qq rainloop-community-1.10.2.*.zip -d $rainloop_path/
|
||||
# Download sources and keys
|
||||
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
|
||||
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-ldap-suggestions $rainloop_path/data/_data_/_default_/plugins/.
|
||||
|
||||
|
@ -61,13 +77,13 @@ app=$YNH_APP_INSTANCE_NAME
|
|||
*)
|
||||
lang="en"
|
||||
esac
|
||||
|
||||
ynh_app_setting_set "$app" lang "$lang"
|
||||
|
||||
# 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" ];
|
||||
then
|
||||
plugins="$plugins,ynh-ldap-suggestions"
|
||||
plugins="$plugins,ynh-ldap-suggestions" # This plugin is to suggest YunoHost users in recipients list
|
||||
fi
|
||||
ynh_app_setting_set "$app" plugins "$plugins"
|
||||
|
||||
|
@ -80,22 +96,20 @@ app=$YNH_APP_INSTANCE_NAME
|
|||
|
||||
# Set admin 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
|
||||
sudo mkdir -p $rainloop_path/data/_data_/_default_/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://" `
|
||||
for ldomain in $alldomains ; do
|
||||
sudo cp ../conf/data/domains/domain.tld.ini $rainloop_path/data/_data_/_default_/domains/$ldomain.ini
|
||||
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 and auto version - at the moment the index is the SSO and rainloop is installed in /app
|
||||
# install SSO - 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/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@PATHTOCHANGE@$path@g" $final_path/index.php
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Exit on command errors and treat unset variables as an error
|
||||
set -eu
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
set -eu
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
# Source app helpers
|
||||
. /usr/share/yunohost/helpers
|
||||
|
@ -10,7 +10,6 @@ app=$YNH_APP_INSTANCE_NAME
|
|||
# Retrieve arguments
|
||||
dbuser=$app
|
||||
dbname=$app
|
||||
root_pwd=$(sudo cat /etc/yunohost/mysql)
|
||||
domain=$(ynh_app_setting_get "$app" domain)
|
||||
|
||||
# Drop MySQL database and user
|
||||
|
@ -22,6 +21,9 @@ app=$YNH_APP_INSTANCE_NAME
|
|||
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
|
||||
|
|
|
@ -4,53 +4,53 @@
|
|||
set -eu
|
||||
|
||||
# Get multi-instances specific variables
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
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)
|
||||
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" \
|
||||
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.\
|
||||
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}'.
|
||||
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}'.
|
||||
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"
|
||||
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
|
||||
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"
|
||||
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"
|
||||
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
|
||||
sudo service php5-fpm restart || true
|
||||
sudo service nginx reload || true
|
||||
|
|
|
@ -1,8 +1,18 @@
|
|||
#!/bin/bash
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
rainloop_version='1.10.5.192'
|
||||
|
||||
# Exit on command errors and treat unset variables as an error
|
||||
set -eu
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
# Backup the current version of the app, restore it if the upgrade fails
|
||||
sudo yunohost backup delete $app-before-upgrade
|
||||
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
|
||||
. /usr/share/yunohost/helpers
|
||||
|
@ -18,30 +28,40 @@ app=$YNH_APP_INSTANCE_NAME
|
|||
db_user=$app
|
||||
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...
|
||||
|
||||
# Create the final path and copy sources
|
||||
# Copy the new sources
|
||||
final_path=/var/www/$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
|
||||
|
||||
# Use of latest community edition
|
||||
sudo wget -q https://github.com/RainLoop/rainloop-webmail/releases/download/v1.10.2.145/rainloop-community-1.10.2.145-74dc686dd82d9f29b0fef8ceb11c2903.zip
|
||||
#Check checksum
|
||||
sudo unzip -qq rainloop-community-1.10.2.*.zip -d $rainloop_path/
|
||||
|
||||
# Update patch to auto load version
|
||||
sudo cp ../sources/patch/index_auto_version.php $rainloop_path/index.php
|
||||
# Download sources and keys
|
||||
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
|
||||
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:
|
||||
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-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/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@PATHTOCHANGE@$path@g" $final_path/index.php
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
?>
|
Loading…
Add table
Reference in a new issue