mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 17:30:00 +00:00
Merge pull request #120514 from fengxsong/patch-1
fix: check if initsystem service exists
This commit is contained in:
commit
0241da314e
@ -125,7 +125,7 @@ func (sysd SystemdInitSystem) ServiceExists(service string) bool {
|
|||||||
args := []string{"status", service}
|
args := []string{"status", service}
|
||||||
outBytes, _ := exec.Command("systemctl", args...).Output()
|
outBytes, _ := exec.Command("systemctl", args...).Output()
|
||||||
output := string(outBytes)
|
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.
|
// ServiceIsEnabled ensures the service is enabled to start on each boot.
|
||||||
|
Loading…
Reference in New Issue
Block a user