#!/bin/bash #================================================= # GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= source _common.sh source experimental_helper.sh source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= ynh_script_progression --message="Loading installation settings..." --weight=3 app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=special_domain) final_path=$(ynh_app_setting_get --app=$app --key=final_path) synapse_tls_port=$(ynh_app_setting_get --app=$app --key=synapse_tls_port) turnserver_tls_port=$(ynh_app_setting_get --app=$app --key=turnserver_tls_port) turnserver_alt_tls_port=$(ynh_app_setting_get --app=$app --key=turnserver_alt_tls_port) #================================================= # SET CONSTANTS #================================================= synapse_user="matrix-$app" synapse_db_name="matrix_$app" synapse_db_user="matrix_$app" upstream_version=$(ynh_app_upstream_version) #================================================= # STANDARD REMOVE #================================================= # REMOVE SERVICE FROM ADMIN PANEL #================================================= # Remove a service from the admin panel, added by `yunohost service add` if yunohost service status matrix-$app >/dev/null 2>&1 then yunohost service remove matrix-$app fi if yunohost service status coturn-$app >/dev/null 2>&1 then yunohost service remove coturn-$app fi #================================================= # STOP AND REMOVE SERVICE #================================================= ynh_script_progression --message="Stopping and removing the systemd service" --weight=2 ynh_remove_systemd_config --service=matrix-$app ynh_remove_systemd_config --service=coturn-$app #================================================= # REMOVE THE POSTGRESQL DATABASE #================================================= ynh_script_progression --message="Removing the PostgreSQL database" --weight=2 # Remove a database if it exists, along with the associated user ynh_psql_remove_db --db_user=$synapse_db_name --db_name=$synapse_db_user #================================================= # REMOVE DEPENDENCIES #================================================= ynh_script_progression --message="Removing dependencies" --weight=15 # Remove metapackage and its dependencies ynh_remove_app_dependencies #================================================= # SETUP SSOWAT #================================================= # Remove the skipped url python3 $final_path/remove_sso_conf.py #================================================= # REMOVE APP MAIN DIR #================================================= ynh_script_progression --message="Removing app main directory" --weight=2 ynh_secure_remove --file=$final_path ynh_secure_remove --file=/var/lib/matrix-$app ynh_secure_remove --file=/var/log/matrix-$app ynh_secure_remove --file=/etc/matrix-$app ynh_secure_remove --file=/etc/default/matrix-$app ynh_secure_remove --file=/etc/default/coturn-$app #================================================= # REMOVE NGINX CONFIGURATION #================================================= ynh_script_progression --message="Removing nginx web server configuration" --weight=2 # Remove the dedicated nginx config ynh_remove_nginx_config #================================================= # REMOVE LOGROTATE CONFIGURATION #================================================= ynh_script_progression --message="Removing logrotate configuration" --weight=1 # Remove the app-specific logrotate config ynh_remove_logrotate #================================================= # CLOSE A PORT #================================================= closeport() { local port=$1 if yunohost firewall list | grep -q "\- $port$" then ynh_script_progression --message="Closing port $port" ynh_exec_warn_less yunohost firewall disallow Both $port fi } closeport $synapse_tls_port closeport $turnserver_tls_port closeport $turnserver_alt_tls_port #================================================= # REMOVE FAIL2BAN CONFIGURATION #================================================= ynh_script_progression --message="Removing fail2ban configuration..." --weight=8 # Remove the dedicated fail2ban config ynh_remove_fail2ban_config #================================================= # GENERIC FINALIZATION #================================================= # REMOVE DEDICATED USER #================================================= ynh_script_progression --message="Removing the dedicated system user" --weight=1 # Delete a system user ynh_system_user_delete --username=$synapse_user #================================================= # END OF SCRIPT #================================================= ynh_script_progression --message="Removal of $app completed" --last