2016-07-26 22:51:05 +02:00
|
|
|
#!/bin/bash
|
2016-12-18 01:13:17 +01:00
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
2017-02-24 12:29:41 +01:00
|
|
|
rainloop_version=$(cat ../sources/rainloop_version)
|
2016-07-26 22:51:05 +02:00
|
|
|
|
2016-12-18 01:13:17 +01:00
|
|
|
# Backup the current version of the app, restore it if the upgrade fails
|
2017-02-21 22:23:47 +01:00
|
|
|
# Check if old backup exists
|
|
|
|
if sudo yunohost backup list | grep -q $app-before-upgrade > /dev/null 2>&1;
|
|
|
|
then
|
|
|
|
sudo yunohost backup delete $app-before-upgrade
|
|
|
|
else
|
|
|
|
echo "no old backup to delete"
|
|
|
|
fi
|
2016-12-18 13:16:33 +01:00
|
|
|
sudo yunohost backup create --ignore-hooks --apps $app --name $app-before-upgrade --quiet
|
2016-12-18 01:13:17 +01:00
|
|
|
EXIT_PROPERLY () {
|
2017-02-24 12:18:06 +01:00
|
|
|
trap '' ERR
|
2016-12-18 01:13:17 +01:00
|
|
|
set +eu
|
2016-12-18 13:16:33 +01:00
|
|
|
sudo yunohost backup restore --ignore-hooks $app-before-upgrade --apps $app --force --quiet # Restore the backup if upgrade failed
|
2016-12-18 01:13:17 +01:00
|
|
|
ynh_die "Upgrade failed. The app was restored to the way it was before the failed upgrade."
|
|
|
|
}
|
2017-02-21 23:23:45 +01:00
|
|
|
set -eu
|
2016-12-18 01:13:17 +01:00
|
|
|
trap EXIT_PROPERLY ERR
|
2016-06-28 17:27:30 +02:00
|
|
|
|
|
|
|
# Source app helpers
|
2017-02-21 23:23:45 +01:00
|
|
|
source /usr/share/yunohost/helpers
|
2017-02-24 12:31:09 +01:00
|
|
|
source .fonctions
|
2015-02-01 20:20:54 +01:00
|
|
|
|
2015-02-06 19:47:10 +01:00
|
|
|
# Retrieve arguments
|
2016-06-28 17:27:30 +02:00
|
|
|
domain=$(ynh_app_setting_get "$app" domain)
|
|
|
|
path=$(ynh_app_setting_get "$app" path)
|
|
|
|
is_public=$(ynh_app_setting_get "$app" is_public)
|
2016-07-26 13:49:42 +02:00
|
|
|
password=$(ynh_app_setting_get "$app" password)
|
|
|
|
ldap=$(ynh_app_setting_get "$app" ldap)
|
|
|
|
lang=$(ynh_app_setting_get "$app" lang)
|
2016-06-28 17:27:30 +02:00
|
|
|
dp_pwd=$(ynh_app_setting_get "$app" mysqlpwd)
|
2015-10-24 14:24:50 +02:00
|
|
|
db_user=$app
|
2016-06-28 17:27:30 +02:00
|
|
|
plugins=$(ynh_app_setting_get "$app" plugins)
|
2015-02-01 20:20:54 +01:00
|
|
|
|
2017-02-24 12:31:09 +01:00
|
|
|
# Correct path using .fonctions
|
|
|
|
CHECK_PATH
|
2016-12-18 01:13:17 +01:00
|
|
|
|
2015-10-22 20:55:36 +02:00
|
|
|
# no update for db now...
|
2015-02-06 19:47:10 +01:00
|
|
|
|
2016-12-18 01:13:17 +01:00
|
|
|
# Copy the new sources
|
2015-10-24 14:24:50 +02:00
|
|
|
final_path=/var/www/$app
|
|
|
|
rainloop_path=${final_path}/app
|
2016-12-18 01:13:17 +01:00
|
|
|
sudo rm -rf $rainloop_path/rainloop # Remove the previous Rainloop files except data
|
2015-10-11 22:46:23 +02:00
|
|
|
|
2016-12-18 01:13:17 +01:00
|
|
|
# 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
|
2017-02-21 23:23:45 +01:00
|
|
|
# Verify the integrity of sources
|
2016-12-18 01:13:17 +01:00
|
|
|
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/
|
2015-02-06 19:47:10 +01:00
|
|
|
|
2015-10-24 14:24:50 +02:00
|
|
|
# Update ynh plugins:
|
|
|
|
sudo mkdir -p $rainloop_path/data/_data_/_default_/plugins
|
2016-12-18 01:13:17 +01:00
|
|
|
sudo cp -rf ../sources/plugins/auto-domain-grab $rainloop_path/data/_data_/_default_/plugins/.
|
2015-10-24 14:24:50 +02:00
|
|
|
sudo cp -rf ../sources/plugins/ynh-login-mapping $rainloop_path/data/_data_/_default_/plugins/.
|
2015-10-24 23:51:26 +02:00
|
|
|
sudo cp -rf ../sources/plugins/ynh-ldap-suggestions $rainloop_path/data/_data_/_default_/plugins/.
|
2015-02-01 20:20:54 +01:00
|
|
|
|
2016-12-18 01:13:17 +01:00
|
|
|
# update SSO
|
|
|
|
sudo cp ../sources/sso/sso.php $final_path/index.php
|
2015-10-24 14:24:50 +02:00
|
|
|
sudo sed -i "s@domain.tld@$domain@g" $final_path/index.php
|
|
|
|
sudo sed -i "s@PATHTOCHANGE@$path@g" $final_path/index.php
|
2015-10-07 21:23:28 +02:00
|
|
|
|
2016-12-18 02:26:17 +01:00
|
|
|
# Install PGPback by chtixof to allow users to backup/restore their PGP private keys on the server
|
|
|
|
sudo cp -rf ../sources/pgpback $final_path/.
|
|
|
|
|
2015-10-11 22:46:23 +02:00
|
|
|
# Set permissions to rainloop directory
|
2016-06-28 17:27:30 +02:00
|
|
|
sudo find $final_path/. -type d -exec chmod 755 {} \;
|
|
|
|
sudo find $final_path/. -type f -exec chmod 644 {} \;
|
2015-10-24 14:24:50 +02:00
|
|
|
sudo chown -R www-data:www-data $final_path
|
2015-10-07 21:23:28 +02:00
|
|
|
|
2015-10-22 20:55:36 +02:00
|
|
|
# Update Nginx configuration file
|
2015-10-24 14:24:50 +02:00
|
|
|
nginx_conf_file=/etc/nginx/conf.d/$domain.d/$app.conf
|
|
|
|
sudo cp ../conf/nginx.conf $nginx_conf_file
|
2017-02-23 14:32:47 +01:00
|
|
|
if [ $path = "/" ]; then
|
2017-02-23 14:37:54 +01:00
|
|
|
sudo sed -i "s@ROOTTOCHANGE@@g" $nginx_conf_file
|
2017-02-23 14:32:47 +01:00
|
|
|
else
|
2017-02-23 14:37:54 +01:00
|
|
|
sudo sed -i "s@ROOTTOCHANGE@$path@g" $nginx_conf_file
|
2017-02-23 14:32:47 +01:00
|
|
|
fi
|
2017-02-24 12:15:57 +01:00
|
|
|
sudo sed -i "s@PATHTOCHANGE@$path@g" $nginx_conf_file
|
2015-10-24 14:24:50 +02:00
|
|
|
sudo sed -i "s@ALIASTOCHANGE@$final_path/@g" $nginx_conf_file
|
|
|
|
sudo sed -i "s@NAMETOCHANGE@$app@g" $nginx_conf_file
|
|
|
|
sudo chown root: $nginx_conf_file
|
|
|
|
sudo chmod 644 $nginx_conf_file
|
2015-02-06 19:47:10 +01:00
|
|
|
|
2015-10-24 14:24:50 +02:00
|
|
|
finalphpconf=/etc/php5/fpm/pool.d/$app.conf
|
|
|
|
sudo cp ../conf/php-fpm.conf $finalphpconf
|
|
|
|
sudo sed -i "s@NAMETOCHANGE@$app@g" $finalphpconf
|
|
|
|
sudo chown root: $finalphpconf
|
|
|
|
sudo chmod 644 $finalphpconf
|
2015-02-06 19:47:10 +01:00
|
|
|
|
2016-06-28 17:27:30 +02:00
|
|
|
# Reload services
|
2017-02-24 12:15:57 +01:00
|
|
|
sudo service php5-fpm reload
|
|
|
|
sudo service nginx reload
|