2022-12-27 17:59:56 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
source _common.sh
|
|
|
|
source ynh_mongo_db__2
|
|
|
|
source ynh_java
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# LOAD SETTINGS
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Loading installation settings..." --weight=1
|
|
|
|
|
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
|
|
|
|
|
|
|
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
2022-12-29 10:06:04 +01:00
|
|
|
port_ide=$(ynh_app_setting_get --app=$app --key=port_ide)
|
|
|
|
port_preview=$(ynh_app_setting_get --app=$app --key=port_preview)
|
|
|
|
port_project=$(ynh_app_setting_get --app=$app --key=port_project)
|
|
|
|
port_data=$(ynh_app_setting_get --app=$app --key=port_data)
|
2022-12-27 17:59:56 +01:00
|
|
|
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)
|
|
|
|
|
2022-12-29 10:06:04 +01:00
|
|
|
SERVICES_LIST=(ide preview project data)
|
|
|
|
PORT_LIST=($port_ide $port_preview $port_project $port_data)
|
|
|
|
|
2022-12-27 17:59:56 +01:00
|
|
|
#=================================================
|
|
|
|
# STANDARD REMOVE
|
|
|
|
#=================================================
|
|
|
|
# REMOVE SERVICE INTEGRATION IN YUNOHOST
|
|
|
|
#=================================================
|
2022-12-29 10:06:04 +01:00
|
|
|
ynh_script_progression --message="Removing $app services..." --weight=1
|
2022-12-27 17:59:56 +01:00
|
|
|
|
|
|
|
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
|
2022-12-29 10:06:04 +01:00
|
|
|
for service_name in "${SERVICES_LIST[@]}"
|
|
|
|
do
|
|
|
|
if ynh_exec_warn_less yunohost service status "${app}-${service_name}" >/dev/null
|
|
|
|
then
|
|
|
|
yunohost service remove "${app}-${service_name}"
|
|
|
|
fi
|
|
|
|
done
|
2022-12-27 17:59:56 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# STOP AND REMOVE SERVICE
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Stopping and removing the systemd service..." --weight=1
|
|
|
|
|
|
|
|
# Remove the dedicated systemd config
|
2022-12-29 10:06:04 +01:00
|
|
|
for service_name in "${SERVICES_LIST[@]}"
|
|
|
|
do
|
|
|
|
ynh_remove_systemd_config --service="${app}-${service_name}"
|
|
|
|
done
|
2022-12-27 17:59:56 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# REMOVE LOGROTATE CONFIGURATION
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Removing logrotate configuration..." --weight=1
|
|
|
|
|
|
|
|
# Remove the app-specific logrotate config
|
|
|
|
ynh_remove_logrotate
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# REMOVE THE MONGO DATABASE
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Removing the Mongo database..." --weight=1
|
|
|
|
|
|
|
|
# Remove a database if it exists, along with the associated user
|
2022-12-29 10:06:04 +01:00
|
|
|
ynh_mongo_remove_db --db_user=$db_user --db_name=dontCodeProjects
|
|
|
|
ynh_mongo_remove_db --db_user=$db_user --db_name=dontCodeDemoProjects
|
|
|
|
ynh_mongo_remove_db --db_user=$db_user --db_name=dontCodeData
|
2022-12-27 17:59:56 +01:00
|
|
|
|
|
|
|
# Remove mongo itself if not used anymore
|
|
|
|
ynh_remove_mongo
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# REMOVE APP MAIN DIR
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Removing app main directory..." --weight=1
|
|
|
|
|
|
|
|
# Remove the app directory securely
|
|
|
|
ynh_secure_remove --file="$final_path"
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# REMOVE NGINX CONFIGURATION
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1
|
|
|
|
|
|
|
|
# Remove the dedicated NGINX config
|
|
|
|
ynh_remove_nginx_config
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# REMOVE DEPENDENCIES
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Removing dependencies..." --weight=1
|
|
|
|
|
|
|
|
# Remove metapackage and its dependencies, including java
|
|
|
|
ynh_remove_app_dependencies
|
|
|
|
|
|
|
|
#=================================================
|
2022-12-29 10:06:04 +01:00
|
|
|
# CLOSE ALL PORTS
|
2022-12-27 17:59:56 +01:00
|
|
|
#=================================================
|
|
|
|
|
2022-12-29 10:06:04 +01:00
|
|
|
for port in "${PORT_LIST[@]}"
|
|
|
|
do
|
|
|
|
if yunohost firewall list | grep -q "\- $port$"
|
|
|
|
then
|
|
|
|
ynh_script_progression --message="Closing port $port..." --weight=1
|
|
|
|
ynh_exec_warn_less yunohost firewall disallow TCP $port
|
|
|
|
fi
|
|
|
|
done
|
2022-12-27 17:59:56 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# SPECIFIC REMOVE
|
|
|
|
#=================================================
|
|
|
|
# REMOVE VARIOUS FILES
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Removing various files..." --weight=1
|
|
|
|
|
|
|
|
# Remove the log files
|
|
|
|
ynh_secure_remove --file="/var/log/$app"
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC FINALIZATION
|
|
|
|
#=================================================
|
|
|
|
# REMOVE DEDICATED USER
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Removing the dedicated system user..." --weight=1
|
|
|
|
|
|
|
|
# Delete a system user
|
|
|
|
ynh_system_user_delete --username=$app
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
ynh_script_progression --message="Removal of $app completed" --last
|