Sha256: 504fa38e0dea06a2bc14baa1825c5976982af54c07a3c3fea1b8133bd362e6fc

Contents?: true

Size: 1.16 KB

Versions: 1

Compression:

Stored size: 1.16 KB

Contents

module Serverspec
  module Commands
    class Base
      class NotImplementedError < Exception; end

      def check_enabled service
        raise NotImplementedError.new
      end

      def check_file file
        "test -f #{file}"
      end

      def check_directory directory
        "test -d #{directory}"
      end

      def check_user user
        "id #{user}"
      end

      def check_group group
        "getent group | grep -wq #{group}"
      end

      def check_installed package
        raise NotImplementedError.new
      end

      def check_listening port
        "netstat -tnl | grep ':#{port} '"
      end

      def check_running service
        "service #{service} status"
      end

      def check_process process
        "ps -e | grep -qw #{process}"
      end

      def check_file_contain file, expected_pattern
        "grep -q '#{expected_pattern}' #{file} "
      end

      def check_mode file, mode
        "stat -c %a #{file} | grep #{mode}"
      end

      def check_owner file, owner
        "stat -c %U #{file} | grep #{owner}"
      end

      def check_group file, group
        "stat -c %G #{file} | grep #{group}"
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
serverspec-0.0.7 lib/serverspec/commands/base.rb