1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/synapse_ynh.git synced 2024-09-03 20:26:38 +02:00
synapse_ynh/scripts/remove
2018-01-31 23:06:06 +01:00

119 lines
3.4 KiB
Bash
Executable file

#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source /usr/share/yunohost/helpers
# Don't execute the command witch don't have all variable set
set -u
# Import common cmd
source ./psql.sh
source ./experimental_helper.sh
source ./_common.sh
#=================================================
# SET ALL CONSTANT
#=================================================
app=$YNH_APP_INSTANCE_NAME
synapse_user="matrix-$app"
synapse_db_name="matrix_$app"
synapse_db_user="matrix_$app"
upstream_version=$(ynh_app_upstream_version)
#=================================================
# LOAD SETTINGS
#=================================================
domain=$(ynh_app_setting_get $app special_domain)
final_path=$(ynh_app_setting_get $app final_path)
synapse_tls_port=$(ynh_app_setting_get $app synapse_tls_port)
turnserver_tls_port=$(ynh_app_setting_get $app turnserver_tls_port)
turnserver_alt_tls_port=$(ynh_app_setting_get $app turnserver_alt_tls_port)
#=================================================
# STANDARD REMOVE
#=================================================
# STOP AND REMOVE SERVICE
#=================================================
ynh_remove_systemd_config matrix-$YNH_APP_INSTANCE_NAME
ynh_remove_systemd_config coturn-$YNH_APP_INSTANCE_NAME
#=================================================
# CLOSE A PORT
#=================================================
closeport() {
if yunohost firewall list | grep -q "\- $port$"
then
echo "Close port $port"
yunohost firewall disallow Both $port > /dev/null
fi
}
port=$synapse_tls_port
closeport
port=$turnserver_tls_port
closeport
port=$turnserver_alt_tls_port
closeport
#=================================================
# SETUP SSOWAT
#=================================================
# Remove the skipped url
python $final_path/remove_sso_conf.py
#=================================================
# REMOVE DEPENDENCIES
#=================================================
ynh_remove_app_dependencies || true
#=================================================
# REMOVE APP DIR
#=================================================
ynh_secure_remove $final_path
ynh_secure_remove /var/lib/matrix-$YNH_APP_INSTANCE_NAME
ynh_secure_remove /var/log/matrix-$YNH_APP_INSTANCE_NAME
ynh_secure_remove /etc/matrix-$YNH_APP_INSTANCE_NAME
ynh_secure_remove /etc/default/matrix-$YNH_APP_INSTANCE_NAME
ynh_secure_remove /etc/default/coturn-$YNH_APP_INSTANCE_NAME
#=================================================
# REMOVE NGINX CONFIGURATION
#=================================================
ynh_remove_nginx_config
#=================================================
# REMOVE THE POSTGRESQL DATABASE
#=================================================
ynh_psql_remove_db $synapse_db_name $synapse_db_user
#=================================================
# REMOVE DEDICATED USER
#=================================================
ynh_system_user_delete matrix-$YNH_APP_INSTANCE_NAME
#=================================================
# REMOVE LOGROTATE CONFIGURATION
#=================================================
ynh_remove_logrotate
#=================================================
# REMOVE SERVICE FROM ADMIN PANEL
#=================================================
yunohost service remove matrix-$YNH_APP_INSTANCE_NAME