From 266408e23599a27ea196fbd4cdfd3ec1ea1f2871 Mon Sep 17 00:00:00 2001 From: OniriCorpe Date: Thu, 23 May 2024 18:51:16 +0200 Subject: [PATCH 1/5] do not enable a service disabled by the user --- helpers/systemd | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/helpers/systemd b/helpers/systemd index 765c575ef..f657386bd 100644 --- a/helpers/systemd +++ b/helpers/systemd @@ -25,7 +25,10 @@ ynh_add_systemd_config() { ynh_add_config --template="$template" --destination="/etc/systemd/system/$service.service" - systemctl enable $service --quiet + # do not enable a service disabled by the user + if ! yunohost service status $service | grep -q "start_on_boot: disabled"; then + systemctl enable $service --quiet + fi systemctl daemon-reload } @@ -88,6 +91,11 @@ ynh_systemd_action() { return 0 fi + # do not start a service disabled by the user + if [ "$action" == "start" ] && ! yunohost service status $service_name | grep -q "start_on_boot: disabled"; then + return 0 + fi + # Start to read the log if [[ -n "$line_match" ]]; then local templog="$(mktemp)" From 95250230bc52f60caee0ea3ebf57631c2d2b8280 Mon Sep 17 00:00:00 2001 From: OniriCorpe Date: Thu, 23 May 2024 19:01:54 +0200 Subject: [PATCH 2/5] also handle 'reload_or_restart' and 'restart' --- helpers/systemd | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/helpers/systemd b/helpers/systemd index f657386bd..5c19610db 100644 --- a/helpers/systemd +++ b/helpers/systemd @@ -92,7 +92,8 @@ ynh_systemd_action() { fi # do not start a service disabled by the user - if [ "$action" == "start" ] && ! yunohost service status $service_name | grep -q "start_on_boot: disabled"; then + if [ "$action" == "start" ] || [ "$action" == "reload_or_restart" ] || [ "$action" == "restart" ] && \ + ! yunohost service status $service_name | grep -q "start_on_boot: disabled"; then return 0 fi From 8bdaedfde749ec3ca21e879d422d5183ed82e418 Mon Sep 17 00:00:00 2001 From: OniriCorpe Date: Thu, 23 May 2024 23:51:02 +0200 Subject: [PATCH 3/5] Update helpers/systemd Co-authored-by: Alexandre Aubin <4533074+alexAubin@users.noreply.github.com> --- helpers/systemd | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/helpers/systemd b/helpers/systemd index 5c19610db..eb73f8187 100644 --- a/helpers/systemd +++ b/helpers/systemd @@ -92,8 +92,9 @@ ynh_systemd_action() { fi # do not start a service disabled by the user - if [ "$action" == "start" ] || [ "$action" == "reload_or_restart" ] || [ "$action" == "restart" ] && \ - ! yunohost service status $service_name | grep -q "start_on_boot: disabled"; then + if ([ "$action" == "start" ] || [ "$action" == "reload_or_restart" ] || [ "$action" == "restart" ]) && \ + ! systemctl --quiet is-enabled $service_name; then + echo "$service_name is disabled, therefore skipping action $action" return 0 fi From e8c6abb76871f853bf9561382123faea4e16caea Mon Sep 17 00:00:00 2001 From: OniriCorpe Date: Thu, 23 May 2024 23:53:47 +0200 Subject: [PATCH 4/5] Update helpers/systemd Co-authored-by: Alexandre Aubin <4533074+alexAubin@users.noreply.github.com> --- helpers/systemd | 4 ---- 1 file changed, 4 deletions(-) diff --git a/helpers/systemd b/helpers/systemd index eb73f8187..7687b15ab 100644 --- a/helpers/systemd +++ b/helpers/systemd @@ -25,10 +25,6 @@ ynh_add_systemd_config() { ynh_add_config --template="$template" --destination="/etc/systemd/system/$service.service" - # do not enable a service disabled by the user - if ! yunohost service status $service | grep -q "start_on_boot: disabled"; then - systemctl enable $service --quiet - fi systemctl daemon-reload } From cfcbeb3fa9e2a031d0571d0c5d9dd4feecdbd6f8 Mon Sep 17 00:00:00 2001 From: OniriCorpe Date: Fri, 24 May 2024 00:06:03 +0200 Subject: [PATCH 5/5] enable the $app service during install --- helpers/systemd | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/helpers/systemd b/helpers/systemd index 7687b15ab..1df6a6fc9 100644 --- a/helpers/systemd +++ b/helpers/systemd @@ -25,6 +25,10 @@ ynh_add_systemd_config() { ynh_add_config --template="$template" --destination="/etc/systemd/system/$service.service" + if [[ ${YNH_APP_ACTION} == "install" ]]; then + systemctl enable $service --quiet + fi + systemctl daemon-reload }