2014-12-09 21:00:17 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
2017-03-19 18:28:38 +01:00
|
|
|
#=================================================
|
|
|
|
# GENERIC STARTING
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
source .fonctions
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# LOAD SETTINGS
|
|
|
|
#=================================================
|
2016-11-30 17:49:37 +01:00
|
|
|
|
|
|
|
# Récupère les infos de l'application.
|
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
|
|
|
|
2016-11-30 17:55:46 +01:00
|
|
|
domain=$(ynh_app_setting_get $app domain)
|
2017-03-19 18:28:38 +01:00
|
|
|
path_url=$(ynh_app_setting_get $app path)
|
2016-11-30 17:55:46 +01:00
|
|
|
is_public=$(ynh_app_setting_get $app is_public)
|
|
|
|
port=$(ynh_app_setting_get $app port)
|
2015-02-27 14:41:04 +01:00
|
|
|
|
2017-03-19 18:28:38 +01:00
|
|
|
#=================================================
|
|
|
|
# FIX OLD THINGS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
if [ "$is_public" = "Yes" ]; then
|
|
|
|
ynh_app_setting_set $app is_public 1 # Fixe is_public en booléen
|
|
|
|
is_public=1
|
|
|
|
elif [ "$is_public" = "No" ]; then
|
|
|
|
ynh_app_setting_set $app is_public 0
|
|
|
|
is_public=0
|
|
|
|
fi
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
BACKUP_BEFORE_UPGRADE # Backup the current version of the app
|
|
|
|
ynh_clean_setup () {
|
|
|
|
BACKUP_FAIL_UPGRADE # restore it if the upgrade fails
|
|
|
|
}
|
|
|
|
ynh_abort_if_errors # Active trap pour arrêter le script si une erreur est détectée.
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# NGINX CONFIGURATION
|
|
|
|
#=================================================
|
2014-12-09 21:00:17 +01:00
|
|
|
|
2016-11-30 17:49:37 +01:00
|
|
|
# Copie le fichier de config nginx
|
|
|
|
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf
|
|
|
|
# Et modifie les variables dans le fichier de configuration nginx
|
2017-03-19 18:28:38 +01:00
|
|
|
sudo sed -i "s@__PATH__@$path_url@g" /etc/nginx/conf.d/$domain.d/$app.conf
|
2016-11-30 17:49:37 +01:00
|
|
|
sudo sed -i "s@__DOMAIN__@$domain@g" /etc/nginx/conf.d/$domain.d/$app.conf
|
|
|
|
sudo sed -i "s@__PORT__@$port@g" /etc/nginx/conf.d/$domain.d/$app.conf
|
2014-12-16 00:14:01 +01:00
|
|
|
|
2017-03-19 18:28:38 +01:00
|
|
|
#=================================================
|
|
|
|
# SETUP SSOWAT
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
if [ $is_public -eq 1 ]
|
2014-12-16 00:14:01 +01:00
|
|
|
then
|
2017-03-19 18:28:38 +01:00
|
|
|
ynh_app_setting_set $app unprotected_uris "/"
|
2014-12-16 00:14:01 +01:00
|
|
|
else
|
2017-03-19 18:28:38 +01:00
|
|
|
ynh_app_setting_delete $app unprotected_uris
|
2014-12-16 00:14:01 +01:00
|
|
|
fi
|
|
|
|
|
2017-03-19 18:28:38 +01:00
|
|
|
#=================================================
|
|
|
|
# RELOAD NGINX
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
sudo systemctl reload nginx
|