specinfra 1.27.5 → 2.0.0.beta1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cf132b8746de3ef1580b6c39ef553ee7b2459832
4
- data.tar.gz: 03a3abbe7eadea2f0436b9363cc59737ab7bfc2a
3
+ metadata.gz: 0ebda9e1a8980f9cd098f5831d06e0a7cdce6d62
4
+ data.tar.gz: 9bf241f31f25c1f8e5ab0260f2a3461c8e45dd0a
5
5
  SHA512:
6
- metadata.gz: ca0ab54768ea1818a89c2b3e96fc9dae37495a14e0aa1921b28c102b71178e83d978edd9721315ed67cf43dbfde54365e61a048c823ccf2ab3ded603469b6d58
7
- data.tar.gz: a0e32824d098305ddac11e1c2bf19fc69c9848cb77bf77e1edf6b66786ee9bbb028a9e6c7f99035770671d24f931cc3e147c2d3b4ca94a3b1de9c9f2f38ab4fe
6
+ metadata.gz: 63aa54e8bd0578ed770798036e1f97b12868d37aefea6b163c28ee235435113d01b40d225eb03cac389d002ea4982d8e43531b292e7f1e34740a4c1574362d65
7
+ data.tar.gz: 7763ef61cc1fe078e44b0c4e879e2f0831ec8a67a16ab77e79ade0f57fef9fd7a4b2020811aca30260a247f2fdd4b65956256736acce0e7a267172c40384e35c
data/Rakefile CHANGED
@@ -1,36 +1,30 @@
1
1
  require "bundler/gem_tasks"
2
- begin
3
- require "rspec/core/rake_task"
4
- require "octorelease"
5
- rescue LoadError
6
- end
2
+ require "rspec/core/rake_task"
3
+ require "octorelease"
7
4
 
8
- if defined?(RSpec)
9
- task :spec => 'spec:all'
5
+ task :spec => 'spec:all'
10
6
 
11
- namespace :spec do
12
- task :all => [ :helper, :backend, :configuration ]
7
+ namespace :spec do
8
+ task :all => [ :helper, :backend, :configuration ]
13
9
 
14
- RSpec::Core::RakeTask.new(:helper) do |t|
15
- t.pattern = "spec/helper/*_spec.rb"
16
- end
10
+ RSpec::Core::RakeTask.new(:helper) do |t|
11
+ t.pattern = "spec/helper/*_spec.rb"
12
+ end
17
13
 
18
- task :backend => 'backend:all'
19
- namespace :backend do
20
- backends = %w[exec ssh]
14
+ task :backend => 'backend:all'
15
+ namespace :backend do
16
+ backends = %w[exec ssh]
21
17
 
22
- task :all => backends
18
+ task :all => backends
23
19
 
24
- backends.each do |backend|
25
- RSpec::Core::RakeTask.new(backend) do |t|
26
- t.pattern = "spec/backend/#{backend}/*_spec.rb"
27
- end
20
+ backends.each do |backend|
21
+ RSpec::Core::RakeTask.new(backend) do |t|
22
+ t.pattern = "spec/backend/#{backend}/*_spec.rb"
28
23
  end
29
24
  end
25
+ end
30
26
 
31
- RSpec::Core::RakeTask.new(:configuration) do |t|
32
- t.pattern = "spec/configuration_spec.rb"
33
- end
27
+ RSpec::Core::RakeTask.new(:configuration) do |t|
28
+ t.pattern = "spec/configuration_spec.rb"
34
29
  end
35
30
  end
36
-
@@ -1,5 +1,6 @@
1
1
  require 'singleton'
2
2
  require 'fileutils'
3
+ require 'shellwords'
3
4
 
4
5
  module SpecInfra
5
6
  module Backend
@@ -33,22 +34,25 @@ module SpecInfra
33
34
  end
34
35
 
35
36
  def build_command(cmd)
37
+ shell = SpecInfra.configuration.shell || '/bin/sh'
38
+ cmd = cmd.shelljoin if cmd.is_a?(Array)
39
+ cmd = "#{shell.shellescape} -c #{cmd.shellescape}"
40
+
36
41
  path = SpecInfra.configuration.path
37
42
  if path
38
- cmd = "env PATH=#{path}:$PATH #{cmd}"
39
- cmd.gsub!(/(\&\&\s*!?\(?\s*)/, "\\1env PATH=#{path}:$PATH ")
40
- cmd.gsub!(/(\|\|\s*!?\(?\s*)/, "\\1env PATH=#{path}:$PATH ")
43
+ cmd = "env PATH=#{path.shellescape}:\"$PATH\" #{cmd}"
41
44
  end
45
+
42
46
  cmd
43
47
  end
44
48
 
45
49
  def add_pre_command(cmd)
46
- path = SpecInfra.configuration.path
47
50
  if SpecInfra.configuration.pre_command
48
- cmd = "#{SpecInfra.configuration.pre_command} && #{cmd}"
49
- cmd = "env PATH=#{path}:$PATH #{cmd}" if path
51
+ pre_cmd = build_command(SpecInfra.configuration.pre_command)
52
+ "#{pre_cmd} && #{cmd}"
53
+ else
54
+ cmd
50
55
  end
51
- cmd
52
56
  end
53
57
 
54
58
  def check_running(process)
@@ -181,38 +185,20 @@ module SpecInfra
181
185
 
182
186
  def check_os
183
187
  return SpecInfra.configuration.os if SpecInfra.configuration.os
184
- arch = run_command('uname -m').stdout.strip
185
- # Fedora also has an /etc/redhat-release so the Fedora check must
186
- # come before the RedHat check
187
- if run_command('ls /etc/fedora-release').success?
188
- line = run_command('cat /etc/redhat-release').stdout
189
- if line =~ /release (\d[\d]*)/
190
- release = $1
191
- end
192
- { :family => 'Fedora', :release => release }
193
- elsif run_command('ls /etc/redhat-release').success?
188
+ if run_command('ls /etc/redhat-release').success?
194
189
  line = run_command('cat /etc/redhat-release').stdout
195
190
  if line =~ /release (\d[\d.]*)/
196
191
  release = $1
197
192
  end
198
-
199
- if release =~ /7./
200
- { :family => 'RedHat7', :release => release, :arch => arch }
201
- else
202
- { :family => 'RedHat', :release => release, :arch => arch }
203
- end
193
+ { :family => 'RedHat', :release => release }
204
194
  elsif run_command('ls /etc/system-release').success?
205
- { :family => 'RedHat', :release => nil, :arch => arch } # Amazon Linux
195
+ { :family => 'RedHat', :release => nil } # Amazon Linux
206
196
  elsif run_command('ls /etc/SuSE-release').success?
207
197
  line = run_command('cat /etc/SuSE-release').stdout
208
198
  if line =~ /SUSE Linux Enterprise Server (\d+)/
209
199
  release = $1
210
- family = 'SuSE'
211
- elsif line =~ /openSUSE (\d+\.\d+|\d+)/
212
- release = $1
213
- family = 'OpenSUSE'
214
200
  end
215
- { :family => family, :release => release, :arch => arch }
201
+ { :family => 'SuSE', :release => release }
216
202
  elsif run_command('ls /etc/debian_version').success?
217
203
  lsb_release = run_command("lsb_release -ir")
218
204
  if lsb_release.success?
@@ -231,39 +217,37 @@ module SpecInfra
231
217
  end
232
218
  distro ||= 'Debian'
233
219
  release ||= nil
234
- { :family => distro.strip, :release => release, :arch => arch }
220
+ { :family => distro.strip, :release => release }
235
221
  elsif run_command('ls /etc/gentoo-release').success?
236
- { :family => 'Gentoo', :release => nil, :arch => arch }
222
+ { :family => 'Gentoo', :release => nil }
237
223
  elsif run_command('ls /usr/lib/setup/Plamo-*').success?
238
- { :family => 'Plamo', :release => nil, :arch => arch }
239
- elsif run_command('ls /var/run/current-system/sw').success?
240
- { :family => 'NixOS', :release => nil, :arch => arch }
224
+ { :family => 'Plamo', :release => nil }
241
225
  elsif run_command('uname -s').stdout =~ /AIX/i
242
- { :family => 'AIX', :release => nil, :arch => arch }
243
- elsif ( uname = run_command('uname -sr').stdout) && uname =~ /SunOS/i
244
- if uname =~ /5.10/
245
- { :family => 'Solaris10', :release => nil, :arch => arch }
226
+ { :family => 'AIX', :release => nil }
227
+ elsif (os = run_command('uname -sr').stdout) && os =~ /SunOS/i
228
+ if os =~ /5.10/
229
+ { :family => 'Solaris10', :release => nil }
246
230
  elsif run_command('grep -q "Oracle Solaris 11" /etc/release').success?
247
- { :family => 'Solaris11', :release => nil, :arch => arch }
231
+ { :family => 'Solaris11', :release => nil }
248
232
  elsif run_command('grep -q SmartOS /etc/release').success?
249
- { :family => 'SmartOS', :release => nil, :arch => arch }
233
+ { :family => 'SmartOS', :release => nil }
250
234
  else
251
- { :family => 'Solaris', :release => nil, :arch => arch }
235
+ { :family => 'Solaris', :release => nil }
252
236
  end
253
237
  elsif run_command('uname -s').stdout =~ /Darwin/i
254
238
  { :family => 'Darwin', :release => nil }
255
- elsif ( uname = run_command('uname -sr').stdout ) && uname =~ /FreeBSD/i
256
- if uname =~ /10./
257
- { :family => 'FreeBSD10', :release => nil, :arch => arch }
239
+ elsif (os = run_command('uname -sr').stdout) && os =~ /FreeBSD/i
240
+ if os =~ /10./
241
+ { :family => 'FreeBSD10', :release => nil }
258
242
  else
259
- { :family => 'FreeBSD', :release => nil, :arch => arch }
243
+ { :family => 'FreeBSD', :release => nil }
260
244
  end
261
245
  elsif run_command('uname -sr').stdout =~ /Arch/i
262
- { :family => 'Arch', :release => nil, :arch => arch }
246
+ { :family => 'Arch', :release => nil }
263
247
  elsif run_command('uname -s').stdout =~ /OpenBSD/i
264
- { :family => 'OpenBSD', :release => nil, :arch => arch }
248
+ { :family => 'OpenBSD', :release => nil }
265
249
  else
266
- { :family => 'Base', :release => nil, :arch => arch }
250
+ { :family => 'Base', :release => nil }
267
251
  end
268
252
  end
269
253
 
@@ -1,89 +1,13 @@
1
1
  function FindIISWebsite
2
2
  {
3
3
  param($name)
4
-
5
- Import-Module WebAdministration
6
-
7
- Try {
8
- Get-Item "IIS:\Sites\$name" -Erroraction silentlycontinue
9
- }
10
- Catch [System.IO.FileNotFoundException] {
11
- Get-Item "IIS:\Sites\$name" -Erroraction silentlycontinue
12
- }
4
+ import-module WebAdministration
5
+ Get-Website | Where { $_.name -match $name }
13
6
  }
14
7
 
15
8
  function FindIISAppPool
16
9
  {
17
10
  param($name)
18
-
19
- Import-Module WebAdministration
20
- Try {
21
- Get-Item "IIS:\AppPools\$name" -Erroraction silentlycontinue
22
- }
23
- Catch [System.IO.FileNotFoundException] {
24
- Get-Item "IIS:\AppPools\$name" -Erroraction silentlycontinue
25
-
26
- }
27
- }
28
-
29
- function FindSiteBindings
30
- {
31
- param($name, $protocol, $hostHeader, $port, $ipAddress)
32
-
33
- Import-Module WebAdministration
34
- Try {
35
- Get-WebBinding -Name $name -Protocol $protocol -HostHeader $hostHeader -Port $port -IPAddress $ipAddress
36
- }
37
- Catch [System.IO.FileNotFoundException] {
38
- Get-WebBinding -Name $name -Protocol $protocol -HostHeader $hostHeader -Port $port -IPAddress $ipAddress
39
- }
40
- }
41
-
42
- function FindSiteVirtualDir
43
- {
44
- param($name, $vdir, $path)
45
-
46
- Import-Module WebAdministration
47
-
48
- $webVirtDirPath = [string]::Format('IIS:\Sites\{0}\{1}',$name, $vdir);
49
- if (Test-Path $webVirtDirPath)
50
- {
51
- if ([string]::IsNullOrEmpty($path))
52
- {
53
- $true
54
- }
55
- else
56
- {
57
- (Get-Item $webVirtDirPath).physicalPath -eq $path
58
- }
59
- }
60
- else
61
- {
62
- $false
63
- }
64
- }
65
-
66
- function FindSiteApplication
67
- {
68
- param($name, $app, $pool, $physicalPath)
69
-
70
- Import-Module WebAdministration
71
-
72
- $path = "IIS:\Sites\${name}\${app}"
73
- $result = $false
74
- if (Test-Path $path)
75
- {
76
- $result = $true
77
- if ([string]::IsNullOrEmpty($pool) -eq $false)
78
- {
79
- $result = $result -and (Get-Item $path).applicationPool -eq $pool
80
- }
81
-
82
- if ([string]::IsNullOrEmpty($physicalPath) -eq $false)
83
- {
84
- $result = $result -and (Get-Item $path).physicalPath -eq $physicalPath
85
- }
86
- }
87
-
88
- $result
89
- }
11
+ import-module WebAdministration
12
+ Get-Item "IIS:\AppPools\$name" -Erroraction silentlycontinue
13
+ }
@@ -24,19 +24,6 @@ module SpecInfra
24
24
  disable_sudo = SpecInfra.configuration.disable_sudo
25
25
  if user != 'root' && !disable_sudo
26
26
  cmd = "#{sudo} #{cmd}"
27
- cmd.gsub!(/(\&\&\s*!?\(?\s*)/, "\\1#{sudo} ")
28
- cmd.gsub!(/(\|\|\s*!?\(?\s*)/, "\\1#{sudo} ")
29
- end
30
- cmd
31
- end
32
-
33
- def add_pre_command(cmd)
34
- cmd = super(cmd)
35
- user = SpecInfra.configuration.ssh.options[:user]
36
- pre_command = SpecInfra.configuration.pre_command
37
- disable_sudo = SpecInfra.configuration.disable_sudo
38
- if pre_command && user != 'root' && !disable_sudo
39
- cmd = "#{sudo} #{cmd}"
40
27
  end
41
28
  cmd
42
29
  end
@@ -58,7 +45,6 @@ module SpecInfra
58
45
  exit_status = nil
59
46
  exit_signal = nil
60
47
  pass_prompt = SpecInfra.configuration.pass_prompt || /^\[sudo\] password for/
61
- retry_prompt = /^Sorry, try again/
62
48
 
63
49
  ssh = SpecInfra.configuration.ssh
64
50
  ssh.open_channel do |channel|
@@ -70,9 +56,7 @@ module SpecInfra
70
56
  channel.exec("#{command}") do |ch, success|
71
57
  abort "FAILED: couldn't execute command (ssh.channel.exec)" if !success
72
58
  channel.on_data do |ch, data|
73
- if data.match retry_prompt
74
- abort 'Wrong sudo password! Please confirm your password.'
75
- elsif data.match pass_prompt
59
+ if data.match pass_prompt
76
60
  channel.send_data "#{SpecInfra.configuration.sudo_password}\n"
77
61
  else
78
62
  stdout_data += data
@@ -81,7 +65,7 @@ module SpecInfra
81
65
 
82
66
  channel.on_extended_data do |ch, type, data|
83
67
  if data.match /you must have a tty to run sudo/
84
- abort 'Please set "SpecInfra.configuration.request_pty = true" or "c.request_pty = true" in your spec_helper.rb or other appropriate file.'
68
+ abort 'Please set "SpecInfra.configuration.request_pty = true" or "c.request_pty = true" in your spec_helper.rb or other appropreate file.'
85
69
  end
86
70
 
87
71
  if data.match /^sudo: no tty present and no askpass program specified/
@@ -105,16 +89,19 @@ module SpecInfra
105
89
  end
106
90
 
107
91
  def sudo
108
- sudo_path = SpecInfra.configuration.sudo_path
109
- sudo_path += '/' if sudo_path
92
+ if sudo_path = SpecInfra.configuration.sudo_path
93
+ sudo_path += '/sudo'
94
+ else
95
+ sudo_path = 'sudo'
96
+ end
110
97
 
111
98
  sudo_options = SpecInfra.configuration.sudo_options
112
99
  if sudo_options
113
- sudo_options = sudo_options.join(' ') if sudo_options.is_a?(Array)
100
+ sudo_options = sudo_options.shelljoin if sudo_options.is_a?(Array)
114
101
  sudo_options = ' ' + sudo_options
115
102
  end
116
103
 
117
- "#{sudo_path}sudo#{sudo_options}"
104
+ "#{sudo_path.shellescape}#{sudo_options}"
118
105
  end
119
106
  end
120
107
  end
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  module SpecInfra
3
2
  module Command
4
3
  class Arch < Linux
@@ -8,7 +7,7 @@ module SpecInfra
8
7
 
9
8
  def check_enabled(service, level)
10
9
  level = "multi-user.target" if level == 3
11
- "systemctl --plain list-dependencies #{level} | grep '^● #{escape(service)}.service$'"
10
+ "systemctl --plain list-dependencies #{level} | grep '^#{escape(service)}.service$'"
12
11
  end
13
12
 
14
13
  def check_running(service)
@@ -17,12 +16,12 @@ module SpecInfra
17
16
 
18
17
  def check_installed(package,version=nil)
19
18
  if version
20
- grep = version.include?('-') ? "^#{escape(version)}$" : "^#{escape(version)}-"
21
- "pacman -Q #{escape(package)} | awk '{print $2}' | grep '#{grep}'"
19
+ "pacman -Q | grep #{escape(package)} #{espace(version)}"
22
20
  else
23
- "pacman -Q #{escape(package)}"
21
+ "pacman -Q | grep #{escape(package)}"
24
22
  end
25
23
  end
24
+
26
25
  def sync_repos
27
26
  "pacman -Syy"
28
27
  end
@@ -29,8 +29,8 @@ module SpecInfra
29
29
  end
30
30
 
31
31
  def check_mounted(path)
32
- regexp = "on #{path} "
33
- "mount | grep -- '#{escape(regexp)}'"
32
+ regexp = "on #{path}"
33
+ "mount | grep -w -- #{escape(regexp)}"
34
34
  end
35
35
 
36
36
  def check_routing_table(destination)
@@ -59,14 +59,6 @@ module SpecInfra
59
59
  "test -f #{escape(file)}"
60
60
  end
61
61
 
62
- def get_file_mtime(file)
63
- "stat -c %Y #{escape(file)}"
64
- end
65
-
66
- def get_file_size(file)
67
- "stat -c %s #{escape(file)}"
68
- end
69
-
70
62
  def check_socket(file)
71
63
  "test -S #{escape(file)}"
72
64
  end
@@ -80,7 +72,7 @@ module SpecInfra
80
72
  end
81
73
 
82
74
  def check_group(group)
83
- "getent group #{escape(group)}"
75
+ "getent group | grep -wq -- #{escape(group)}"
84
76
  end
85
77
 
86
78
  def check_installed(package, version=nil)
@@ -129,10 +121,6 @@ module SpecInfra
129
121
  "ps aux | grep -w -- #{escape(process)} | grep -qv grep"
130
122
  end
131
123
 
132
- def check_process_count(process, count)
133
- "test $(ps aux | grep -w -- #{escape(process)} | grep -v grep | wc -l) -eq #{escape(count)}"
134
- end
135
-
136
124
  def get_process(process, opts)
137
125
  "ps -C #{escape(process)} -o #{opts[:format]} | head -1"
138
126
  end
@@ -142,11 +130,11 @@ module SpecInfra
142
130
  end
143
131
 
144
132
  def check_file_contain_with_regexp(file, expected_pattern)
145
- "grep -qs -- #{escape(expected_pattern)} #{escape(file)}"
133
+ "grep -q -- #{escape(expected_pattern)} #{escape(file)}"
146
134
  end
147
135
 
148
136
  def check_file_contain_with_fixed_strings(file, expected_pattern)
149
- "grep -qFs -- #{escape(expected_pattern)} #{escape(file)}"
137
+ "grep -qF -- #{escape(expected_pattern)} #{escape(file)}"
150
138
  end
151
139
 
152
140
  def check_file_checksum(file, expected)
@@ -168,7 +156,6 @@ module SpecInfra
168
156
  from ||= '1'
169
157
  to ||= '$'
170
158
  sed = "sed -n #{escape(from)},#{escape(to)}p #{escape(file)}"
171
- sed += " | sed -n 1,#{escape(to)}p" if from != '1' and to != '$'
172
159
  checker_with_regexp = check_file_contain_with_regexp("-", expected_pattern)
173
160
  checker_with_fixed = check_file_contain_with_fixed_strings("-", expected_pattern)
174
161
  "#{sed} | #{checker_with_regexp} || #{sed} | #{checker_with_fixed}"
@@ -201,7 +188,7 @@ module SpecInfra
201
188
  end
202
189
 
203
190
  def check_cron_entry(user, entry)
204
- entry_escaped = entry.gsub(/\*/, '\\*').gsub(/\[/, '\\[').gsub(/\]/, '\\]')
191
+ entry_escaped = entry.gsub(/\*/, '\\*')
205
192
  if user.nil?
206
193
  "crontab -l | grep -v \"#\" -- | grep -- #{escape(entry_escaped)}"
207
194
  else
@@ -258,10 +245,6 @@ module SpecInfra
258
245
  "id #{escape(user)} | awk '{print $3}' | grep -- #{escape(group)}"
259
246
  end
260
247
 
261
- def check_primary_group(group)
262
- raise NotImplementedError.new
263
- end
264
-
265
248
  def check_gid(group, gid)
266
249
  regexp = "^#{group}"
267
250
  "getent group | grep -w -- #{escape(regexp)} | cut -f 3 -d ':' | grep -w -- #{escape(gid)}"
@@ -289,10 +272,6 @@ module SpecInfra
289
272
  raise NotImplementedError.new
290
273
  end
291
274
 
292
- def check_ip6tables_rule(rule, table=nil, chain=nil)
293
- raise NotImplementedError.new
294
- end
295
-
296
275
  def check_zfs(zfs, property=nil, value=nil)
297
276
  raise NotImplementedError.new
298
277
  end
@@ -332,10 +311,6 @@ module SpecInfra
332
311
  def check_ipv4_address(interface, ip_address)
333
312
  raise NotImplementedError.new
334
313
  end
335
-
336
- def check_ipv6_address(interface, ip_address)
337
- raise NotImplementedError.new
338
- end
339
314
 
340
315
  def check_mail_alias(recipient, target)
341
316
  target = "[[:space:]]#{target}"
@@ -354,10 +329,6 @@ module SpecInfra
354
329
  raise NotImplementedError.new
355
330
  end
356
331
 
357
- def check_immutable(file)
358
- raise NotImplementedError.new
359
- end
360
-
361
332
  def get_package_version(package, opts=nil)
362
333
  raise NotImplementedError.new
363
334
  end
@@ -1,19 +1,6 @@
1
1
  module SpecInfra
2
2
  module Command
3
3
  class Darwin < Base
4
- def check_enabled(service, level=nil)
5
- "launchctl list | grep #{escape(service)}"
6
- end
7
-
8
- def check_running(service)
9
- "launchctl list | grep #{escape(service)} | grep -E '^[0-9]+'"
10
- end
11
-
12
- def check_listening(port)
13
- regexp = ":#{port} "
14
- "lsof -nP -iTCP -sTCP:LISTEN | grep -- #{escape(regexp)}"
15
- end
16
-
17
4
  def check_file_md5checksum(file, expected)
18
5
  "openssl md5 #{escape(file)} | cut -d'=' -f2 | cut -c 2- | grep -E ^#{escape(expected)}$"
19
6
  end
@@ -58,12 +45,6 @@ module SpecInfra
58
45
  end
59
46
  cmd
60
47
  end
61
- alias :check_installed_by_homebrew :check_installed
62
-
63
- def check_installed_by_pkgutil(package, version=nil)
64
- cmd = "pkgutil --pkg-info #{package}"
65
- cmd = "#{cmd} | grep '^version: #{escape(version)}'" if version
66
- end
67
48
 
68
49
  def install(package)
69
50
  cmd = "brew install '#{package}'"
@@ -2,12 +2,8 @@ module SpecInfra
2
2
  module Command
3
3
  class Debian < Linux
4
4
  def check_enabled(service, level=3)
5
- # Debian jessie default init system (on Linux) is systemd,
6
- # but upstart and sysvinit is also available.
7
- cmd = "if [ -d /run/systemd/system ]; then systemctl --plain list-dependencies runlevel#{level}.target | grep '^#{escape(service)}.service$'; "
8
- cmd += "else ls /etc/rc#{level}.d/ | grep -- '^S..#{escape(service)}' || grep 'start on' /etc/init/#{escape(service)}.conf; "
9
- cmd += "fi"
10
- "sh -c \"#{cmd}\""
5
+ # Until everything uses Upstart, this needs an OR.
6
+ "ls /etc/rc#{level}.d/ | grep -- '^S..#{escape(service)}' || grep 'start on' /etc/init/#{escape(service)}.conf"
11
7
  end
12
8
 
13
9
  def check_installed(package, version=nil)
@@ -23,20 +23,6 @@ module SpecInfra
23
23
  "stat -f%Lp #{escape(file)} | grep -- #{escape(regexp)}"
24
24
  end
25
25
 
26
- def check_owner(file, owner)
27
- regexp = "^#{owner}$"
28
- "stat -f%Su #{escape(file)} | grep -- #{escape(regexp)}"
29
- end
30
-
31
- def check_grouped(file, group)
32
- regexp = "^#{group}$"
33
- "stat -f%Sg #{escape(file)} | grep -- #{escape(regexp)}"
34
- end
35
-
36
- def check_link(link, target)
37
- "stat -f%Y #{escape(link)} | grep -- #{escape(target)}"
38
- end
39
-
40
26
  def get_mode(file)
41
27
  "stat -f%Lp #{escape(file)}"
42
28
  end
@@ -17,18 +17,6 @@ module SpecInfra
17
17
  cmd
18
18
  end
19
19
 
20
- def check_ip6tables_rule(rule, table=nil, chain=nil)
21
- cmd = "ip6tables"
22
- cmd += " -t #{escape(table)}" if table
23
- cmd += " -S"
24
- cmd += " #{escape(chain)}" if chain
25
- cmd += " | grep -- #{escape(rule)}"
26
- cmd += " || ip6tables-save"
27
- cmd += " -t #{escape(table)}" if table
28
- cmd += " | grep -- #{escape(rule)}"
29
- cmd
30
- end
31
-
32
20
  def check_selinux(mode)
33
21
  cmd = ""
34
22
  cmd += "test ! -f /etc/selinux/config || (" if mode == "disabled"
@@ -56,17 +44,6 @@ module SpecInfra
56
44
  ip_address.gsub!(".", "\\.")
57
45
  "ip addr show #{interface} | grep 'inet #{ip_address}'"
58
46
  end
59
-
60
- def check_ipv6_address(interface, ip_address)
61
- ip_address = ip_address.dup
62
- if ip_address =~ /\/\d+$/
63
- ip_address << " "
64
- else
65
- ip_address << "/"
66
- end
67
- ip_address.downcase!
68
- "ip addr show #{interface} | grep 'inet6 #{ip_address}'"
69
- end
70
47
 
71
48
  def check_zfs(zfs, property=nil)
72
49
  if property.nil?
@@ -86,15 +63,7 @@ module SpecInfra
86
63
  end
87
64
 
88
65
  def check_container_running(container)
89
- "lxc-info -n #{escape(container)} -s | grep -w RUNNING"
90
- end
91
-
92
- def check_attribute(file, attribute)
93
- "lsattr -d #{escape(file)} 2>&1 | awk '$1~/^-*#{escape(attribute)}-*$/ {exit 0} {exit 1}'"
94
- end
95
-
96
- def check_immutable(file)
97
- check_attribute(file, 'i')
66
+ "lxc-info -n #{escape(container)} -t RUNNING"
98
67
  end
99
68
 
100
69
  end
@@ -2,7 +2,7 @@ module SpecInfra
2
2
  module Command
3
3
  class OpenBSD < Base
4
4
  def check_enabled(service, level=3)
5
- "rcctl status #{escape(service)}"
5
+ "egrep '(#{escape(service)}_flags=|^pkg_scripts=\"(.*)#{escape(service)}(.*)\")' /etc/rc.conf.local | grep -v \=NO"
6
6
  end
7
7
 
8
8
  def check_file_md5checksum(file, expected)
@@ -76,7 +76,7 @@ module SpecInfra
76
76
  # end
77
77
 
78
78
  def check_running(service)
79
- "rcctl check #{escape(service)}"
79
+ "/etc/rc.d/#{escape(service)} status"
80
80
  end
81
81
 
82
82
  def get_mode(file)
@@ -6,10 +6,6 @@ module SpecInfra
6
6
  "runuser -s /bin/sh -c \"test -#{access} #{file}\" #{user}"
7
7
  end
8
8
 
9
- def check_belonging_primary_group(user, group)
10
- "id -gn #{escape(user)}| grep ^#{escape(group)}$"
11
- end
12
-
13
9
  def check_enabled(service, level=3)
14
10
  "chkconfig --list #{escape(service)} | grep #{level}:on"
15
11
  end