2015-04-28 17:32:31 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2016-08-30 00:22:47 +02:00
|
|
|
# Exit on command errors and treat unset variables as an error
|
|
|
|
set -eu
|
|
|
|
|
|
|
|
# See comments in install script
|
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
|
|
|
|
|
|
|
# Source YunoHost helpers
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
# Retrieve app settings
|
|
|
|
domain=$(ynh_app_setting_get "$app" domain)
|
|
|
|
path=$(ynh_app_setting_get "$app" path)
|
|
|
|
admin=$(ynh_app_setting_get "$app" admin)
|
|
|
|
is_public=$(ynh_app_setting_get "$app" is_public)
|
|
|
|
language=$(ynh_app_setting_get "$app" language)
|
|
|
|
|
2016-09-20 01:51:28 +02:00
|
|
|
CHECK_PATH # Vérifie et corrige la syntaxe du path.
|
|
|
|
|
|
|
|
# Check if admin is not null
|
|
|
|
if [[ "$admin" = "" || "$is_public" = "" || "$language" = "" ]]; then
|
|
|
|
echo "Unable to upgrade, please contact support"
|
2017-02-21 04:02:03 +01:00
|
|
|
ynh_die
|
2016-09-20 01:51:28 +02:00
|
|
|
fi
|
2015-04-28 17:32:31 +02:00
|
|
|
|
|
|
|
root_pwd=$(sudo cat /etc/yunohost/mysql)
|
|
|
|
|
2016-09-20 01:51:28 +02:00
|
|
|
final_path=/var/www/$app
|
2015-04-28 17:32:31 +02:00
|
|
|
|
2016-09-20 01:51:28 +02:00
|
|
|
db_name=$app
|
2015-04-28 17:32:31 +02:00
|
|
|
|
|
|
|
# Modify Nginx configuration file and copy it to Nginx conf directory
|
|
|
|
sed -i "s@PATHTOCHANGE@$path@g" ../conf/nginx.conf*
|
|
|
|
sed -i "s@ALIASTOCHANGE@$final_path/@g" ../conf/nginx.conf*
|
|
|
|
|
|
|
|
if [ $is_public = "Yes" ];
|
|
|
|
then
|
2016-09-20 01:51:28 +02:00
|
|
|
sudo cp ../conf/nginx.conf-public /etc/nginx/conf.d/$domain.d/$app.conf
|
2017-02-22 00:38:20 +01:00
|
|
|
# grep -q "define('FORCE_SSL_ADMIN', true);" $final_path/config/connect.php
|
2016-08-30 00:22:47 +02:00
|
|
|
# if [[ ! $? -eq 0 ]];
|
|
|
|
# then
|
|
|
|
# echo "define('FORCE_SSL_ADMIN', true);" | sudo tee -a $final_path/config/connect.php
|
|
|
|
# else
|
|
|
|
# sudo sed -i "s@//define('FORCE_SSL_ADMIN@define('FORCE_SSL_ADMIN@g" $final_path/config/connect.php
|
|
|
|
# fi
|
|
|
|
else
|
2016-09-20 01:51:28 +02:00
|
|
|
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf
|
2016-08-30 00:22:47 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
# If app is public, add url to SSOWat conf as skipped_uris
|
|
|
|
if [[ $is_public -eq 1 ]]; then
|
|
|
|
# See install script
|
|
|
|
ynh_app_setting_set "$app" unprotected_uris "/"
|
2016-09-20 01:51:28 +02:00
|
|
|
sudo cp ../conf/nginx.conf-public /etc/nginx/conf.d/$domain.d/$app.conf
|
2015-04-28 17:32:31 +02:00
|
|
|
else
|
2016-09-20 01:51:28 +02:00
|
|
|
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf
|
2015-04-28 17:32:31 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Reload Nginx
|
|
|
|
sudo service nginx reload
|