2014-06-18 00:05:18 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2015-11-22 14:37:01 +01:00
|
|
|
# Récupère les infos de l'application.
|
2016-05-20 00:00:38 +02:00
|
|
|
ynh_version=$(sudo yunohost -v | grep "moulinette:" | cut -d' ' -f2 | cut -d'.' -f1,2)
|
|
|
|
if [ $ynh_version = "2.4" ]; then
|
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
|
|
|
|
|
|
|
# Source app helpers
|
|
|
|
. /usr/share/yunohost/helpers
|
|
|
|
else
|
|
|
|
app=leed
|
|
|
|
MYSQL_ROOT_PWD_FILE="/etc/yunohost/mysql"
|
|
|
|
fi
|
2015-11-22 14:37:01 +01:00
|
|
|
domain=$(sudo yunohost app setting $app domain)
|
|
|
|
|
2016-05-20 00:00:38 +02:00
|
|
|
# Suppression de la base de donnée et de l'utilisateur associé.
|
2015-11-22 14:37:01 +01:00
|
|
|
# Utilise '$app' comme nom d'utilisateur et de base de donnée
|
|
|
|
db_user=$app
|
2016-05-20 00:00:38 +02:00
|
|
|
if mysqlshow -u root -p$(sudo cat $MYSQL_ROOT_PWD_FILE) | grep -q "^| $db_user"; then
|
|
|
|
echo "Delete db"
|
|
|
|
if [ $ynh_version = "2.4" ]; then
|
|
|
|
ynh_mysql_drop_db $db_user
|
|
|
|
ynh_mysql_drop_user $db_user
|
|
|
|
else
|
|
|
|
mysql -u root -p$(sudo cat $MYSQL_ROOT_PWD_FILE) -e "DROP DATABASE $db_user ; DROP USER $db_user@localhost ;"
|
|
|
|
fi
|
|
|
|
fi
|
2015-11-22 14:37:01 +01:00
|
|
|
|
|
|
|
# Suppression du dossier de l'application
|
2016-05-20 00:00:38 +02:00
|
|
|
if [ -e "/var/www/$app" ]; then # Delete final_path
|
|
|
|
echo "Delete app dir"
|
|
|
|
sudo rm -r "/var/www/$app"
|
|
|
|
fi
|
2015-11-22 14:37:01 +01:00
|
|
|
|
2014-08-17 17:48:37 +02:00
|
|
|
# Suppression de la configuration nginx
|
2016-05-20 00:00:38 +02:00
|
|
|
if [ -e "/etc/nginx/conf.d/$domain.d/$app.conf" ]; then # Delete nginx config
|
|
|
|
echo "Delete nginx config"
|
|
|
|
sudo rm "/etc/nginx/conf.d/$domain.d/$app.conf"
|
|
|
|
sudo service nginx reload
|
|
|
|
fi
|
2015-11-22 14:37:01 +01:00
|
|
|
|
|
|
|
# Suppression de la configuration du pool php-fpm
|
2016-05-20 00:00:38 +02:00
|
|
|
if [ -e "/etc/php5/fpm/pool.d/$app.conf" ]; then # Delete fpm config
|
|
|
|
echo "Delete fpm config"
|
|
|
|
sudo rm "/etc/php5/fpm/pool.d/$app.conf"
|
|
|
|
fi
|
|
|
|
if [ -e "/etc/php5/fpm/conf.d/20-$app.ini" ]; then # Delete php config
|
|
|
|
echo "Delete php config"
|
|
|
|
sudo rm "/etc/php5/fpm/conf.d/20-$app.ini"
|
|
|
|
fi
|
2016-05-15 11:34:18 +02:00
|
|
|
sudo service php5-fpm reload
|
2016-05-20 00:00:38 +02:00
|
|
|
|
|
|
|
# Retirer le cron
|
|
|
|
if [ -e "/etc/cron.d/$app" ]; then
|
|
|
|
echo "Delete cron"
|
|
|
|
sudo rm "/etc/cron.d/$app"
|
|
|
|
fi
|
|
|
|
|
2015-11-22 14:37:01 +01:00
|
|
|
# Régénère la configuration de SSOwat
|
2014-08-17 17:48:37 +02:00
|
|
|
sudo yunohost app ssowatconf
|
2016-05-20 00:00:38 +02:00
|
|
|
|
|
|
|
echo -e "\e[0m" # Restore normal color
|