From eb97b3632a8a0d6e4521f380c6996f8894dcecaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Wed, 21 Feb 2024 16:19:00 +0100 Subject: [PATCH] helpers: ynh_remove_systemd_config: Also remove the systemd service from YunoHost. Every app or almost will do that, because it doesn't make sense to remove the systemd config but not the associated yunohost configuration. This will clean up a bit the remove scripts. --- helpers/helpers.v2.1.d/systemd | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/helpers/helpers.v2.1.d/systemd b/helpers/helpers.v2.1.d/systemd index b8ff84fd1..702062ae9 100644 --- a/helpers/helpers.v2.1.d/systemd +++ b/helpers/helpers.v2.1.d/systemd @@ -26,15 +26,20 @@ ynh_config_add_systemd() { systemctl daemon-reload } -# Remove the dedicated systemd config +# Remove the dedicated systemd config, and if configured into YunoHost, removes the service. # # usage: ynh_config_remove_systemd service # | arg: service - Service name (optionnal, $app by default) ynh_config_remove_systemd() { local service="${1:-$app}" + + if ynh_exec_warn_less yunohost service status "$app" >/dev/null; then + yunohost service remove "$app" + fi + if [ -e "/etc/systemd/system/$service.service" ]; then - ynh_systemctl --service=$service --action=stop - systemctl disable $service --quiet + ynh_systemctl --service="$service" --action=stop + systemctl disable "$service" --quiet ynh_safe_rm "/etc/systemd/system/$service.service" systemctl daemon-reload fi