Sha256: 7db0345d97d7699b4ee2c6b355b36ca112d43fc9adeab7eb27ba92a55a6cd993
Contents?: true
Size: 1.33 KB
Versions: 2
Compression:
Stored size: 1.33 KB
Contents
require 'shellwords' module Serverspec module Commands class Linux < Base def check_access_by_user(file, user, access) "su -s /bin/sh -c \"test -#{access} #{file}\" #{user}" end def check_iptables_rule(rule, table=nil, chain=nil) cmd = "iptables" cmd += " -t #{escape(table)}" if table cmd += " -S" cmd += " #{escape(chain)}" if chain cmd += " | grep -- #{escape(rule)}" cmd end def check_selinux(mode) cmd = "" cmd += "test ! -f /etc/selinux/config || (" if mode == "disabled" cmd += "getenforce | grep -i -- #{escape(mode)} " cmd += "&& grep -i -- ^SELINUX=#{escape(mode)}$ /etc/selinux/config" cmd += ")" if mode == "disabled" cmd end def check_kernel_module_loaded(name) "lsmod | grep ^#{name}" end def get_interface_speed_of(name) "ethtool #{name} | grep Speed | gawk '{print gensub(/Speed: ([0-9]+)Mb\\\/s/,\"\\\\1\",\"\")}'" end def check_ipv4_address(interface, ip_address) ip_address = ip_address.dup if ip_address =~ /\/\d+$/ ip_address << " " else ip_address << "/" end ip_address.gsub!(".", "\\.") "ip addr show #{interface} | grep 'inet #{ip_address}'" end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
serverspec-0.7.9 | lib/serverspec/commands/linux.rb |
serverspec-0.7.8 | lib/serverspec/commands/linux.rb |