2015-10-21 13:03:49 +02:00
|
|
|
#!/bin/bash
|
2017-02-04 19:14:21 +01:00
|
|
|
set -u # treat unset variables as an error
|
2015-10-21 13:03:49 +02:00
|
|
|
|
2017-10-10 14:09:26 +02:00
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
2017-02-04 19:20:51 +01:00
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
2017-10-10 14:09:26 +02:00
|
|
|
#=================================================
|
|
|
|
# LOAD SETTINGS
|
|
|
|
#=================================================
|
|
|
|
|
2017-10-10 14:12:41 +02:00
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
2017-02-04 19:20:51 +01:00
|
|
|
domain=$(ynh_app_setting_get mattermost domain)
|
2015-10-21 13:03:49 +02:00
|
|
|
db_name="mattermost"
|
|
|
|
db_user="mmuser"
|
2017-10-10 14:12:41 +02:00
|
|
|
final_path="/var/www/$app"
|
|
|
|
data_path="/home/yunohost.app/$app"
|
2015-10-21 13:03:49 +02:00
|
|
|
|
2017-10-10 14:09:26 +02:00
|
|
|
#=================================================
|
|
|
|
# STANDARD REMOVE
|
|
|
|
#=================================================
|
|
|
|
# STOP AND REMOVE SERVICE
|
|
|
|
#=================================================
|
|
|
|
|
2017-10-10 14:12:41 +02:00
|
|
|
sudo supervisorctl stop "$app"
|
|
|
|
sudo rm -f "/etc/supervisor/conf.d/${app}.conf"
|
2015-10-21 13:03:49 +02:00
|
|
|
|
2017-10-10 14:09:26 +02:00
|
|
|
#=================================================
|
|
|
|
# REMOVE THE MYSQL DATABASE
|
|
|
|
#=================================================
|
2015-10-21 13:03:49 +02:00
|
|
|
|
2017-09-12 14:03:48 +02:00
|
|
|
# (DROP USER IF EXISTS is only available on MySQL >= 5.7, so we don't use it for now)
|
|
|
|
ynh_mysql_execute_as_root "DROP DATABASE IF EXISTS $db_name ; DROP USER $db_user@localhost ;"
|
2015-10-21 13:03:49 +02:00
|
|
|
|
2017-10-10 14:09:26 +02:00
|
|
|
#=================================================
|
|
|
|
# REMOVE APP MAIN DIR
|
|
|
|
#=================================================
|
2015-10-31 16:51:08 +01:00
|
|
|
|
2017-10-10 14:12:41 +02:00
|
|
|
sudo rm -rf "$final_path"
|
|
|
|
sudo rm -rf "$data_path"
|
2017-10-10 14:09:26 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# REMOVE NGINX CONFIGURATION
|
|
|
|
#=================================================
|
2015-10-21 14:33:49 +02:00
|
|
|
|
2017-10-10 14:12:41 +02:00
|
|
|
sudo rm -f "/etc/nginx/conf.d/${domain}.d/${app}.conf"
|
2015-10-21 14:33:49 +02:00
|
|
|
|
2017-10-10 14:09:26 +02:00
|
|
|
#=================================================
|
|
|
|
# REMOVE LOG FILE
|
|
|
|
#=================================================
|
|
|
|
|
2017-10-10 14:12:41 +02:00
|
|
|
sudo rm -f "/var/log/${app}.log"
|
2017-10-10 14:09:26 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# REMOVE DEDICATED USER
|
|
|
|
#=================================================
|
|
|
|
|
2017-10-10 14:12:41 +02:00
|
|
|
sudo userdel "$app"
|