diff --git a/helpers/systemd b/helpers/systemd index 765c575eff..1df6a6fc94 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 + if [[ ${YNH_APP_ACTION} == "install" ]]; then + systemctl enable $service --quiet + fi + systemctl daemon-reload } @@ -88,6 +91,13 @@ ynh_systemd_action() { return 0 fi + # do not start a service disabled by the user + 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 + # Start to read the log if [[ -n "$line_match" ]]; then local templog="$(mktemp)"