1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/leed_ynh.git synced 2024-09-03 19:26:32 +02:00
leed_ynh/scripts/upgrade

84 lines
3 KiB
Text
Raw Normal View History

2014-08-17 17:52:31 +02:00
#!/bin/bash
2014-08-18 22:05:31 +02:00
2015-11-22 14:37:01 +01:00
# Récupère les infos de l'application.
2016-05-20 00:00:38 +02:00
version=$(sudo yunohost -v | grep "moulinette:" | cut -d' ' -f2 | cut -d'.' -f1,2)
if [ $version = "2.4" ]; then
app=$YNH_APP_INSTANCE_NAME
else
app=leed
fi
2015-11-22 14:37:01 +01:00
domain=$(sudo yunohost app setting $app domain)
path=$(sudo yunohost app setting $app path)
admin=$(sudo yunohost app setting $app admin)
is_public=$(sudo yunohost app setting $app is_public)
2014-08-18 22:05:31 +02:00
2015-11-22 14:37:01 +01:00
# Décompresse la source
tar -x -f ../sources/leed.tar.gz
# Copie les fichiers sources
sudo cp -a leed/. "$final_path"
# Copie les fichiers additionnels ou modifiés.
# sudo cp -a ../sources/ajouts/. "$final_path"
# Et copie le fichier de config nginx
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf
2014-08-18 22:05:31 +02:00
# Set right permissions
sudo chown -R www-data: $final_path
# Change variables in Leed configuration
2015-11-22 14:37:01 +01:00
sudo sed -i "s@__PATH__@$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
# Créer le fichier de configuration du pool php-fpm et le configure.
sed -i "s@__NAMETOCHANGE__@$app@g" ../conf/php-fpm.conf
sed -i "s@__FINALPATH__@$final_path@g" ../conf/php-fpm.conf
finalphpconf=/etc/php5/fpm/pool.d/$app.conf
sudo cp ../conf/php-fpm.conf $finalphpconf
sudo chown root: $finalphpconf
finalphpini=/etc/php5/fpm/conf.d/20-$app.ini
sudo cp ../conf/php-fpm.ini $finalphpini
sudo chown root: $finalphpini
sudo service php5-fpm reload
2014-08-18 22:05:31 +02:00
2015-11-22 14:37:01 +01:00
# Configure les droits d'accès au fichiers
# -rw-r--r-- sur les fichiers
2014-08-21 23:59:25 +02:00
sudo find $final_path -type f | xargs sudo chmod 644
2015-11-22 14:37:01 +01:00
# drwxr-xr-x sur les dossiers
2014-08-21 23:59:25 +02:00
sudo find $final_path -type d | xargs sudo chmod 755
2015-11-22 14:37:01 +01:00
# Les fichiers appartiennent à root
2014-08-21 23:59:25 +02:00
sudo chown -R root: $final_path
2015-11-22 14:37:01 +01:00
# www-data doit avoir les droits d'écriture dans plugins et cache
sudo mkdir $final_path/cache
2014-08-21 23:59:25 +02:00
sudo chown -R www-data $final_path/cache $final_path/plugins
2014-08-18 22:05:31 +02:00
2015-11-22 14:37:01 +01:00
# Récupération du code de synchronisation
db_user=$app
code_sync=$(mysql -h localhost -u $db_user -p$db_pwd -s $db_user -e 'SELECT value FROM leed_configuration WHERE `key`="synchronisationCode"' | sed -n 1p)
# Mise en place du cron pour la synchronisation
sed -i "s@__ADMIN__@$admin@g" ../conf/cron_leed
sed -i "s@__DOMAIN__@$domain@g" ../conf/cron_leed
sed -i "s@__PATH__@$path@g" ../conf/cron_leed
sed -i "s@__CODESYNC__@$code_sync@g" ../conf/cron_leed
sudo cp ../conf/cron_leed /etc/cron.d/$app
2014-08-18 22:05:31 +02:00
# Make app private if necessary
2015-11-22 14:37:01 +01:00
sudo yunohost app setting $app is_public -v "$is_public"
2014-08-18 22:05:31 +02:00
if [ "$is_public" = "No" ];
then
# Retire l'autorisation d'accès de la page d'install.
2015-11-22 14:37:01 +01:00
sudo yunohost app setting $app unprotected_uris -d
2014-08-18 22:05:31 +02:00
# Rend la page d'actualisation accessible pour le script cron.
2015-11-22 14:37:01 +01:00
sudo yunohost app setting $app skipped_uris -v "/action.php"
2014-08-18 22:05:31 +02:00
else # Si l'app est publique
2015-11-22 14:37:01 +01:00
sudo yunohost app setting $app unprotected_uris -v "/"
2014-08-18 22:05:31 +02:00
fi
2016-05-20 00:00:38 +02:00
# Recharge la configuration Nginx
2014-08-18 22:05:31 +02:00
sudo service nginx reload
2015-11-22 14:37:01 +01:00
# Régénère la configuration de SSOwat
2014-08-18 22:05:31 +02:00
sudo yunohost app ssowatconf