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

155 lines
5.2 KiB
Text
Raw Permalink Normal View History

2017-02-13 20:43:41 +01:00
#!/bin/bash
2018-01-30 23:44:49 +01:00
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
2019-04-30 19:15:33 +02:00
source _common.sh
source experimental_helper.sh
source /usr/share/yunohost/helpers
2018-01-30 23:44:49 +01:00
#=================================================
2019-04-30 19:15:33 +02:00
# LOAD SETTINGS
2018-01-30 23:44:49 +01:00
#=================================================
2019-04-30 19:15:33 +02:00
ynh_script_progression --message="Loading installation settings..." --weight=3
2018-01-30 23:44:49 +01:00
app=$YNH_APP_INSTANCE_NAME
2019-04-30 19:15:33 +02:00
domain=$(ynh_app_setting_get --app=$app --key=domain)
well-known support (#136) * Update README.md * Update manifest.json * a * Delete a * avoid boolean for public but ask a clear choice Yes/No * Update check_process Add server_name="domain2.tld" (DOMAIN) * .well-known DNS conf become optionnal with .well-known edition * .well-known redirection for access by federation Create .well-known redirection for access by federation * .well-known redirection for access by federation If not existing, create .well-known redirection for access by federation * Update README.md back to 0.99.5.2 * back to 0.99.5.2 * back to 0.99.5.2 * back to 0.99.5.2 * Update install * Update upgrade * Update install * Update upgrade * Update install * Update upgrade * Update .well-known redirection for access by federation and applications like Riot.im * Update .well-known redirection for access by federation and applications like Riot.im * update to 1.1.0 * update to 1.1.0 * update to 1.1.0 * update to 1.1.0 * update to 1.1.0 * update to 1.1.0 * Update install * Update upgrade * Update to 1.2.1 * Update to 1.2.1 * Update to 1.2.1 * Back to v1.1.0 * Back to v1.1.0 * Back to v1.1.0 * Update to v1.2.1 * Update to v1.2.1 * Update to v1.2.1 * Important update of upgrade script ynh_replace_string __SERVER_NAME__ $server_name "$homeserver_config_path" was missing * Back to v1.1.0 * Back to v1.1.0 * Back to v1.1.0 * Fix typo for ipv6 validation * Upgrade to v1.2.1 * Upgrade to v1.2.1 * Upgrade to v1.2.1 * remove server_name's nginx conf remove /etc/nginx/conf.d/${server_name}.d/server_name.conf * Create server_name.conf To allow the automatic well-known system for server-name detection instead of DNS record * Update install In # Create .well-known redirection for access by federation change cat > /etc/nginx/conf.d/${server_name}.d/server_name.conf <<EOF location /.well-known/matrix/ { return 200 '{"m.server": "$domain", "m.homeserver": "https://$domain"}'; add_header Content-Type application/json; add_header Access-Control-Allow-Origin '*'; } EOF to cp ../conf/server_name.conf /etc/nginx/conf.d/${server_name}.d/server_name.conf after creation of ../conf/server_name.conf file. * Update upgrade In # Create .well-known redirection for access by federation if it doesn't exist change cat > /etc/nginx/conf.d/${server_name}.d/server_name.conf <<EOF location /.well-known/matrix/ { return 200 '{"m.server": "$domain", "m.homeserver": "https://$domain"}'; add_header Content-Type application/json; add_header Access-Control-Allow-Origin '*'; } EOF to cp ../conf/server_name.conf /etc/nginx/conf.d/${server_name}.d/server_name.conf * backup well.known server_name nginx cond add ynh_backup "/etc/nginx/conf.d/${server_name}.d/server_name.conf" * Backup well.known server-name nging conf add server_name=$(ynh_app_setting_get $app server_name) to make ynh_backup "/etc/nginx/conf.d/${server_name}.d/server_name.conf" understood * Update backup * Update scripts/install Co-Authored-By: Josue-T <josue@tille.ch> * Update install * Update README.md Co-Authored-By: Josue-T <josue@tille.ch> * Update scripts/upgrade Co-Authored-By: Josue-T <josue@tille.ch> * Update conf/server_name.conf Co-Authored-By: Josue-T <josue@tille.ch> * move .well-known redirection to config section move #Create .well-known redirection for access by federation to end of config section * move .well-known redirection to config section move #Create .well-known redirection to the end of config section and Indentation * add checksum management for server_name.conf add checksum management for server_name.conf with the helper ynh_store_file_checksum * add checksum management for server_name.conf add checksum management for server_name.conf with the helper ynh_store_file_checksum * replace __SERVER_NAME__ * replace __SERVER_NAME__ * delete a blank line * Update upgrade * Update install * Update check_process Co-Authored-By: Josue-T <josue@tille.ch> * Update conf/server_name.conf Co-Authored-By: Josue-T <josue@tille.ch> * remove blank line * ynh_store_file_checksum after cp inside if block * change order checksum and cp change order to ynh_backup_if_checksum_is_different then cp then ynh_store_file_checksum * Update install * Update upgrade * Update backup * Update backup * Update scripts/backup Co-Authored-By: Josue-T <josue@tille.ch> * Update scripts/install Co-Authored-By: Josue-T <josue@tille.ch> * Update scripts/install Co-Authored-By: Josue-T <josue@tille.ch> * Update scripts/install Co-Authored-By: Josue-T <josue@tille.ch> * Update install * Update remove * Update upgrade
2019-12-01 22:18:56 +01:00
server_name=$(ynh_app_setting_get --app=$app --key=server_name)
2019-04-30 19:15:33 +02:00
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
#=================================================
2018-01-30 23:44:49 +01:00
synapse_user="matrix-$app"
2022-05-26 17:27:30 +02:00
synapse_user_app="$app"
2018-01-30 23:44:49 +01:00
synapse_db_name="matrix_$app"
synapse_db_user="matrix_$app"
2021-02-18 09:16:37 +01:00
synapse_db_name="matrix_$app"
2018-01-30 23:44:49 +01:00
upstream_version=$(ynh_app_upstream_version)
final_www_path="/var/www/$app"
2018-01-30 23:44:49 +01:00
#=================================================
2019-04-30 19:15:33 +02:00
# STANDARD REMOVE
#=================================================
# REMOVE SERVICE FROM ADMIN PANEL
2018-01-30 23:44:49 +01:00
#=================================================
2019-04-30 19:15:33 +02:00
# 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
2017-02-13 20:43:41 +01:00
2018-01-30 23:44:49 +01:00
#=================================================
# STOP AND REMOVE SERVICE
#=================================================
2019-04-30 19:15:33 +02:00
ynh_script_progression --message="Stopping and removing the systemd service" --weight=2
2018-01-30 23:44:49 +01:00
2019-04-30 19:15:33 +02:00
ynh_remove_systemd_config --service=matrix-$app
ynh_remove_systemd_config --service=coturn-$app
2018-01-30 23:44:49 +01:00
#=================================================
2019-04-30 19:15:33 +02:00
# REMOVE THE POSTGRESQL DATABASE
2018-01-30 23:44:49 +01:00
#=================================================
2019-04-30 19:15:33 +02:00
ynh_script_progression --message="Removing the PostgreSQL database" --weight=2
2017-02-13 20:43:41 +01:00
2019-04-30 19:15:33 +02:00
# 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
2017-02-13 20:43:41 +01:00
2018-01-30 23:44:49 +01:00
#=================================================
2019-04-30 19:15:33 +02:00
# REMOVE DEPENDENCIES
2018-01-30 23:44:49 +01:00
#=================================================
2019-04-30 19:15:33 +02:00
ynh_script_progression --message="Removing dependencies" --weight=15
2018-01-30 23:44:49 +01:00
2019-04-30 19:15:33 +02:00
# Remove metapackage and its dependencies
ynh_remove_app_dependencies
2018-01-30 23:44:49 +01:00
#=================================================
2019-04-30 19:15:33 +02:00
# REMOVE APP MAIN DIR
2018-01-30 23:44:49 +01:00
#=================================================
2019-04-30 19:15:33 +02:00
ynh_script_progression --message="Removing app main directory" --weight=2
2018-01-30 23:44:49 +01:00
2019-04-30 19:15:33 +02:00
ynh_secure_remove --file=$final_path
ynh_secure_remove --file=$final_www_path
2019-04-30 19:15:33 +02:00
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
well-known support (#136) * Update README.md * Update manifest.json * a * Delete a * avoid boolean for public but ask a clear choice Yes/No * Update check_process Add server_name="domain2.tld" (DOMAIN) * .well-known DNS conf become optionnal with .well-known edition * .well-known redirection for access by federation Create .well-known redirection for access by federation * .well-known redirection for access by federation If not existing, create .well-known redirection for access by federation * Update README.md back to 0.99.5.2 * back to 0.99.5.2 * back to 0.99.5.2 * back to 0.99.5.2 * Update install * Update upgrade * Update install * Update upgrade * Update install * Update upgrade * Update .well-known redirection for access by federation and applications like Riot.im * Update .well-known redirection for access by federation and applications like Riot.im * update to 1.1.0 * update to 1.1.0 * update to 1.1.0 * update to 1.1.0 * update to 1.1.0 * update to 1.1.0 * Update install * Update upgrade * Update to 1.2.1 * Update to 1.2.1 * Update to 1.2.1 * Back to v1.1.0 * Back to v1.1.0 * Back to v1.1.0 * Update to v1.2.1 * Update to v1.2.1 * Update to v1.2.1 * Important update of upgrade script ynh_replace_string __SERVER_NAME__ $server_name "$homeserver_config_path" was missing * Back to v1.1.0 * Back to v1.1.0 * Back to v1.1.0 * Fix typo for ipv6 validation * Upgrade to v1.2.1 * Upgrade to v1.2.1 * Upgrade to v1.2.1 * remove server_name's nginx conf remove /etc/nginx/conf.d/${server_name}.d/server_name.conf * Create server_name.conf To allow the automatic well-known system for server-name detection instead of DNS record * Update install In # Create .well-known redirection for access by federation change cat > /etc/nginx/conf.d/${server_name}.d/server_name.conf <<EOF location /.well-known/matrix/ { return 200 '{"m.server": "$domain", "m.homeserver": "https://$domain"}'; add_header Content-Type application/json; add_header Access-Control-Allow-Origin '*'; } EOF to cp ../conf/server_name.conf /etc/nginx/conf.d/${server_name}.d/server_name.conf after creation of ../conf/server_name.conf file. * Update upgrade In # Create .well-known redirection for access by federation if it doesn't exist change cat > /etc/nginx/conf.d/${server_name}.d/server_name.conf <<EOF location /.well-known/matrix/ { return 200 '{"m.server": "$domain", "m.homeserver": "https://$domain"}'; add_header Content-Type application/json; add_header Access-Control-Allow-Origin '*'; } EOF to cp ../conf/server_name.conf /etc/nginx/conf.d/${server_name}.d/server_name.conf * backup well.known server_name nginx cond add ynh_backup "/etc/nginx/conf.d/${server_name}.d/server_name.conf" * Backup well.known server-name nging conf add server_name=$(ynh_app_setting_get $app server_name) to make ynh_backup "/etc/nginx/conf.d/${server_name}.d/server_name.conf" understood * Update backup * Update scripts/install Co-Authored-By: Josue-T <josue@tille.ch> * Update install * Update README.md Co-Authored-By: Josue-T <josue@tille.ch> * Update scripts/upgrade Co-Authored-By: Josue-T <josue@tille.ch> * Update conf/server_name.conf Co-Authored-By: Josue-T <josue@tille.ch> * move .well-known redirection to config section move #Create .well-known redirection for access by federation to end of config section * move .well-known redirection to config section move #Create .well-known redirection to the end of config section and Indentation * add checksum management for server_name.conf add checksum management for server_name.conf with the helper ynh_store_file_checksum * add checksum management for server_name.conf add checksum management for server_name.conf with the helper ynh_store_file_checksum * replace __SERVER_NAME__ * replace __SERVER_NAME__ * delete a blank line * Update upgrade * Update install * Update check_process Co-Authored-By: Josue-T <josue@tille.ch> * Update conf/server_name.conf Co-Authored-By: Josue-T <josue@tille.ch> * remove blank line * ynh_store_file_checksum after cp inside if block * change order checksum and cp change order to ynh_backup_if_checksum_is_different then cp then ynh_store_file_checksum * Update install * Update upgrade * Update backup * Update backup * Update scripts/backup Co-Authored-By: Josue-T <josue@tille.ch> * Update scripts/install Co-Authored-By: Josue-T <josue@tille.ch> * Update scripts/install Co-Authored-By: Josue-T <josue@tille.ch> * Update scripts/install Co-Authored-By: Josue-T <josue@tille.ch> * Update install * Update remove * Update upgrade
2019-12-01 22:18:56 +01:00
ynh_secure_remove --file=/etc/nginx/conf.d/${server_name}.d/${app}_server_name.conf
2018-01-30 23:44:49 +01:00
#=================================================
# REMOVE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Removing NGINX web server configuration" --weight=2
2018-01-30 23:44:49 +01:00
2019-04-30 19:15:33 +02:00
# Remove the dedicated nginx config
ynh_remove_nginx_config
# Remove the dedicated php-fpm config
ynh_remove_fpm_config
2018-01-30 23:44:49 +01:00
#=================================================
2019-04-30 19:15:33 +02:00
# REMOVE LOGROTATE CONFIGURATION
2018-01-30 23:44:49 +01:00
#=================================================
2019-04-30 19:15:33 +02:00
ynh_script_progression --message="Removing logrotate configuration" --weight=1
2019-04-30 19:15:33 +02:00
# Remove the app-specific logrotate config
ynh_remove_logrotate
2018-01-30 23:44:49 +01:00
#=================================================
2019-04-30 19:15:33 +02:00
# CLOSE A PORT
2018-01-30 23:44:49 +01:00
#=================================================
2019-04-30 19:15:33 +02:00
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
2019-02-12 21:24:25 +01:00
#=================================================
2019-04-30 19:15:33 +02:00
# REMOVE FAIL2BAN CONFIGURATION
2019-02-12 21:24:25 +01:00
#=================================================
ynh_script_progression --message="Removing Fail2Ban configuration..." --weight=8
2019-02-12 21:24:25 +01:00
2019-04-30 19:15:33 +02:00
# Remove the dedicated fail2ban config
ynh_remove_fail2ban_config
2019-02-12 21:24:25 +01:00
2018-01-30 23:44:49 +01:00
#=================================================
2019-04-30 19:15:33 +02:00
# GENERIC FINALIZATION
2018-01-30 23:44:49 +01:00
#=================================================
2019-04-30 19:15:33 +02:00
# REMOVE DEDICATED USER
#=================================================
ynh_script_progression --message="Removing the dedicated system user" --weight=1
2018-01-30 23:44:49 +01:00
2019-04-30 19:15:33 +02:00
# Delete a system user
ynh_system_user_delete --username=$synapse_user
yunohost user delete $synapse_user_app
2017-02-13 20:43:41 +01:00
2018-01-30 23:44:49 +01:00
#=================================================
2019-04-30 19:15:33 +02:00
# END OF SCRIPT
2018-01-30 23:44:49 +01:00
#=================================================
2020-12-07 16:34:41 +01:00
ynh_print_info --message="Due of the backup core only feature the data directory in '/home/yunohost.app/matrix-$app' was not removed. It need to be removed manually to purge app user data."
2018-01-30 23:44:49 +01:00
2019-04-30 19:15:33 +02:00
ynh_script_progression --message="Removal of $app completed" --last
2020-12-07 16:34:41 +01:00
sleep 1