Sha256: a5561a1d9107f91e65742335605745512f17fd1e3737aa2783e90fd791d5d234

Contents?: true

Size: 1.52 KB

Versions: 146

Compression:

Stored size: 1.52 KB

Contents

class Specinfra::Command::Windows::Base::Service < Specinfra::Command::Windows::Base
  class << self
    def check_is_installed(service)
      Backend::PowerShell::Command.new do
        using 'find_service.ps1'
        exec "@(FindService -name '#{service}').count -gt 0"
      end
    end

    def check_has_start_mode(service, mode)
      Backend::PowerShell::Command.new do
        using 'find_service.ps1'
        exec  "'#{mode}' -match (FindService -name '#{service}').StartMode -and (FindService -name '#{service}') -ne $null"
      end
    end

    def check_is_enabled(service, level=nil)
      Backend::PowerShell::Command.new do
        using 'find_service.ps1'
        exec "(FindService -name '#{service}').StartMode -eq 'Auto'"
      end
    end

    def check_is_running(service)
      Backend::PowerShell::Command.new do
        using 'find_service.ps1'
        exec "(FindService -name '#{service}').State -eq 'Running'"
      end
    end
      
    def check_has_property(service, property)
        command = []
        property.keys.each do |key|
          value= property[key]
          command << "(FindService -name '#{service}').#{key} -eq '#{value}'"
        end
        executable = command.join(' -and ')
        Backend::PowerShell::Command.new do
          using 'find_service.ps1'
          exec executable
        end
    end
    
    def get_property(service)
      Backend::PowerShell::Command.new do
        using 'find_service.ps1'
        exec "(FindService -name '#{service}') | Select-Object *"
      end
    end
  end
end

Version data entries

146 entries across 146 versions & 1 rubygems

Version Path
specinfra-2.91.0 lib/specinfra/command/windows/base/service.rb
specinfra-2.90.1 lib/specinfra/command/windows/base/service.rb
specinfra-2.90.0 lib/specinfra/command/windows/base/service.rb
specinfra-2.89.0 lib/specinfra/command/windows/base/service.rb
specinfra-2.88.2 lib/specinfra/command/windows/base/service.rb
specinfra-2.88.1 lib/specinfra/command/windows/base/service.rb
specinfra-2.88.0 lib/specinfra/command/windows/base/service.rb
specinfra-2.87.2 lib/specinfra/command/windows/base/service.rb
specinfra-2.87.1 lib/specinfra/command/windows/base/service.rb
specinfra-2.87.0 lib/specinfra/command/windows/base/service.rb
specinfra-2.86.0 lib/specinfra/command/windows/base/service.rb
specinfra-2.85.1 lib/specinfra/command/windows/base/service.rb
specinfra-2.85.0 lib/specinfra/command/windows/base/service.rb
specinfra-2.84.1 lib/specinfra/command/windows/base/service.rb
specinfra-2.84.0 lib/specinfra/command/windows/base/service.rb
specinfra-2.83.4 lib/specinfra/command/windows/base/service.rb
specinfra-2.83.3 lib/specinfra/command/windows/base/service.rb
specinfra-2.83.2 lib/specinfra/command/windows/base/service.rb
specinfra-2.83.1 lib/specinfra/command/windows/base/service.rb
specinfra-2.83.0 lib/specinfra/command/windows/base/service.rb