From 427b54c949db47dca773a2d08ae3695d46ef3650 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Thu, 14 Feb 2019 19:40:31 +0100 Subject: [PATCH] Apply example_ynh to remove --- scripts/remove | 52 +++++++++++++++++++++++++++++++++----------------- 1 file changed, 35 insertions(+), 17 deletions(-) diff --git a/scripts/remove b/scripts/remove index 632eb44..87b542b 100755 --- a/scripts/remove +++ b/scripts/remove @@ -1,7 +1,7 @@ #!/bin/bash #================================================= -# GENERIC STARTING +# GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= @@ -12,6 +12,7 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= +ynh_print_info "Loading installation settings..." app=$YNH_APP_INSTANCE_NAME @@ -20,39 +21,48 @@ port=$(ynh_app_setting_get $app port) #================================================= # STANDARD REMOVE +#================================================= +# REMOVE SERVICE FROM ADMIN PANEL +#================================================= + +# Remove a service from the admin panel, added by `yunohost service add` +if yunohost service status | grep -q $app +then + ynh_print_info "Removing $app service" + yunohost service remove $app +fi + #================================================= # STOP AND REMOVE SERVICE #================================================= +ynh_print_info "Stopping and removing the service" +# Remove the dedicated systemd config ynh_remove_systemd_config -#================================================= -# DISABLE SERVICE IN ADMIN PANEL -#================================================= - -if yunohost service status | grep -q $app # Test l'existence du service dans Yunohost -then - ynh_print_info "Remove $app service" >&2 - yunohost service remove $app.service -fi - #================================================= # REMOVE DEPENDENCIES #================================================= +ynh_print_info "Removing dependencies" +# Remove metapackage and its dependencies ynh_remove_app_dependencies #================================================= -# REMOVE THE MAIN DIR OF THE APP +# REMOVE APP MAIN DIR #================================================= +ynh_print_info "Removing app main directory" -ynh_secure_remove "/var/www/$app" # Suppression du dossier de l'application +# Remove the app directory securely +ynh_secure_remove "$final_path" #================================================= -# REMOVE THE NGINX CONFIGURATION +# REMOVE NGINX CONFIGURATION #================================================= +ynh_print_info "Removing nginx configuration" -ynh_remove_nginx_config # Suppression de la configuration nginx +# Remove the dedicated nginx config +ynh_remove_nginx_config #================================================= # CLOSE A PORT @@ -60,8 +70,8 @@ ynh_remove_nginx_config # Suppression de la configuration nginx if yunohost firewall list | grep -q "\- $port$" then - ynh_print_info "Close port $port" >&2 - ynh_exec_quiet yunohost firewall disallow TCP $port + ynh_print_info "Closing port $port" + ynh_exec_warn_less yunohost firewall disallow TCP $port fi #================================================= @@ -69,5 +79,13 @@ fi #================================================= # REMOVE DEDICATED USER #================================================= +ynh_print_info "Removing the dedicated system user" +# Delete a system user ynh_system_user_delete $app + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_print_info "Removal of $app completed"