2018-04-17 00:02:25 +02:00
|
|
|
#!/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..."
|
2018-04-17 00:02:25 +02:00
|
|
|
|
|
|
|
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)
|
2018-04-17 00:02:25 +02:00
|
|
|
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)
|
2018-04-17 00:02:25 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# STANDARD REMOVE
|
2019-01-08 22:17:04 +01:00
|
|
|
#=================================================
|
|
|
|
# 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
|
2019-01-08 22:17:04 +01:00
|
|
|
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
|
2019-01-08 22:17:04 +01:00
|
|
|
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
|
2019-01-08 22:17:04 +01:00
|
|
|
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
|
|
|
|
|
|
|
systemctl stop "$app".target
|
|
|
|
|
|
|
|
# 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"
|
|
|
|
|
2018-04-17 00:02:25 +02:00
|
|
|
#=================================================
|
2019-04-03 14:35:09 +02:00
|
|
|
# REMOVE THE POSTGRESQL DATABASE
|
2018-04-17 00:02:25 +02:00
|
|
|
#=================================================
|
2019-04-03 14:35:09 +02:00
|
|
|
ynh_print_info "Removing the PostgreSQL database"
|
2018-04-17 00:02:25 +02:00
|
|
|
|
|
|
|
# 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-04-17 00:02:25 +02:00
|
|
|
|
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"
|
|
|
|
|
2018-04-17 00:02:25 +02:00
|
|
|
#=================================================
|
|
|
|
# REMOVE DEPENDENCIES
|
|
|
|
#=================================================
|
2019-04-03 14:35:09 +02:00
|
|
|
ynh_print_info "Removing dependencies"
|
2018-04-17 00:02:25 +02:00
|
|
|
|
|
|
|
# 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"
|
2018-04-17 00:02:25 +02:00
|
|
|
|
|
|
|
# Remove the app directory securely
|
|
|
|
ynh_secure_remove "$final_path"
|
|
|
|
|
2019-01-14 21:30:46 +01:00
|
|
|
ynh_secure_remove "/var/log/$app"
|
|
|
|
|
2018-04-17 00:02:25 +02:00
|
|
|
#=================================================
|
|
|
|
# REMOVE NGINX CONFIGURATION
|
|
|
|
#=================================================
|
2019-04-03 14:35:09 +02:00
|
|
|
ynh_print_info "Removing nginx web server configuration"
|
2018-04-17 00:02:25 +02:00
|
|
|
|
2018-05-11 19:07:23 +02:00
|
|
|
# remove domain specific configuration
|
2019-02-17 08:06:04 +01:00
|
|
|
funkwhale_nginx_domain_cleaning
|
2018-05-11 19:07:23 +02:00
|
|
|
|
2018-04-17 00:02:25 +02:00
|
|
|
# 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
|
|
|
|
|
2018-04-17 00:02:25 +02:00
|
|
|
#=================================================
|
|
|
|
# GENERIC FINALIZATION
|
2018-11-25 21:54:18 +01:00
|
|
|
#=================================================
|
|
|
|
# REMOVE FAIL2BAN CONFIGURATION
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
ynh_remove_fail2ban_config
|
|
|
|
|
2018-04-17 00:02:25 +02:00
|
|
|
#=================================================
|
|
|
|
# REMOVE DEDICATED USER
|
|
|
|
#=================================================
|
2019-04-03 14:35:09 +02:00
|
|
|
ynh_print_info "Removing the dedicated system user"
|
2018-04-17 00:02:25 +02:00
|
|
|
|
|
|
|
# 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"
|