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

143 lines
4.3 KiB
Text
Raw Normal View History

#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
2019-04-03 14:35:09 +02:00
ynh_print_info "Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get $app domain)
2019-04-03 14:35:09 +02:00
port=$(ynh_app_setting_get $app port)
db_name=$(ynh_app_setting_get $app db_name)
db_user=$db_name
final_path=$(ynh_app_setting_get $app final_path)
2018-05-12 23:57:20 +02:00
redis_db=$(ynh_app_setting_get $app redis_db)
#=================================================
# STANDARD REMOVE
#=================================================
# REMOVE SERVICE FROM ADMIN PANEL
#=================================================
# Remove a service from the admin panel, added by `yunohost service add`
2019-04-03 14:35:09 +02:00
if yunohost service status "$app-server" >/dev/null 2>&1
then
echo "Remove $app-server service"
yunohost service remove "$app-server"
fi
2019-04-03 14:35:09 +02:00
if yunohost service status "$app-worker" >/dev/null 2>&1
then
echo "Remove $app-worker service"
yunohost service remove "$app-worker"
fi
2019-04-03 14:35:09 +02:00
if yunohost service status "$app-beat" >/dev/null 2>&1
then
echo "Remove $app-beat service"
yunohost service remove "$app-beat"
fi
2019-01-14 21:30:46 +01:00
#=================================================
# STOP AND REMOVE SERVICE
#=================================================
2019-04-03 14:35:09 +02:00
ynh_print_info "Stopping and removing the systemd service"
2019-01-14 21:30:46 +01:00
2019-04-12 15:47:49 +02:00
ynh_systemd_action --action=stop --service_name=${app}-beat --log_path=systemd --line_match="Stopped Funkwhale"
ynh_systemd_action --action=stop --service_name=${app}-server --log_path=systemd --line_match="Stopped Funkwhale"
ynh_systemd_action --action=stop --service_name=${app}-worker --log_path=systemd --line_match="Stopped Funkwhale"
2019-01-14 21:30:46 +01:00
# Remove the dedicated systemd config
ynh_remove_systemd_config "$app-server"
ynh_remove_systemd_config "$app-worker"
ynh_remove_systemd_config "$app-beat"
ynh_secure_remove "/etc/systemd/system/$app.target"
#=================================================
2019-04-03 14:35:09 +02:00
# REMOVE THE POSTGRESQL DATABASE
#=================================================
2019-04-03 14:35:09 +02:00
ynh_print_info "Removing the PostgreSQL database"
# Remove a database if it exists, along with the associated user
2019-04-12 01:46:28 +02:00
ynh_psql_remove_db --db_name="$db_name" --db_user="$app"
2018-05-12 23:57:20 +02:00
#=================================================
2019-04-03 14:35:09 +02:00
# REMOVE THE REDIS DATABASE
2018-05-12 23:57:20 +02:00
#=================================================
2019-04-03 14:35:09 +02:00
ynh_print_info "Removing the Redis database"
2018-05-12 23:57:20 +02:00
# Remove a database if it exists, along with the associated user
ynh_redis_remove_db "$redis_db"
#=================================================
# REMOVE DEPENDENCIES
#=================================================
2019-04-03 14:35:09 +02:00
ynh_print_info "Removing dependencies"
# Remove metapackage and its dependencies
ynh_remove_app_dependencies
#=================================================
# REMOVE APP MAIN DIR
#=================================================
2019-04-03 14:35:09 +02:00
ynh_print_info "Removing app main directory"
# Remove the app directory securely
ynh_secure_remove "$final_path"
2019-01-14 21:30:46 +01:00
ynh_secure_remove "/var/log/$app"
#=================================================
# REMOVE NGINX CONFIGURATION
#=================================================
2019-04-03 14:35:09 +02:00
ynh_print_info "Removing nginx web server configuration"
# remove domain specific configuration
funkwhale_nginx_domain_cleaning
# Remove the dedicated nginx config
ynh_remove_nginx_config
2018-05-10 23:20:19 +02:00
#=================================================
# CLOSE A PORT
#=================================================
if yunohost firewall list | grep -q "\- $port$"
then
2019-04-03 14:35:09 +02:00
ynh_print_info "Closing port $port"
ynh_exec_warn_less yunohost firewall disallow TCP $port
2018-05-10 23:20:19 +02:00
fi
#=================================================
# GENERIC FINALIZATION
2018-11-25 21:54:18 +01:00
#=================================================
# REMOVE FAIL2BAN CONFIGURATION
#=================================================
ynh_remove_fail2ban_config
#=================================================
# REMOVE DEDICATED USER
#=================================================
2019-04-03 14:35:09 +02:00
ynh_print_info "Removing the dedicated system user"
# Delete a system user
2019-04-03 14:35:09 +02:00
ynh_system_user_delete "$app"
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info "Removal of $app completed"