mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-31 15:25:57 +00:00
fix: check if initsystem service exists
when detecting whether a service exists, if it does not, the output result will be like "Unit noneexists.service could not be found." on ubuntu:20.04
This commit is contained in:
parent
fba0802836
commit
a69f56e137
@ -125,7 +125,7 @@ func (sysd SystemdInitSystem) ServiceExists(service string) bool {
|
||||
args := []string{"status", service}
|
||||
outBytes, _ := exec.Command("systemctl", args...).Output()
|
||||
output := string(outBytes)
|
||||
return !strings.Contains(output, "Loaded: not-found")
|
||||
return !strings.Contains(output, "Loaded: not-found") && !strings.Contains(output, "could not be found")
|
||||
}
|
||||
|
||||
// ServiceIsEnabled ensures the service is enabled to start on each boot.
|
||||
|
Loading…
Reference in New Issue
Block a user