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
|
|
|
|
2022-05-26 09:30:42 +02:00
|
|
|
app="$YNH_APP_INSTANCE_NAME"
|
2020-10-05 23:05:58 +02:00
|
|
|
|
2022-05-26 09:30:42 +02:00
|
|
|
domain=$(ynh_app_setting_get --app="$app" --key=domain)
|
|
|
|
port=$(ynh_app_setting_get --app="$app" --key=port)
|
|
|
|
final_path=$(ynh_app_setting_get --app="$app" --key=final_path)
|
|
|
|
mqtt_domain=$(ynh_app_setting_get --app="$app" --key=mqtt_domain)
|
2020-10-05 23:05:58 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# 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`)
|
2022-05-26 09:30:42 +02:00
|
|
|
if ynh_exec_warn_less yunohost service status "$app" >/dev/null
|
2020-10-05 23:05:58 +02:00
|
|
|
then
|
2021-08-05 02:21:46 +02:00
|
|
|
ynh_script_progression --message="Removing $app service integration..."
|
2022-05-26 09:30:42 +02:00
|
|
|
yunohost service remove "$app"
|
|
|
|
[[ ! -z "$mqtt_domain" ]] && 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
|
2022-05-26 09:30:42 +02:00
|
|
|
ynh_exec_warn_less yunohost firewall disallow TCP "$port"
|
2022-05-22 19:15:23 +02:00
|
|
|
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-26 09:30:42 +02:00
|
|
|
[[ ! -z "$mqtt_domain" ]] && 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
|
|
|
|
2022-06-17 19:09:19 +02:00
|
|
|
#remove hook for mqtt nginx
|
|
|
|
ynh_secure_remove --file="/usr/share/yunohost/hooks/conf_regen/95-nginx_domoticz"
|
|
|
|
yunohost tools regen-conf postfix
|
|
|
|
|
|
|
|
|
2021-08-05 02:21:46 +02:00
|
|
|
# Remove the dedicated NGINX config
|
2022-05-26 09:30:42 +02:00
|
|
|
[[ ! -z "$mqtt_domain" ]] && ynh_secure_remove --file="/etc/nginx/conf.d/"$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-05-26 09:30:42 +02:00
|
|
|
[[ ! -z "$mqtt_domain" ]] && 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
|
2022-05-26 09:30:42 +02:00
|
|
|
ynh_system_user_delete --username="$app"
|
2020-10-05 23:05:58 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
2020-11-07 10:24:19 +01:00
|
|
|
ynh_script_progression --message="Removal of $app completed" --last
|