From 359282a87662e50c8d27daf59927dd74348bf883 Mon Sep 17 00:00:00 2001 From: Yury Kulazhenkov Date: Fri, 12 Apr 2024 16:00:13 +0300 Subject: [PATCH] Use `systemctl reenable` command to enable services We use reenable command (the command is a combination of disable+enable) to reset symlinks for the unit and make sure that only symlinks that are currently configured in the [Install] section exist for the service. Signed-off-by: Yury Kulazhenkov --- pkg/host/internal/service/service.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pkg/host/internal/service/service.go b/pkg/host/internal/service/service.go index f1574526f..c8705068a 100644 --- a/pkg/host/internal/service/service.go +++ b/pkg/host/internal/service/service.go @@ -97,8 +97,11 @@ func (s *service) EnableService(service *types.Service) error { } defer exit() - // Enable service - _, _, err = s.utilsHelper.RunCommand("systemctl", "enable", service.Name) + // Enable the service + // we use reenable command (the command is a combination of disable+enable) to reset + // symlinks for the unit and make sure that only symlinks that are currently + // configured in the [Install] section exist for the service. + _, _, err = s.utilsHelper.RunCommand("systemctl", "reenable", service.Name) return err }