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
|
|
|
|
|
2017-03-08 00:26:58 +01:00
|
|
|
source .fonctions # Loads the generic functions usually used in the script
|
2017-03-08 00:43:41 +01:00
|
|
|
source /usr/share/yunohost/helpers # Source YunoHost helpers
|
2017-02-22 02:39:06 +01:00
|
|
|
|
2016-08-30 00:22:47 +02:00
|
|
|
# See comments in install script
|
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
|
|
|
|
|
|
|
# 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)
|
|
|
|
|
2017-03-08 00:26:58 +01:00
|
|
|
CHECK_PATH # Checks and corrects the syntax of the path.
|
2016-09-20 01:51:28 +02:00
|
|
|
|
|
|
|
# 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
|
|
|
|
2017-03-26 15:06:27 +02:00
|
|
|
# Get source
|
2017-03-26 00:58:09 +01:00
|
|
|
SETUP_SOURCE
|
2017-03-23 13:43:34 +01:00
|
|
|
|
2016-09-20 01:51:28 +02:00
|
|
|
db_name=$app
|
2015-04-28 17:32:31 +02:00
|
|
|
|
2017-03-08 00:26:58 +01:00
|
|
|
CHECK_MD5_CONFIG "connect.php" "$final_path/config/connect.php" # Created a backup of the config file if it was changed.
|
2017-02-22 02:39:06 +01:00
|
|
|
|
2015-04-28 17:32:31 +02:00
|
|
|
# Modify Nginx configuration file and copy it to Nginx conf directory
|
2017-03-15 17:12:04 +01:00
|
|
|
sudo sed -i "s@__PATHTOCHANGE__@$path@g" /etc/nginx/conf.d/$domain.d/$app.conf
|
|
|
|
sudo sed -i "s@__FINALPATH__@$final_path@g" /etc/nginx/conf.d/$domain.d/$app.conf
|
|
|
|
sudo sed -i "s@__NAMETOCHANGE__@$app@g" /etc/nginx/conf.d/$domain.d/$app.conf
|
2015-04-28 17:32:31 +02:00
|
|
|
|
2017-03-15 17:12:04 +01:00
|
|
|
if [ "$is_public" = "Yes" ];
|
2015-04-28 17:32:31 +02:00
|
|
|
then
|
2017-03-15 17:12:04 +01:00
|
|
|
sudo sed -i "s@#--PRIVATE--@@g" /etc/nginx/conf.d/$domain.d/$app.conf
|
|
|
|
fi
|
|
|
|
|
2017-03-26 15:06:27 +02:00
|
|
|
# Create the php-fpm pool config
|
|
|
|
POOL_FPM
|
|
|
|
|
2017-03-15 17:12:04 +01:00
|
|
|
# Setup SSOwat
|
|
|
|
ynh_app_setting_set "$app" is_public "$is_public"
|
|
|
|
if [ "$is_public" = "Yes" ];
|
|
|
|
then
|
|
|
|
ynh_app_setting_set "$app" unprotected_uris "/"
|
2015-04-28 17:32:31 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Reload Nginx
|
|
|
|
sudo service nginx reload
|