summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2014-11-04 16:39:23 -0800
committerLamont Granquist <lamont@scriptkiddie.org>2014-11-08 11:26:07 -0800
commit550cbad4aea1554159aba59c5c310d5a6180bd60 (patch)
tree70f16a7c91993ee9f48660e6ca6d4a82b47aaa7d
parent4aba8b23a6248e34aca75436ad142836fe2d4c82 (diff)
downloadchef-550cbad4aea1554159aba59c5c310d5a6180bd60.tar.gz
syntax fixes for grepping output
-rw-r--r--lib/chef/platform/service_helpers.rb8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/chef/platform/service_helpers.rb b/lib/chef/platform/service_helpers.rb
index 4b7c27b8de..dc0a808c06 100644
--- a/lib/chef/platform/service_helpers.rb
+++ b/lib/chef/platform/service_helpers.rb
@@ -118,9 +118,13 @@ class Chef
def extract_systemd_services(command)
output = shell_out!(command).stdout
# first line finds e.g. "sshd.service"
- services = output.lines.split.map { |l| l.split[0] }
+ services = []
+ output.each_line do |line|
+ fields = line.split
+ services << fields[0] if fields[1] == "loaded" || fields[1] == "not-found"
+ end
# this splits off the suffix after the last dot to return "sshd"
- services += services.map { |s| s.sub(/(.*)\..*/, '\1') }
+ services += services.select {|s| s.match(/\.service$/) }.map { |s| s.sub(/(.*)\.service$/, '\1') }
rescue Mixlib::ShellOut::ShellCommandFailed
false
end