1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/mattermost_ynh.git synced 2024-09-03 19:36:29 +02:00
mattermost_ynh/scripts/remove

107 lines
3.5 KiB
Text
Raw Normal View History

2015-10-21 13:03:49 +02:00
#!/bin/bash
2017-10-10 14:09:26 +02:00
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
2021-01-11 23:46:48 +01:00
source _common.sh
source /usr/share/yunohost/helpers
2017-10-10 14:09:26 +02:00
#=================================================
# LOAD SETTINGS
#=================================================
app=$YNH_APP_INSTANCE_NAME
2021-01-11 23:46:48 +01:00
domain=$(ynh_app_setting_get --app=$app --key=domain)
port=$(ynh_app_setting_get --app=$app --key=port)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$db_name
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
2021-09-16 11:39:20 +02:00
data_path=$(ynh_app_setting_get --app=$app --key=data_path)
2015-10-21 13:03:49 +02:00
2017-10-10 14:09:26 +02:00
#=================================================
# STANDARD REMOVE
#=================================================
# REMOVE SERVICE FROM ADMIN PANEL
#=================================================
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
2021-01-11 23:46:48 +01:00
if ynh_exec_warn_less yunohost service status $app >/dev/null
then
ynh_script_progression --message="Removing $app service..." --weight=1
yunohost service remove $app
fi
2017-10-10 14:09:26 +02:00
#=================================================
# STOP AND REMOVE SERVICE
#=================================================
2021-01-11 23:46:48 +01:00
ynh_script_progression --message="Stopping and removing the systemd service..." --weight=1
2017-10-10 14:09:26 +02:00
2021-01-11 23:46:48 +01:00
# Remove the dedicated systemd config
ynh_remove_systemd_config
2017-10-10 14:09:26 +02:00
#=================================================
# REMOVE THE MySQL DATABASE
2017-10-10 14:09:26 +02:00
#=================================================
2021-01-11 23:46:48 +01:00
ynh_script_progression --message="Removing the MySQL database..." --weight=2
2015-10-21 13:03:49 +02:00
2021-01-11 23:46:48 +01:00
# Remove a database if it exists, along with the associated user
ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name
2015-10-21 13:03:49 +02:00
2017-10-10 14:09:26 +02:00
#=================================================
# REMOVE APP MAIN DIR
#=================================================
2021-01-11 23:46:48 +01:00
ynh_script_progression --message="Removing $app main directory..." --weight=6
# Remove the app directory securely
ynh_secure_remove --file="$final_path"
2021-10-03 11:24:09 +02:00
#=================================================
# REMOVE DATA DIR
#=================================================
# Remove the data directory if --purge option is used
if [ "${YNH_APP_PURGE:-0}" -eq 1 ]
then
ynh_script_progression --message="Removing app data directory..." --weight=1
ynh_secure_remove --file="$data_path"
fi
2017-10-10 14:09:26 +02:00
#=================================================
# REMOVE NGINX CONFIGURATION
#=================================================
2021-01-11 23:46:48 +01:00
ynh_script_progression --message="Removing NGINX web server configuration..." --weight=5
2015-10-21 14:33:49 +02:00
2021-01-11 23:46:48 +01:00
# Remove the dedicated NGINX config
ynh_remove_nginx_config
2015-10-21 14:33:49 +02:00
2021-01-11 23:46:48 +01:00
#=================================================
# REMOVE LOGROTATE CONFIGURATION
#=================================================
ynh_script_progression --message="Removing logrotate configuration..." --weight=1
# Remove the app-specific logrotate config
ynh_remove_logrotate
2017-10-10 14:09:26 +02:00
#=================================================
# REMOVE LOG FILE
#=================================================
2021-01-11 23:46:48 +01:00
ynh_secure_remove --file="/var/log/$app"
2017-10-10 14:09:26 +02:00
#=================================================
# REMOVE DEDICATED USER
#=================================================
2021-01-11 23:46:48 +01:00
ynh_script_progression --message="Removing the dedicated system user..." --weight=1
ynh_system_user_delete --username=$app
#=================================================
# END OF SCRIPT
#=================================================
2017-10-10 14:09:26 +02:00
2021-01-11 23:46:48 +01:00
ynh_script_progression --message="Removal of $app completed" --last