Class: Serverspec::Commands::Solaris
- Inherits:
-
Base
- Object
- Base
- Serverspec::Commands::Solaris
show all
- Defined in:
- lib/serverspec/commands/solaris.rb
Instance Method Summary
collapse
-
#check_belonging_group(user, group) ⇒ Object
-
#check_cron_entry(user, entry) ⇒ Object
-
#check_enabled(service) ⇒ Object
-
#check_file_contain_within(file, expected_pattern, from = nil, to = nil) ⇒ Object
-
#check_gid(group, gid) ⇒ Object
-
#check_home_directory(user, path_to_home) ⇒ Object
-
#check_installed(package) ⇒ Object
-
#check_ipfilter_rule(rule) ⇒ Object
-
#check_ipnat_rule(rule) ⇒ Object
-
#check_listening(port) ⇒ Object
-
#check_login_shell(user, path_to_shell) ⇒ Object
-
#check_running(service) ⇒ Object
-
#check_svcprop(svc, property, value) ⇒ Object
-
#check_svcprops(svc, property) ⇒ Object
-
#check_zfs(zfs, property = nil) ⇒ Object
Methods inherited from Base
#check_authorized_key, #check_directory, #check_file, #check_file_contain, #check_group, #check_grouped, #check_installed_by_gem, #check_iptables_rule, #check_link, #check_mode, #check_mounted, #check_owner, #check_process, #check_resolvable, #check_running_under_supervisor, #check_selinux, #check_uid, #check_user, #get_mode
Instance Method Details
#check_belonging_group(user, group) ⇒ Object
64
65
66
|
# File 'lib/serverspec/commands/solaris.rb', line 64
def check_belonging_group user, group
"id -Gn #{user} | grep #{group}"
end
|
#check_cron_entry(user, entry) ⇒ Object
20
21
22
23
|
# File 'lib/serverspec/commands/solaris.rb', line 20
def check_cron_entry user, entry
entry_escaped = entry.gsub(/\*/, '\\*')
"crontab -l #{user} | grep '#{entry_escaped}'"
end
|
#check_enabled(service) ⇒ Object
4
5
6
|
# File 'lib/serverspec/commands/solaris.rb', line 4
def check_enabled service
"svcs -l #{service} 2> /dev/null | grep 'enabled true'"
end
|
#check_file_contain_within(file, expected_pattern, from = nil, to = nil) ⇒ Object
57
58
59
60
61
62
|
# File 'lib/serverspec/commands/solaris.rb', line 57
def check_file_contain_within file, expected_pattern, from=nil, to=nil
from ||= '1'
to ||= '$'
checker = check_file_contain("/dev/stdin", expected_pattern)
"sed -n '#{from},#{to}p' #{file} | #{checker}"
end
|
#check_gid(group, gid) ⇒ Object
68
69
70
|
# File 'lib/serverspec/commands/solaris.rb', line 68
def check_gid group, gid
"getent group | grep ^#{group}: | cut -f 3 -d ':' | grep -w #{gid}"
end
|
#check_home_directory(user, path_to_home) ⇒ Object
72
73
74
|
# File 'lib/serverspec/commands/solaris.rb', line 72
def check_home_directory user, path_to_home
"getent passwd #{user} | cut -f 6 -d ':' | grep -w #{path_to_home}"
end
|
#check_installed(package) ⇒ Object
8
9
10
|
# File 'lib/serverspec/commands/solaris.rb', line 8
def check_installed package
"pkg list -H #{package} 2> /dev/null"
end
|
#check_ipfilter_rule(rule) ⇒ Object
37
38
39
|
# File 'lib/serverspec/commands/solaris.rb', line 37
def check_ipfilter_rule rule
"/sbin/ipfstat -io 2> /dev/null | grep '#{rule}'"
end
|
#check_ipnat_rule(rule) ⇒ Object
41
42
43
|
# File 'lib/serverspec/commands/solaris.rb', line 41
def check_ipnat_rule rule
"/sbin/ipnat -l 2> /dev/null | grep '^#{rule}$'"
end
|
#check_listening(port) ⇒ Object
12
13
14
|
# File 'lib/serverspec/commands/solaris.rb', line 12
def check_listening port
"netstat -an 2> /dev/null | egrep 'LISTEN|Idle' | grep '\.#{port} '"
end
|
#check_login_shell(user, path_to_shell) ⇒ Object
76
77
78
|
# File 'lib/serverspec/commands/solaris.rb', line 76
def check_login_shell user, path_to_shell
"getent passwd #{user} | cut -f 7 -d ':' | grep -w #{path_to_shell}"
end
|
#check_running(service) ⇒ Object
16
17
18
|
# File 'lib/serverspec/commands/solaris.rb', line 16
def check_running service
"svcs -l #{service} status 2> /dev/null |grep 'state online'"
end
|
#check_svcprop(svc, property, value) ⇒ Object
45
46
47
|
# File 'lib/serverspec/commands/solaris.rb', line 45
def check_svcprop svc, property, value
"svcprop -p #{property} #{svc} | grep ^#{value}$"
end
|
#check_svcprops(svc, property) ⇒ Object
49
50
51
52
53
54
55
|
# File 'lib/serverspec/commands/solaris.rb', line 49
def check_svcprops svc, property
commands = []
property.sort.each do |key, value|
commands << "svcprop -p #{key} #{svc} | grep ^#{value}$"
end
commands.join(' && ')
end
|
#check_zfs(zfs, property = nil) ⇒ Object
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/serverspec/commands/solaris.rb', line 25
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
|