From 34c35c86659b4dd10c6ace0bbe09fda964509450 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Tue, 3 Nov 2020 15:33:26 +0100 Subject: [PATCH] Update remove --- scripts/remove | 79 +++++++++++++++++++------------------------------- 1 file changed, 30 insertions(+), 49 deletions(-) diff --git a/scripts/remove b/scripts/remove index 199ec28..51cb38c 100644 --- a/scripts/remove +++ b/scripts/remove @@ -17,85 +17,66 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get $app domain) port=$(ynh_app_setting_get $app port) -db_name=$(ynh_app_setting_get $app db_name) final_path=$(ynh_app_setting_get $app final_path) #================================================= # STANDARD REMOVE #================================================= -# STOP AND REMOVE SERVICE +# REMOVE SERVICE INTEGRATION IN YUNOHOST #================================================= -ynh_remove_systemd_config - -ynh_secure_remove /etc/systemd/system/ethercalc.env - -#================================================= -# REMOVE SERVICE FROM ADMIN PANEL -#================================================= - -if yunohost service status | grep -q $app +# 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 - echo "Remove $app service" + ynh_script_progression --message="Removing $app service integration..." --time --weight=1 yunohost service remove $app fi +#================================================= +# STOP AND REMOVE SERVICE +#================================================= +ynh_script_progression --message="Stopping and removing the systemd service..." --time --weight=1 + +# Remove the dedicated systemd config +ynh_remove_systemd_config + #================================================= # REMOVE DEPENDENCIES #================================================= +ynh_script_progression --message="Removing dependencies..." --time --weight=1 +# Remove metapackage and its dependencies ynh_remove_app_dependencies -#================================================= -# REMOVE THE MYSQL DATABASE -#================================================= - -ynh_mysql_remove_db $db_name $db_name - -#================================================= -# REMOVE APP MAIN DIR -#================================================= - -ynh_secure_remove "$final_path" - #================================================= # REMOVE NGINX CONFIGURATION #================================================= +ynh_script_progression --message="Removing nginx web server configuration..." --time --weight=1 +# Remove the dedicated nginx config ynh_remove_nginx_config #================================================= -# REMOVE LOGROTATE CONFIGURATION +# REMOVE APP MAIN DIR #================================================= +ynh_script_progression --message="Removing app main directory..." --time --weight=1 -ynh_remove_logrotate - -#================================================= -# CLOSE A PORT -#================================================= - -if yunohost firewall list | grep -q "\- $port$" -then - echo "Close port $port" - yunohost firewall disallow TCP $port 2>&1 -fi - -#================================================= -# SPECIFIC REMOVE -#================================================= -# REMOVE THE CRON FILE -#================================================= - -ynh_secure_remove "/etc/cron.d/$app" - -ynh_secure_remove "/etc/$app/" - -ynh_secure_remove "/var/log/$app/" +# Remove the app directory securely +ynh_secure_remove --file="$final_path" #================================================= # GENERIC FINALIZATION #================================================= # REMOVE DEDICATED USER #================================================= +ynh_script_progression --message="Removing the dedicated system user..." --time --weight=1 + +# Delete a system user +ynh_system_user_delete --username=$app + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Removal of $app completed" --time --last -ynh_system_user_delete $app