Sha256: 844c516cca1b34c75d9306c5b186c531d73381c6b69ae6673ef978304c6c3333

Contents?: true

Size: 1.51 KB

Versions: 10

Compression:

Stored size: 1.51 KB

Contents

module Serverspec
  module Commands
    class Solaris < Base
      def check_enabled service
        "svcs -l #{service} 2> /dev/null | grep 'enabled      true'"
      end

      def check_installed package
        "pkg list -H #{package} 2> /dev/null"
      end

      def check_listening port
        "netstat -an 2> /dev/null | egrep 'LISTEN|Idle' | grep '\.#{port} '"
      end

      def check_running service
        "svcs -l #{service} status 2> /dev/null |grep 'state        online'"
      end

      def check_cron_entry user, entry
        entry_escaped = entry.gsub(/\*/, '\\*')
        "crontab -l #{user} | grep '#{entry_escaped}'"
      end

      def check_zfs zfs, property=nil
        if property.nil?
          "/sbin/zfs list -H #{zfs}"
        else
          commands = []
          property.sort.each do |key, value|
            commands << "/sbin/zfs list -H -o #{key} #{zfs} | grep ^#{value}$"
          end
          commands.join(' && ')
        end
      end

      def check_ipfilter_rule rule
        "/sbin/ipfstat -io 2> /dev/null | grep '#{rule}'"
      end

      def check_ipnat_rule rule
        "/sbin/ipnat -l 2> /dev/null | grep '^#{rule}$'"
      end

      def check_svcprop svc, property, value
        "svcprop -p #{property} #{svc} | grep ^#{value}$"
      end

      def check_svcprops svc, property
        commands = []
        property.sort.each do |key, value|
          commands << "svcprop -p #{key} #{svc} | grep ^#{value}$"
        end
        commands.join(' && ')
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
serverspec-0.2.16 lib/serverspec/commands/solaris.rb
serverspec-0.2.15 lib/serverspec/commands/solaris.rb
serverspec-0.2.14 lib/serverspec/commands/solaris.rb
serverspec-0.2.13 lib/serverspec/commands/solaris.rb
serverspec-0.2.12 lib/serverspec/commands/solaris.rb
serverspec-0.2.11 lib/serverspec/commands/solaris.rb
serverspec-0.2.10 lib/serverspec/commands/solaris.rb
serverspec-0.2.9 lib/serverspec/commands/solaris.rb
serverspec-0.2.8 lib/serverspec/commands/solaris.rb
serverspec-0.2.7 lib/serverspec/commands/solaris.rb