2016-04-29 16:32:48 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2017-07-18 13:03:45 +02:00
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
2021-06-30 17:01:55 +02:00
|
|
|
source _common.sh
|
2017-07-18 13:03:45 +02:00
|
|
|
source /usr/share/yunohost/helpers
|
2021-06-30 17:01:55 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# LOAD SETTINGS
|
|
|
|
#=================================================
|
2023-02-16 09:55:28 +01:00
|
|
|
#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1
|
2017-07-18 13:03:45 +02:00
|
|
|
|
2023-02-16 09:55:28 +01:00
|
|
|
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
|
2016-04-29 16:32:48 +02:00
|
|
|
|
2023-02-16 09:55:28 +01:00
|
|
|
#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
|
|
|
|
#REMOVEME? port=$(ynh_app_setting_get --app=$app --key=port)
|
|
|
|
#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
|
|
|
#REMOVEME? db_user=$db_name
|
|
|
|
#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
|
2016-04-29 16:32:48 +02:00
|
|
|
|
2021-06-30 17:01:55 +02:00
|
|
|
#=================================================
|
|
|
|
# STANDARD REMOVE
|
|
|
|
#=================================================
|
|
|
|
# REMOVE SERVICE INTEGRATION IN YUNOHOST
|
|
|
|
#=================================================
|
|
|
|
|
2022-06-26 20:30:44 +02:00
|
|
|
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
|
2021-06-30 17:01:55 +02:00
|
|
|
if ynh_exec_warn_less yunohost service status $app >/dev/null
|
|
|
|
then
|
2022-06-27 02:49:41 +02:00
|
|
|
ynh_script_progression --message="Removing $app service integration..." --weight=1
|
2021-06-30 17:01:55 +02:00
|
|
|
yunohost service remove $app
|
|
|
|
fi
|
2017-07-19 13:32:24 +02:00
|
|
|
|
2021-06-30 17:01:55 +02:00
|
|
|
#=================================================
|
|
|
|
# STOP AND REMOVE SERVICE
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Stopping and removing the systemd service..." --weight=1
|
|
|
|
|
|
|
|
# Remove the dedicated systemd config
|
|
|
|
ynh_remove_systemd_config
|
|
|
|
|
2021-11-13 23:17:56 +01:00
|
|
|
#=================================================
|
|
|
|
# REMOVE LOGROTATE CONFIGURATION
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Removing logrotate configuration..." --weight=1
|
|
|
|
|
|
|
|
# Remove the app-specific logrotate config
|
|
|
|
ynh_remove_logrotate
|
|
|
|
|
2021-06-30 17:01:55 +02:00
|
|
|
#=================================================
|
|
|
|
# REMOVE THE MONGODB DATABASE
|
|
|
|
#=================================================
|
2022-10-01 19:11:02 +02:00
|
|
|
ynh_script_progression --message="Removing the MongoDB database..." --weight=11
|
2021-06-30 17:01:55 +02:00
|
|
|
|
2022-07-12 09:33:07 +02:00
|
|
|
ynh_replace_string --match_string="engine: wiredTiger" --replace_string="# engine:" --target_file="/etc/mongod.conf"
|
|
|
|
ynh_replace_string --match_string="replication:" --replace_string="#replication:" --target_file="/etc/mongod.conf"
|
|
|
|
ynh_replace_string --match_string=" replSetName: rs01" --replace_string="" --target_file="/etc/mongod.conf"
|
2022-06-27 02:49:41 +02:00
|
|
|
|
2022-07-12 09:33:07 +02:00
|
|
|
ynh_systemd_action --service_name=mongod --action=restart --log_path=/var/log/mongodb/mongod.log --line_match="Waiting for connections"
|
2022-06-27 02:49:41 +02:00
|
|
|
|
2021-06-30 17:01:55 +02:00
|
|
|
# Remove a database if it exists, along with the associated user
|
|
|
|
ynh_mongo_remove_db --db_user=$db_user --db_name=$db_name
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# REMOVE APP MAIN DIR
|
|
|
|
#=================================================
|
2023-02-16 09:55:28 +01:00
|
|
|
#REMOVEME? ynh_script_progression --message="Removing app main directory..." --weight=2
|
2021-06-30 17:01:55 +02:00
|
|
|
|
|
|
|
# Remove the app directory securely
|
2023-02-16 09:55:28 +01:00
|
|
|
#REMOVEME? ynh_secure_remove --file="$install_dir"
|
2021-06-30 17:01:55 +02:00
|
|
|
|
2021-11-19 13:47:53 +01:00
|
|
|
if [ -d "/tmp/ufs" ]; then
|
|
|
|
ynh_secure_remove --file="/tmp/ufs"
|
|
|
|
fi
|
|
|
|
|
2021-06-30 17:01:55 +02:00
|
|
|
#=================================================
|
|
|
|
# REMOVE NGINX CONFIGURATION
|
|
|
|
#=================================================
|
2021-06-30 19:03:49 +02:00
|
|
|
ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1
|
2021-06-30 17:01:55 +02:00
|
|
|
|
2022-01-30 10:37:53 +01:00
|
|
|
# Remove the dedicated NGINX config
|
2021-06-30 17:01:55 +02:00
|
|
|
ynh_remove_nginx_config
|
|
|
|
|
2022-06-26 20:30:44 +02:00
|
|
|
#=================================================
|
|
|
|
# REMOVE DEPENDENCIES
|
|
|
|
#=================================================
|
2023-02-16 09:55:28 +01:00
|
|
|
#REMOVEME? ynh_script_progression --message="Removing dependencies..." --weight=4
|
2022-06-26 20:30:44 +02:00
|
|
|
|
|
|
|
# Remove metapackage and its dependencies
|
2023-02-16 09:55:28 +01:00
|
|
|
#REMOVEME? ynh_remove_app_dependencies
|
2022-06-27 02:49:41 +02:00
|
|
|
ynh_remove_nodejs
|
|
|
|
ynh_remove_mongo
|
2022-06-26 20:30:44 +02:00
|
|
|
|
2021-06-30 17:01:55 +02:00
|
|
|
#=================================================
|
|
|
|
# GENERIC FINALIZATION
|
|
|
|
#=================================================
|
|
|
|
# REMOVE DEDICATED USER
|
|
|
|
#=================================================
|
2023-02-16 09:55:28 +01:00
|
|
|
#REMOVEME? ynh_script_progression --message="Removing the dedicated system user..." --weight=1
|
2021-06-30 17:01:55 +02:00
|
|
|
|
|
|
|
# Delete a system user
|
2023-02-16 09:55:28 +01:00
|
|
|
#REMOVEME? ynh_system_user_delete --username=$app
|
2021-06-30 17:01:55 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
2017-07-21 14:35:08 +02:00
|
|
|
|
2021-06-30 17:01:55 +02:00
|
|
|
ynh_script_progression --message="Removal of $app completed" --last
|