libreerp_ynh/scripts/remove

96 lines
3.1 KiB
Text
Raw Normal View History

2015-09-14 17:12:17 +02:00
#!/bin/bash
2016-07-05 15:22:12 +02:00
2022-02-13 22:09:18 +01:00
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
2017-05-18 23:28:18 +02:00
source _common.sh
2022-02-13 22:09:18 +01:00
source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..."
2017-05-18 23:28:18 +02:00
app=$YNH_APP_INSTANCE_NAME
2022-02-13 22:09:18 +01:00
domain=$(ynh_app_setting_get --app=$app --key=domain)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$db_name
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
conf_file=$(ynh_app_setting_get --app=$app --key=conf_file)
2016-07-05 15:22:12 +02:00
2022-02-13 22:09:18 +01:00
#=================================================
# STANDARD REMOVE
#=================================================
# REMOVE SERVICE INTEGRATION IN YUNOHOST
#=================================================
2016-07-05 15:22:12 +02:00
2022-02-13 22:09:18 +01:00
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
if ynh_exec_warn_less yunohost service status $app >/dev/null
then
ynh_script_progression --message="Removing $app service integration..."
yunohost service remove $app
fi
2018-12-14 03:36:58 +01:00
2022-02-13 22:09:18 +01:00
#=================================================
# REMOVE THE MYSQL DATABASE
#=================================================
ynh_script_progression --message="Removing the MySQL database..."
2017-05-18 23:28:18 +02:00
2022-02-13 22:09:18 +01:00
# Remove a database if it exists, along with the associated user
ynh_psql_remove_db --db_user=$db_user --db_name=$db_name
#=================================================
# REMOVE APP MAIN DIR
#=================================================
ynh_script_progression --message="Removing app main directory..."
2022-02-13 22:09:18 +01:00
# Remove the app directory securely
ynh_secure_remove --file="$final_path"
2015-09-14 17:12:17 +02:00
2022-02-13 22:09:18 +01:00
#=================================================
# REMOVE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Removing NGINX web server configuration..."
# Remove the dedicated NGINX config
2018-12-14 03:36:58 +01:00
ynh_remove_nginx_config
2018-09-27 00:31:17 +02:00
2022-02-13 22:09:18 +01:00
#=================================================
# REMOVE DEPENDENCIES
#=================================================
ynh_script_progression --message="Removing dependencies..."
# Remove metapackage and its dependencies
ynh_remove_app_dependencies
#=================================================
# SPECIFIC REMOVE
#=================================================
# REMOVE VARIOUS FILES
#=================================================
ynh_script_progression --message="Removing various files..."
ynh_secure_remove --file="$conf_file"
2018-09-27 00:31:17 +02:00
ynh_del_swap
2022-02-13 22:09:18 +01:00
#=================================================
# GENERIC FINALIZATION
#=================================================
# REMOVE DEDICATED USER
#=================================================
ynh_script_progression --message="Removing the dedicated system user..."
# Delete a system user
ynh_system_user_delete --username=$app
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Removal of $app completed"