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
Pierre de La Morinerie b4f05f6449 scripts: move logs to a subdirectory of /var/log
This allows to give permission to the `mattermost` user to
write new files in this subdirectory, which is needed for
log rotation.

Fix #61
2017-10-17 10:36:25 +05:30

79 lines
2.1 KiB
Bash
Executable file

#!/bin/bash
set -u # treat unset variables as an error
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get mattermost domain)
db_name="mattermost"
db_user="mmuser"
final_path="/var/www/$app"
data_path="/home/yunohost.app/$app"
logs_path="/var/log/$app"
#=================================================
# STANDARD REMOVE
#=================================================
# STOP AND REMOVE SERVICE
#=================================================
# Remove systemd service
if $(sudo systemctl -q is-active "$app"); then
sudo systemctl stop "$app"
fi
ynh_remove_systemd_config
# Legacy, for older versions of this app which used supervisor
if [ -f "/etc/supervisor/conf.d/${app}.conf" ]; then
sudo supervisorctl stop "$app"
sudo rm -f "/etc/supervisor/conf.d/${app}.conf"
fi
#=================================================
# REMOVE SERVICE FROM ADMIN PANEL
#=================================================
if sudo yunohost service status | grep -q "$app"; then
sudo yunohost service remove "$app"
fi
#=================================================
# REMOVE THE MYSQL DATABASE
#=================================================
ynh_mysql_remove_db "$db_user" "$db_name"
#=================================================
# REMOVE APP MAIN DIR
#=================================================
ynh_secure_remove "$final_path"
ynh_secure_remove "$data_path"
#=================================================
# REMOVE NGINX CONFIGURATION
#=================================================
ynh_remove_nginx_config
#=================================================
# REMOVE LOG FILE
#=================================================
sudo rm -rf "$logs_path"
#=================================================
# REMOVE DEDICATED USER
#=================================================
ynh_system_user_delete "$app"