From 2c1dc36d2159606558ca5e08a4ffb14ebf7535e1 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 5 Feb 2019 22:17:28 +0100 Subject: [PATCH] Apply example_ynh on remove --- scripts/remove | 62 +++++++++++++++++++++++++++++++++----------------- 1 file changed, 41 insertions(+), 21 deletions(-) diff --git a/scripts/remove b/scripts/remove index 76aacd2..c251310 100755 --- a/scripts/remove +++ b/scripts/remove @@ -13,38 +13,47 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -readonly app=$YNH_APP_INSTANCE_NAME -readonly domain=$(ynh_app_setting_get "$app" domain) + +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) -readonly final_path=$(ynh_app_setting_get "$app" final_path) + +final_path=$(ynh_app_setting_get $app final_path) #================================================= # STANDARD REMOVE #================================================= -# STOP AND REMOVE SERVICE +# REMOVE SERVICE FROM ADMIN PANEL #================================================= -ynh_remove_systemd_config - -#================================================= -# DISABLE SERVICE IN ADMIN PANEL -#================================================= - -if yunohost service status | grep -q $app # Test l'existence du service dans Yunohost +# Remove a service from the admin panel, added by `yunohost service add` +if yunohost service status | grep -q $app then - echo "Remove $app service" - yunohost service remove $app + echo "Remove $app service" + yunohost service remove $app fi #================================================= -# REMOVE DB +# STOP AND REMOVE SERVICE #================================================= + +# Remove the dedicated systemd config +ynh_remove_systemd_config + +#================================================= +# REMOVE THE MONGODB DATABASE +#================================================= + +# Remove a database if it exists, along with the associated user mongo $db_name --eval "db.dropDatabase()" #================================================= # REMOVE DEPENDENCIES #================================================= +# Remove metapackage and its dependencies ynh_remove_app_dependencies #================================================= @@ -54,23 +63,34 @@ ynh_remove_app_dependencies ynh_remove_nodejs #================================================= -# REMOVE THE MAIN DIR OF THE APP +# REMOVE APP MAIN DIR #================================================= -ynh_secure_remove "/var/www/$app" +# Remove the app directory securely +ynh_secure_remove "$final_path" #================================================= -# REMOVE THE NGINX CONFIGURATION +# REMOVE NGINX CONFIGURATION #================================================= -ynh_remove_nginx_config +# Remove the dedicated nginx config +ynh_remove_nginx_config #================================================= -# GENERIC FINALISATION +# CLOSE A PORT +#================================================= + +if yunohost firewall list | grep -q "\- $port$" +then + echo "Close port $port" >&2 + yunohost firewall disallow TCP $port 2>&1 +fi + +#================================================= +# GENERIC FINALIZATION #================================================= # REMOVE DEDICATED USER #================================================= +# Delete a system user ynh_system_user_delete $app - -