machinery-tool 1.22.1 → 1.22.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.git_revision +1 -1
- data/NEWS +10 -0
- data/bin/machinery +1 -1
- data/lib/analyze_changed_config_files_diffs_task.rb +6 -6
- data/lib/autoyast.rb +2 -2
- data/lib/build_task.rb +10 -7
- data/lib/cli.rb +1005 -801
- data/lib/compare_task.rb +11 -7
- data/lib/comparison.rb +2 -2
- data/lib/config_base.rb +1 -1
- data/lib/config_task.rb +1 -1
- data/lib/containerize_task.rb +3 -3
- data/lib/containerized_app.rb +1 -1
- data/lib/copy_task.rb +1 -1
- data/lib/current_user.rb +1 -1
- data/lib/deploy_task.rb +6 -4
- data/lib/diff_widget.rb +67 -63
- data/lib/docker_system.rb +12 -8
- data/lib/dpkg_database.rb +1 -1
- data/lib/element_filter.rb +7 -4
- data/lib/exceptions.rb +23 -5
- data/lib/export_task.rb +1 -1
- data/lib/exporter.rb +1 -1
- data/lib/file_diff.rb +1 -1
- data/lib/file_scope.rb +1 -1
- data/lib/file_validator.rb +7 -4
- data/lib/filter.rb +97 -93
- data/lib/filter_option_parser.rb +2 -2
- data/lib/hint.rb +64 -59
- data/lib/html.rb +1 -1
- data/lib/inspect_task.rb +12 -12
- data/lib/inspector.rb +3 -3
- data/lib/json_validation_error_cleaner.rb +1 -1
- data/lib/json_validator.rb +4 -4
- data/lib/kiwi_config.rb +8 -4
- data/lib/list_task.rb +10 -9
- data/lib/local_system.rb +11 -5
- data/lib/logged_cheetah.rb +1 -1
- data/lib/man_task.rb +10 -6
- data/lib/managed_files_database.rb +1 -1
- data/lib/manifest.rb +5 -5
- data/lib/migration.rb +16 -10
- data/lib/mountpoints.rb +1 -1
- data/lib/move_task.rb +1 -1
- data/lib/remote_system.rb +7 -7
- data/lib/remove_task.rb +1 -1
- data/lib/renderer.rb +177 -172
- data/lib/rpm.rb +4 -4
- data/lib/rpm_database.rb +1 -1
- data/lib/scope.rb +2 -2
- data/lib/scope_file_access_archive.rb +1 -1
- data/lib/scope_file_access_flat.rb +1 -1
- data/lib/scope_file_store.rb +1 -1
- data/lib/serve_html_task.rb +6 -2
- data/lib/server.rb +19 -12
- data/lib/show_task.rb +10 -6
- data/lib/static_html.rb +1 -1
- data/lib/system.rb +10 -10
- data/lib/system_description.rb +14 -13
- data/lib/system_description_memory_store.rb +1 -1
- data/lib/system_description_store.rb +9 -9
- data/lib/tarball.rb +8 -2
- data/lib/upgrade_format_task.rb +11 -6
- data/lib/validate_task.rb +2 -2
- data/lib/version.rb +1 -1
- data/lib/workload_mapper.rb +2 -2
- data/lib/workload_mapper_dsl.rb +1 -1
- data/lib/zypper.rb +40 -17
- data/machinery-helper/machinery_helper.go +35 -16
- data/machinery-helper/version.go +1 -1
- data/man/generated/machinery.1.gz +0 -0
- data/manual/site/sitemap.xml +24 -24
- data/plugins/changed_config_files/changed_config_files_inspector.rb +59 -56
- data/plugins/changed_config_files/changed_config_files_model.rb +23 -21
- data/plugins/changed_config_files/changed_config_files_renderer.rb +56 -52
- data/plugins/changed_managed_files/changed_managed_files_inspector.rb +52 -50
- data/plugins/changed_managed_files/changed_managed_files_model.rb +23 -21
- data/plugins/changed_managed_files/changed_managed_files_renderer.rb +43 -39
- data/plugins/environment/environment_inspector.rb +25 -23
- data/plugins/environment/environment_model.rb +5 -3
- data/plugins/groups/groups_inspector.rb +30 -28
- data/plugins/groups/groups_model.rb +18 -17
- data/plugins/groups/groups_renderer.rb +29 -25
- data/plugins/os/os_inspector.rb +120 -118
- data/plugins/os/os_model.rb +139 -134
- data/plugins/os/os_renderer.rb +13 -9
- data/plugins/packages/packages_inspector.rb +99 -86
- data/plugins/packages/packages_model.rb +35 -34
- data/plugins/packages/packages_renderer.rb +47 -39
- data/plugins/patterns/patterns_inspector.rb +70 -68
- data/plugins/patterns/patterns_model.rb +19 -18
- data/plugins/patterns/patterns_renderer.rb +36 -32
- data/plugins/repositories/repositories_inspector.rb +162 -156
- data/plugins/repositories/repositories_model.rb +50 -49
- data/plugins/repositories/repositories_renderer.rb +48 -44
- data/plugins/repositories/schema/system-description-repositories.schema-v10.json +0 -1
- data/plugins/services/services_inspector.rb +187 -176
- data/plugins/services/services_model.rb +37 -36
- data/plugins/services/services_renderer.rb +28 -24
- data/plugins/unmanaged_files/unmanaged_files_inspector.rb +102 -99
- data/plugins/unmanaged_files/unmanaged_files_model.rb +64 -56
- data/plugins/unmanaged_files/unmanaged_files_renderer.rb +44 -40
- data/plugins/users/users_inspector.rb +67 -65
- data/plugins/users/users_model.rb +37 -36
- data/plugins/users/users_renderer.rb +31 -27
- data/schema/migrations/migrate1to2.rb +1 -1
- data/schema/migrations/migrate2to3.rb +1 -1
- data/schema/migrations/migrate3to4.rb +1 -1
- data/schema/migrations/migrate4to5.rb +1 -1
- data/schema/migrations/migrate5to6.rb +1 -1
- data/schema/migrations/migrate6to7.rb +1 -1
- data/schema/migrations/migrate7to8.rb +1 -1
- data/schema/migrations/migrate8to9.rb +1 -1
- data/schema/migrations/migrate9to10.rb +1 -1
- metadata +2 -2
@@ -15,63 +15,67 @@
|
|
15
15
|
# To contact SUSE about this file by physical or electronic mail,
|
16
16
|
# you may find current contact information at www.suse.com
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
18
|
+
module Machinery
|
19
|
+
class Ui
|
20
|
+
class RepositoriesRenderer < Machinery::Ui::Renderer
|
21
|
+
def content(description)
|
22
|
+
return unless description.repositories
|
21
23
|
|
22
|
-
|
23
|
-
|
24
|
-
|
24
|
+
if description.repositories.empty?
|
25
|
+
puts "There are no repositories."
|
26
|
+
end
|
25
27
|
|
26
|
-
|
28
|
+
na_note("repository type") if description.repositories.any? { |a| a[:type] == "" }
|
27
29
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
30
|
+
list do
|
31
|
+
description.repositories.each do |p|
|
32
|
+
item_name = if p.name
|
33
|
+
p.name
|
34
|
+
else
|
35
|
+
"URI: #{p.url}"
|
36
|
+
end
|
37
|
+
item item_name do
|
38
|
+
if p.url.is_a?(::Array)
|
39
|
+
list "URI", sublist: true do
|
40
|
+
p.url.each do |url|
|
41
|
+
item url
|
42
|
+
end
|
43
|
+
end
|
44
|
+
elsif p.name
|
45
|
+
puts "URI: #{p.url}"
|
40
46
|
end
|
47
|
+
puts "Mirrorlist: #{!p.mirrorlist.empty? ? p.mirrorlist : "N/A"}" if p.mirrorlist
|
48
|
+
puts "Alias: #{p.alias}" if p.alias
|
49
|
+
puts "Distribution: #{p.distribution}" if p.distribution
|
50
|
+
puts "Components: #{p.components.join(", ")}" if p.components
|
51
|
+
puts "Enabled: #{p.enabled ? "Yes" : "No"}" unless p.enabled.nil?
|
52
|
+
puts "Refresh: #{p.autorefresh ? "Yes" : "No"}" unless p.autorefresh.nil?
|
53
|
+
puts "Priority: #{p.priority}" unless p.priority.nil?
|
54
|
+
puts "Type: #{p.type || "N/A"}"
|
41
55
|
end
|
42
|
-
elsif p.name
|
43
|
-
puts "URI: #{p.url}"
|
44
56
|
end
|
45
|
-
puts "Mirrorlist: #{!p.mirrorlist.empty? ? p.mirrorlist : "N/A"}" if p.mirrorlist
|
46
|
-
puts "Alias: #{p.alias}" if p.alias
|
47
|
-
puts "Distribution: #{p.distribution}" if p.distribution
|
48
|
-
puts "Components: #{p.components.join(", ")}" if p.components
|
49
|
-
puts "Enabled: #{p.enabled ? "Yes" : "No"}" unless p.enabled.nil?
|
50
|
-
puts "Refresh: #{p.autorefresh ? "Yes" : "No"}" unless p.autorefresh.nil?
|
51
|
-
puts "Priority: #{p.priority}" unless p.priority.nil?
|
52
|
-
puts "Type: #{p.type || "N/A"}"
|
53
57
|
end
|
54
58
|
end
|
55
|
-
end
|
56
|
-
end
|
57
59
|
|
58
|
-
|
59
|
-
|
60
|
-
|
60
|
+
def display_name
|
61
|
+
"Repositories"
|
62
|
+
end
|
63
|
+
|
64
|
+
def compare_content_changed(changed_elements)
|
65
|
+
list do
|
66
|
+
changed_elements.each do |one, two|
|
67
|
+
changes = []
|
68
|
+
relevant_attributes = one.attributes.keys
|
61
69
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
70
|
+
relevant_attributes.each do |attribute|
|
71
|
+
if one[attribute] != two[attribute]
|
72
|
+
changes << "#{attribute}: #{one[attribute]} <> #{two[attribute]}"
|
73
|
+
end
|
74
|
+
end
|
67
75
|
|
68
|
-
|
69
|
-
if one[attribute] != two[attribute]
|
70
|
-
changes << "#{attribute}: #{one[attribute]} <> #{two[attribute]}"
|
76
|
+
item "#{one.alias} (#{changes.join(", ")})"
|
71
77
|
end
|
72
78
|
end
|
73
|
-
|
74
|
-
item "#{one.alias} (#{changes.join(", ")})"
|
75
79
|
end
|
76
80
|
end
|
77
81
|
end
|
@@ -15,218 +15,229 @@
|
|
15
15
|
# To contact SUSE about this file by physical or electronic mail,
|
16
16
|
# you may find current contact information at www.suse.com
|
17
17
|
|
18
|
-
|
19
|
-
|
18
|
+
module Machinery
|
19
|
+
class ServicesInspector < Machinery::Inspector
|
20
|
+
has_priority 70
|
20
21
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
22
|
+
def initialize(system, description)
|
23
|
+
@system = system
|
24
|
+
@description = description
|
25
|
+
end
|
25
26
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
27
|
+
def inspect(_filter, _options = {})
|
28
|
+
services, init_system =
|
29
|
+
if @description.environment.system_type == "docker"
|
30
|
+
[[], "none"]
|
31
|
+
elsif @system.has_command?("systemctl")
|
32
|
+
[inspect_systemd_services, "systemd"]
|
33
|
+
elsif @system.has_command?("initctl") && @system.has_command?("chkconfig")
|
34
|
+
[parse_redhat_chkconfig.map { |s| s["legacy_sysv"] = true; s }, "upstart"]
|
35
|
+
elsif @system.has_command?("initctl") && !@system.has_command?("chkconfig")
|
36
|
+
[inspect_ubuntu_services, "upstart"]
|
37
|
+
else
|
38
|
+
[inspect_sysvinit_services, "sysvinit"]
|
39
|
+
end
|
40
|
+
|
41
|
+
@description.services = ServicesScope.new(
|
42
|
+
services,
|
43
|
+
init_system: init_system
|
44
|
+
)
|
45
|
+
end
|
40
46
|
|
41
|
-
|
42
|
-
services,
|
43
|
-
|
44
|
-
)
|
45
|
-
end
|
47
|
+
def summary
|
48
|
+
"Found #{Machinery.pluralize(@description.services.length, "%d service")}."
|
49
|
+
end
|
46
50
|
|
47
|
-
|
48
|
-
"Found #{Machinery.pluralize(@description.services.length, "%d service")}."
|
49
|
-
end
|
51
|
+
private
|
50
52
|
|
51
|
-
|
53
|
+
def inspect_systemd_services
|
54
|
+
services = list_unit_files.map do |line|
|
55
|
+
name, state = line.split(/\s+/)
|
52
56
|
|
53
|
-
|
54
|
-
|
55
|
-
name, state = line.split(/\s+/)
|
57
|
+
Service.new(name: name, state: state)
|
58
|
+
end
|
56
59
|
|
57
|
-
|
58
|
-
|
60
|
+
list_unit_files(true).map { |line| line.split(/\s+/) }.each do |name, state|
|
61
|
+
prefix, suffix = name.split("@")
|
59
62
|
|
60
|
-
|
61
|
-
|
63
|
+
instances = list_units.select { |i| i =~ /#{prefix}@.+#{suffix}/ }.each do |instance|
|
64
|
+
services << Service.new(name: instance, state: unit_is_enabled?(instance))
|
65
|
+
end
|
62
66
|
|
63
|
-
|
64
|
-
services << Service.new(name: instance, state: unit_is_enabled?(instance))
|
67
|
+
services << Service.new(name: name, state: state) if instances.empty?
|
65
68
|
end
|
66
69
|
|
67
|
-
services
|
70
|
+
services.sort_by(&:name)
|
68
71
|
end
|
69
72
|
|
70
|
-
|
71
|
-
|
73
|
+
def list_unit_files(templates = false)
|
74
|
+
@unit_files ||= @system.run_command(
|
75
|
+
"systemctl",
|
76
|
+
"list-unit-files",
|
77
|
+
"--type=service,socket",
|
78
|
+
stdout: :capture
|
79
|
+
)
|
80
|
+
|
81
|
+
# The first line contains a table header. The last two lines contain a
|
82
|
+
# separator and a summary (e.g. "197 unit files listed").
|
83
|
+
# Files will be grouped by depending on
|
84
|
+
# wether they are templates or not.
|
85
|
+
@unit_files.lines[1..-3].group_by { |l| l.include?("@") }[templates]
|
86
|
+
end
|
72
87
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
# The first line contains a table header. The last two lines contain a
|
82
|
-
# separator and a summary (e.g. "197 unit files listed"). Files will be grouped by depending on
|
83
|
-
# weather they are templates or not.
|
84
|
-
@unit_files.lines[1..-3].group_by { |l| l.include?("@") }[templates]
|
85
|
-
end
|
88
|
+
def list_units
|
89
|
+
output = @system.run_command(
|
90
|
+
"systemctl",
|
91
|
+
"list-units",
|
92
|
+
"--all",
|
93
|
+
stdout: :capture
|
94
|
+
)
|
86
95
|
|
87
|
-
|
88
|
-
|
89
|
-
"systemctl",
|
90
|
-
"list-units",
|
91
|
-
"--all",
|
92
|
-
stdout: :capture
|
93
|
-
)
|
96
|
+
output.lines[1..-8].map { |line| line.split.first }
|
97
|
+
end
|
94
98
|
|
95
|
-
|
96
|
-
|
99
|
+
def unit_is_enabled?(unit)
|
100
|
+
output = @system.run_command("systemctl", "is-enabled", unit, stdout: :capture)
|
101
|
+
return output.split("\n").first
|
102
|
+
rescue Cheetah::ExecutionFailed
|
103
|
+
return "disabled"
|
104
|
+
end
|
97
105
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
106
|
+
def inspect_sysvinit_services
|
107
|
+
# Red Hat's chkconfig behaves differently than SUSE's: It takes different
|
108
|
+
# command line arguments and has a different output format. We determine
|
109
|
+
# if it's Red Hat by calling 'chkconfig --version'. On SUSE it exits with
|
110
|
+
# an error, on Red Hat it doesn't.
|
111
|
+
#
|
112
|
+
begin
|
113
|
+
@system.run_command("/sbin/chkconfig", "--version")
|
114
|
+
services = parse_redhat_chkconfig
|
115
|
+
rescue
|
116
|
+
services = parse_suse_chkconfig
|
117
|
+
end
|
104
118
|
|
105
|
-
|
106
|
-
# Red Hat's chkconfig behaves differently than SUSE's: It takes different
|
107
|
-
# command line arguments and has a different output format. We determine
|
108
|
-
# if it's Red Hat by calling 'chkconfig --version'. On SUSE it exits with
|
109
|
-
# an error, on Red Hat it doesn't.
|
110
|
-
#
|
111
|
-
begin
|
112
|
-
@system.run_command("/sbin/chkconfig", "--version")
|
113
|
-
services = parse_redhat_chkconfig
|
114
|
-
rescue
|
115
|
-
services = parse_suse_chkconfig
|
119
|
+
services.sort_by(&:name)
|
116
120
|
end
|
117
121
|
|
118
|
-
|
119
|
-
|
122
|
+
def inspect_ubuntu_services
|
123
|
+
# Ubuntu is managing its services using upstart but also has some
|
124
|
+
# services still not handled by that. Therefor we need to scan upstart
|
125
|
+
# and sysV to determine all services and their bootup state
|
126
|
+
services = parse_ubuntu_upstart
|
127
|
+
parse_ubuntu_sysv.each do |service|
|
128
|
+
services << service unless services.find { |s| s.name == service.name }
|
129
|
+
end
|
120
130
|
|
121
|
-
|
122
|
-
# Ubuntu is managing its services using upstart but also has some
|
123
|
-
# services still not handled by that. Therefor we need to scan upstart
|
124
|
-
# and sysV to determine all services and their bootup state
|
125
|
-
services = parse_ubuntu_upstart
|
126
|
-
parse_ubuntu_sysv.each do |service|
|
127
|
-
services << service unless services.find { |s| s.name == service.name }
|
131
|
+
services.sort_by(&:name)
|
128
132
|
end
|
129
133
|
|
130
|
-
|
131
|
-
|
134
|
+
def parse_ubuntu_upstart
|
135
|
+
initctl_output = @system.run_command(
|
136
|
+
"/sbin/initctl",
|
137
|
+
"show-config",
|
138
|
+
"-e",
|
139
|
+
stdout: :capture
|
140
|
+
)
|
132
141
|
|
133
|
-
|
134
|
-
|
142
|
+
servicelist = initctl_output.lines.map(&:chomp).slice_before do |l|
|
143
|
+
!l.start_with?(" ")
|
144
|
+
end
|
145
|
+
enabled, disabled = servicelist.partition do |s|
|
146
|
+
s.find { |e| e.start_with?(" start on runlevel", " start on startup") }
|
147
|
+
end
|
135
148
|
|
136
|
-
|
137
|
-
|
138
|
-
|
149
|
+
services = enabled.map(&:first).each.map do |name|
|
150
|
+
Service.new(name: name, state: "enabled", legacy_sysv: false)
|
151
|
+
end
|
152
|
+
services + disabled.map(&:first).each.map do |name|
|
153
|
+
Service.new(name: name, state: "disabled", legacy_sysv: false)
|
154
|
+
end
|
139
155
|
end
|
140
156
|
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
157
|
+
def parse_ubuntu_sysv
|
158
|
+
# Get all sysV services
|
159
|
+
out, err = @system.run_command(
|
160
|
+
"/usr/sbin/service",
|
161
|
+
"--status-all",
|
162
|
+
stdout: :capture,
|
163
|
+
stderr: :capture
|
164
|
+
)
|
165
|
+
services_output = out + err
|
166
|
+
|
167
|
+
sysv_all = services_output.each_line.map { |line|
|
168
|
+
line.chomp.sub(/^.*\]../, "")
|
169
|
+
}
|
170
|
+
|
171
|
+
# Get all enabled sysV services - default in ubuntu1404 is runlevel 2
|
172
|
+
# and runlevels 3,4 and 5 are considered to be identical to 2.
|
173
|
+
runlevels = ["2", "S"]
|
174
|
+
find_output = runlevels.each.map do |runlevel|
|
175
|
+
@system.run_command(
|
176
|
+
"/usr/bin/find",
|
177
|
+
"/etc/rc#{runlevel}.d",
|
178
|
+
"-name",
|
179
|
+
"S\*",
|
180
|
+
stdout: :capture
|
181
|
+
).split
|
182
|
+
end
|
148
183
|
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
"--status-all",
|
154
|
-
stdout: :capture, stderr: :capture)
|
155
|
-
services_output = out + err
|
156
|
-
|
157
|
-
sysv_all = services_output.each_line.map { |line|
|
158
|
-
line.chomp.sub(/^.*\]../, "")
|
159
|
-
}
|
160
|
-
|
161
|
-
# Get all enabled sysV services - default in ubuntu1404 is runlevel 2
|
162
|
-
# and runlevels 3,4 and 5 are considered to be identical to 2.
|
163
|
-
runlevels = ["2", "S"]
|
164
|
-
find_output = runlevels.each.map do |runlevel|
|
165
|
-
@system.run_command(
|
166
|
-
"/usr/bin/find",
|
167
|
-
"/etc/rc#{runlevel}.d",
|
168
|
-
"-name",
|
169
|
-
"S\*",
|
170
|
-
stdout: :capture).split
|
171
|
-
end
|
184
|
+
sysv_enabled = find_output.flatten.map { |line|
|
185
|
+
line.chomp.sub(/^\/etc\/rc.\.d\/.../, "")
|
186
|
+
}.uniq
|
187
|
+
sysv_disabled = sysv_all - sysv_enabled
|
172
188
|
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
sysv_disabled = sysv_all - sysv_enabled
|
189
|
+
services = sysv_enabled.map.each do |name|
|
190
|
+
Service.new(name: name, state: "enabled", legacy_sysv: true)
|
191
|
+
end
|
177
192
|
|
178
|
-
|
179
|
-
|
193
|
+
services + sysv_disabled.map.each do |name|
|
194
|
+
Service.new(name: name, state: "disabled", legacy_sysv: true)
|
195
|
+
end
|
180
196
|
end
|
181
197
|
|
182
|
-
|
183
|
-
|
198
|
+
def parse_suse_chkconfig
|
199
|
+
# check if chkconfig is available otherwise use /sbin/chkconfig
|
200
|
+
# this fixes issue on sles11sp3 where chkconfig isn't in /usr/bin
|
201
|
+
chkconfig = @system.check_requirement(["chkconfig", "/sbin/chkconfig"], "--help")
|
202
|
+
output = @system.run_command(
|
203
|
+
chkconfig,
|
204
|
+
"--allservices",
|
205
|
+
stdout: :capture
|
206
|
+
)
|
207
|
+
|
208
|
+
output.lines.map do |line|
|
209
|
+
name, state = line.split(/\s+/)
|
210
|
+
Service.new(name: name, state: state)
|
211
|
+
end
|
184
212
|
end
|
185
|
-
end
|
186
213
|
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
214
|
+
def parse_redhat_chkconfig
|
215
|
+
@system.check_requirement("/sbin/runlevel")
|
216
|
+
_, runlevel = @system.run_command(
|
217
|
+
"/sbin/runlevel",
|
218
|
+
stdout: :capture
|
219
|
+
).split(" ")
|
220
|
+
|
221
|
+
output = @system.run_command(
|
222
|
+
"/sbin/chkconfig", "--list",
|
223
|
+
stdout: :capture
|
224
|
+
)
|
225
|
+
|
226
|
+
# Run chkconfig output through regular expressions to parse
|
227
|
+
# seperatly for systemv and xinetd services.
|
228
|
+
services = output.lines.select do |line|
|
229
|
+
line =~ /^\S+(\s+\d:(on|off))+.*$/
|
230
|
+
end.map do |line|
|
231
|
+
name, *state = line.split(/\s+/)
|
232
|
+
Service.new(name: name, state: state[runlevel.to_i].split(":")[1])
|
233
|
+
end
|
202
234
|
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
stdout: :capture
|
208
|
-
).split(" ")
|
209
|
-
|
210
|
-
output = @system.run_command(
|
211
|
-
"/sbin/chkconfig", "--list",
|
212
|
-
stdout: :capture
|
213
|
-
)
|
214
|
-
|
215
|
-
# Run chkconfig output through regular expressions to parse
|
216
|
-
# seperatly for systemv and xinetd services.
|
217
|
-
services = output.lines.select do |line|
|
218
|
-
line =~ /^\S+(\s+\d:(on|off))+.*$/
|
219
|
-
end.map do |line|
|
220
|
-
state = []
|
221
|
-
name, state[0], state[1], state[2], state[3], state[4], state[5], state[6] = line.split(/\s+/)
|
222
|
-
Service.new(name: name, state: state[runlevel.to_i].split(":")[1])
|
223
|
-
end
|
235
|
+
services += output.lines.select { |line| line =~ /^\s+\S+:\s+(on|off).*$/ }.map do |line|
|
236
|
+
name, state = line.split(/:/)
|
237
|
+
Service.new(name: name.strip, state: state.strip)
|
238
|
+
end
|
224
239
|
|
225
|
-
|
226
|
-
name, state = line.split(/:/)
|
227
|
-
Service.new(name: name.strip, state: state.strip)
|
240
|
+
services
|
228
241
|
end
|
229
|
-
|
230
|
-
services
|
231
242
|
end
|
232
243
|
end
|