2015-11-11 18:03:16 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
2017-03-02 15:44:54 +01:00
|
|
|
# Exit on command errors and treat unset variables as an error
|
|
|
|
set -eu
|
2015-11-11 18:03:16 +01:00
|
|
|
|
2017-03-02 15:44:54 +01:00
|
|
|
source .fonctions # Charge les fonctions génériques habituellement utilisées dans le script
|
|
|
|
|
|
|
|
CLEAN_SETUP () {
|
|
|
|
# Nettoyage des résidus d'installation non pris en charge par le script remove.
|
|
|
|
# Clean hosts
|
|
|
|
sudo sed -i '/#GRAV/d' /etc/hosts
|
|
|
|
}
|
|
|
|
TRAP_ON # Active trap pour arrêter le script si une erreur est détectée.
|
|
|
|
|
|
|
|
domain=$YNH_APP_ARG_DOMAIN
|
|
|
|
path=$YNH_APP_ARG_PATH
|
|
|
|
admin_grav=$YNH_APP_ARG_ADMIN
|
|
|
|
language=$YNH_APP_ARG_LANGUAGE
|
|
|
|
multisite=$YNH_APP_ARG_MULTISITE
|
|
|
|
is_public=$YNH_APP_ARG_IS_PUBLIC
|
|
|
|
|
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
|
|
|
|
|
|
|
# Source app helpers
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
CHECK_VAR "$app" "app name not set"
|
|
|
|
|
|
|
|
CHECK_USER "$admin_grav"
|
|
|
|
|
|
|
|
CHECK_PATH
|
|
|
|
|
|
|
|
CHECK_DOMAINPATH
|
|
|
|
|
|
|
|
CHECK_FINALPATH
|
|
|
|
|
|
|
|
ynh_app_setting_set $app domain $domain
|
|
|
|
ynh_app_setting_set $app path $path
|
|
|
|
ynh_app_setting_set $app admin $admin_grav
|
|
|
|
ynh_app_setting_set $app is_public $is_public
|
|
|
|
ynh_app_setting_set $app language $language
|
|
|
|
ynh_app_setting_set $app multisite $multisite
|
|
|
|
|
|
|
|
GENERATE_DB $app # Créer une base de données et un utilisateur dédié au nom de l'app.
|
2015-11-11 18:03:16 +01:00
|
|
|
|
2017-03-02 15:44:54 +01:00
|
|
|
# Crée le repertoire de destination et stocke son emplacement.
|
|
|
|
sudo mkdir "$final_path"
|
|
|
|
ynh_app_setting_set $app final_path $final_path
|
2015-11-11 18:03:16 +01:00
|
|
|
|
2017-03-02 15:44:54 +01:00
|
|
|
SETUP_SOURCE "grav-admin-v1.1.17.zip"
|
|
|
|
|
|
|
|
# Set permissions to grav directory
|
2015-11-11 18:03:16 +01:00
|
|
|
sudo chown -R www-data: $final_path
|
|
|
|
|
2017-03-02 15:44:54 +01:00
|
|
|
echo -e "127.0.0.1 $domain #GRAV" | sudo tee -a /etc/hosts
|
|
|
|
|
|
|
|
# Et copie le fichier de config nginx
|
|
|
|
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf
|
|
|
|
|
|
|
|
# Modifie les variables dans le fichier de configuration nginx
|
|
|
|
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
|
|
|
|
|
|
|
|
if [ "$multisite" = "Yes" ];
|
|
|
|
then
|
|
|
|
sudo sed -i "s@#--MULTISITE--@@g" /etc/nginx/conf.d/$domain.d/$app.conf
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$is_public" = "Yes" ];
|
|
|
|
then
|
|
|
|
sudo sed -i "s@#--PRIVATE--@@g" /etc/nginx/conf.d/$domain.d/$app.conf
|
|
|
|
fi
|
|
|
|
|
|
|
|
POOL_FPM
|
|
|
|
|
|
|
|
# Donne un accès public pour curl
|
|
|
|
ynh_app_setting_set $app unprotected_uris "/"
|
2015-11-11 18:03:16 +01:00
|
|
|
|
2017-03-02 15:44:54 +01:00
|
|
|
# Régénère la configuration de SSOwat
|
|
|
|
sudo yunohost app ssowatconf
|
2015-11-11 18:03:16 +01:00
|
|
|
|
|
|
|
# Reload Nginx and regenerate SSOwat conf
|
|
|
|
sudo service php5-fpm restart
|
|
|
|
sudo service nginx reload
|
2017-03-02 15:44:54 +01:00
|
|
|
|
|
|
|
if [ "$is_public" = "No" ];
|
|
|
|
then
|
|
|
|
# Retire l'accès public
|
|
|
|
ynh_app_setting_delete $app unprotected_uris
|
|
|
|
sudo yunohost app ssowatconf
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Nettoyer hosts
|
|
|
|
sudo sed -i '/#GRAV/d' /etc/hosts
|