From 5b8cd3149412226039b5f3a51ae2d04f5209633c Mon Sep 17 00:00:00 2001 From: Jeff Date: Tue, 28 Jun 2016 17:29:32 +0200 Subject: [PATCH] YunoHost 2.4 --- scripts/remove | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/scripts/remove b/scripts/remove index 5ae71ab..bfed4a9 100644 --- a/scripts/remove +++ b/scripts/remove @@ -1,18 +1,25 @@ -#!/bin/bash -set -e -app=rainloop +# Exit on command errors and treat unset variables as an error +set -eu +app=$YNH_APP_INSTANCE_NAME -db_user=$app -db_name=$app -root_pwd=$(sudo cat /etc/yunohost/mysql) -domain=$(sudo yunohost app setting $app domain) +# Source app helpers +. /usr/share/yunohost/helpers -mysql -u root -p$root_pwd -e "DROP DATABASE $db_name ; DROP USER $db_user@localhost ;" -sudo rm -rf /var/www/$app -sudo rm -f /etc/nginx/conf.d/$domain.d/$app.conf -sudo rm -f /etc/php5/fpm/pool.d/$app.conf +# Retrieve arguments + dbuser=$app + dbname=$app + root_pwd=$(sudo cat /etc/yunohost/mysql) + domain=$(ynh_app_setting_get "$app" domain) -sudo service php5-fpm restart -sudo service nginx reload -sudo yunohost app ssowatconf +# Drop MySQL database and user + ynh_mysql_drop_db "$dbname" 2>&1 || true + ynh_mysql_drop_user "$dbuser" 2>&1 || true +# Delete app directory and configurations + sudo rm -rf "/var/www/${app}" + sudo rm -f "/etc/php5/fpm/pool.d/${app}.conf" + [[ -n $domain ]] && sudo rm -f "/etc/nginx/conf.d/${domain}.d/${app}.conf" + +# Reload services + sudo service php5-fpm restart || true + sudo service nginx reload || true