TUN-7824: Fix usage of systemctl status to detect which services are installed
## Summary To determine which services were installed, cloudflared, was using the command `systemctl status` this command gives an error if the service is installed but isn't running, which makes the `uninstall services` command report wrongly the services not installed. Therefore, this commit adapts it to use the `systemctl list-units` command combined with a grep to find which services are installed and need to be removed.
This commit is contained in:
parent
f1d6f0c0be
commit
541c63d737
|
@ -369,7 +369,7 @@ func uninstallSystemd(log *zerolog.Logger) error {
|
|||
// Get only the installed services
|
||||
installedServices := make(map[string]ServiceTemplate)
|
||||
for serviceName, serviceTemplate := range systemdAllTemplates {
|
||||
if err := runCommand("systemctl", "status", serviceName); err == nil {
|
||||
if err := runCommand("systemctl", "list-units", "--all", "|", "grep", serviceName); err == nil {
|
||||
installedServices[serviceName] = serviceTemplate
|
||||
} else {
|
||||
log.Info().Msgf("Service '%s' not installed, skipping its uninstall", serviceName)
|
||||
|
|
Loading…
Reference in New Issue