2020-10-05 23:05:58 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
source _common.sh
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# LOAD SETTINGS
|
|
|
|
#=================================================
|
2021-08-05 02:21:46 +02:00
|
|
|
ynh_script_progression --message="Loading installation settings..."
|
2020-10-05 23:05:58 +02:00
|
|
|
|
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
|
|
|
|
|
|
|
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
|
|
|
port=$(ynh_app_setting_get --app=$app --key=port)
|
|
|
|
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)
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# STANDARD REMOVE
|
|
|
|
#=================================================
|
|
|
|
# REMOVE SERVICE INTEGRATION IN YUNOHOST
|
|
|
|
#=================================================
|
|
|
|
|
2021-08-05 02:21:46 +02:00
|
|
|
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
|
2020-10-05 23:05:58 +02:00
|
|
|
if ynh_exec_warn_less yunohost service status $app >/dev/null
|
|
|
|
then
|
2021-08-05 02:21:46 +02:00
|
|
|
ynh_script_progression --message="Removing $app service integration..."
|
2020-10-05 23:05:58 +02:00
|
|
|
yunohost service remove $app
|
2022-04-24 23:58:20 +02:00
|
|
|
yunohost service remove mosquitto
|
2020-10-05 23:05:58 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# STOP AND REMOVE SERVICE
|
|
|
|
#=================================================
|
2021-08-05 02:21:46 +02:00
|
|
|
ynh_script_progression --message="Stopping and removing the systemd service..."
|
2020-10-05 23:05:58 +02:00
|
|
|
|
|
|
|
# Remove the dedicated systemd config
|
|
|
|
ynh_remove_systemd_config
|
|
|
|
|
|
|
|
|
2022-05-22 19:15:23 +02:00
|
|
|
#=================================================
|
|
|
|
# CLOSE A PORT
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
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
|
|
|
|
|
2020-10-05 23:05:58 +02:00
|
|
|
#=================================================
|
|
|
|
# REMOVE DEPENDENCIES
|
|
|
|
#=================================================
|
2020-11-07 10:24:19 +01:00
|
|
|
ynh_script_progression --message="Removing dependencies..." --weight=3
|
2020-10-05 23:05:58 +02:00
|
|
|
|
|
|
|
# Remove metapackage and its dependencies
|
2022-05-22 19:15:23 +02:00
|
|
|
ynh_secure_remove --file="/etc/mosquitto/conf.d"
|
2020-10-05 23:05:58 +02:00
|
|
|
ynh_remove_app_dependencies
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# REMOVE APP MAIN DIR
|
|
|
|
#=================================================
|
2020-11-07 10:24:19 +01:00
|
|
|
ynh_script_progression --message="Removing app main directory..." --weight=3
|
2020-10-05 23:05:58 +02:00
|
|
|
|
|
|
|
# Remove the app directory securely
|
|
|
|
ynh_secure_remove --file="$final_path"
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# REMOVE NGINX CONFIGURATION
|
|
|
|
#=================================================
|
2021-08-05 02:21:46 +02:00
|
|
|
ynh_script_progression --message="Removing NGINX web server configuration..."
|
2020-10-05 23:05:58 +02:00
|
|
|
|
2021-08-05 02:21:46 +02:00
|
|
|
# Remove the dedicated NGINX config
|
2022-05-22 19:15:23 +02:00
|
|
|
ynh_secure_remove --file="/etc/nginx/"$mqtt_domain".d/mqtt_"$app".conf"
|
2020-10-05 23:05:58 +02:00
|
|
|
ynh_remove_nginx_config
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# REMOVE LOGROTATE CONFIGURATION
|
|
|
|
#=================================================
|
2021-08-05 02:21:46 +02:00
|
|
|
ynh_script_progression --message="Removing logrotate configuration..."
|
2020-10-05 23:05:58 +02:00
|
|
|
|
|
|
|
# Remove the app-specific logrotate config
|
|
|
|
ynh_remove_logrotate
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# SPECIFIC REMOVE
|
|
|
|
#=================================================
|
|
|
|
# REMOVE VARIOUS FILES
|
|
|
|
#=================================================
|
2021-08-05 02:21:46 +02:00
|
|
|
ynh_script_progression --message="Removing various files..."
|
2020-10-05 23:05:58 +02:00
|
|
|
|
|
|
|
# Remove the log files
|
2021-08-05 02:21:46 +02:00
|
|
|
ynh_secure_remove --file="/var/log/$app"
|
2022-04-24 23:58:20 +02:00
|
|
|
ynh_secure_remove --file="/var/log/mosquitto"
|
2021-08-05 02:21:46 +02:00
|
|
|
|
|
|
|
#Delete the sudoer file
|
|
|
|
ynh_secure_remove --file="/etc/sudoers.d/$app"
|
2020-10-05 23:05:58 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC FINALIZATION
|
|
|
|
#=================================================
|
|
|
|
# REMOVE DEDICATED USER
|
|
|
|
#=================================================
|
2021-08-05 02:21:46 +02:00
|
|
|
ynh_script_progression --message="Removing the dedicated system user..."
|
2020-11-08 15:24:23 +01:00
|
|
|
|
2020-10-05 23:05:58 +02:00
|
|
|
# Delete a system user
|
|
|
|
ynh_system_user_delete --username=$app
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
2020-11-07 10:24:19 +01:00
|
|
|
ynh_script_progression --message="Removal of $app completed" --last
|