Class: Serverspec::Commands::Aix
- Inherits:
-
Base
- Object
- Base
- Serverspec::Commands::Aix
show all
- Defined in:
- lib/serverspec/commands/aix.rb
Defined Under Namespace
Classes: NotImplementedError
Instance Method Summary
collapse
-
#check_access_by_user(file, user, access) ⇒ Object
-
#check_belonging_group(user, group) ⇒ Object
-
#check_enabled(service, level = nil) ⇒ Object
-
#check_gid(group, gid) ⇒ Object
-
#check_grouped(file, group) ⇒ Object
-
#check_home_directory(user, path_to_home) ⇒ Object
-
#check_installed(package, version) ⇒ Object
-
#check_listening(port) ⇒ Object
-
#check_login_shell(user, path_to_shell) ⇒ Object
-
#check_mode(file, mode) ⇒ Object
-
#check_owner(file, owner) ⇒ Object
-
#check_running(service) ⇒ Object
Methods inherited from Base
#check_authorized_key, #check_cron_entry, #check_directory, #check_file, #check_file_contain, #check_file_contain_with_fixed_strings, #check_file_contain_with_regexp, #check_file_contain_within, #check_file_md5checksum, #check_file_sha256checksum, #check_group, #check_installed_by_gem, #check_installed_by_npm, #check_installed_by_pecl, #check_installed_by_pip, #check_ipfilter_rule, #check_ipnat_rule, #check_iptables_rule, #check_ipv4_address, #check_kernel_module_loaded, #check_link, #check_listening_with_protocol, #check_mail_alias, #check_monitored_by_god, #check_monitored_by_monit, #check_mounted, #check_process, #check_reachable, #check_resolvable, #check_routing_table, #check_running_under_supervisor, #check_running_under_upstart, #check_selinux, #check_socket, #check_svcprop, #check_svcprops, #check_uid, #check_user, #check_yumrepo, #check_yumrepo_enabled, #check_zfs, #escape, #get_mode
Instance Method Details
#check_access_by_user(file, user, access) ⇒ Object
8
9
10
|
# File 'lib/serverspec/commands/aix.rb', line 8
def check_access_by_user(file, user, access)
"su -s sh -c \"test -#{access} #{file}\" #{user}"
end
|
#check_belonging_group(user, group) ⇒ Object
35
36
37
|
# File 'lib/serverspec/commands/aix.rb', line 35
def check_belonging_group(user, group)
"lsuser -a groups #{escape(user)} | awk -F'=' '{print $2}'| sed -e 's/,/ /g' |grep -w -- #{escape(group)}"
end
|
#check_enabled(service, level = nil) ⇒ Object
12
13
14
|
# File 'lib/serverspec/commands/aix.rb', line 12
def check_enabled(service,level=nil)
"lssrc -s #{escape(service)} | grep active"
end
|
#check_gid(group, gid) ⇒ Object
39
40
41
42
|
# File 'lib/serverspec/commands/aix.rb', line 39
def check_gid(group, gid)
regexp = "^#{group}"
"cat etc/group | grep -w -- #{escape(regexp)} | cut -f 3 -d ':' | grep -w -- #{escape(gid)}"
end
|
#check_grouped(file, group) ⇒ Object
61
62
63
64
|
# File 'lib/serverspec/commands/aix.rb', line 61
def check_grouped(file, group)
regexp = "^#{group}$"
"ls -al #{escape(file)} | awk '{print $4}' | grep -- #{escape(regexp)}"
end
|
#check_home_directory(user, path_to_home) ⇒ Object
48
49
50
|
# File 'lib/serverspec/commands/aix.rb', line 48
def check_home_directory(user, path_to_home)
"lsuser -a home #{escape(user)} | awk -F'=' '{print $2}' | grep -w -- #{escape(path_to_home)}"
end
|
#check_installed(package, version) ⇒ Object
20
21
22
23
24
25
26
27
|
# File 'lib/serverspec/commands/aix.rb', line 20
def check_installed(package,version)
if version
"lslpp -L #{escape(package)} | awk '{print $2}' | grep -w -- #{version}"
else
"lslpp -L #{escape(package)}"
end
end
|
#check_listening(port) ⇒ Object
29
30
31
32
33
|
# File 'lib/serverspec/commands/aix.rb', line 29
def check_listening(port)
regexp = "*.#{port} "
"netstat -an -f inet | awk '{print $4}' | grep -- #{regexp}"
end
|
#check_login_shell(user, path_to_shell) ⇒ Object
44
45
46
|
# File 'lib/serverspec/commands/aix.rb', line 44
def check_login_shell(user, path_to_shell)
"lsuser -a shell #{escape(user)} |awk -F'=' '{print $2}' | grep -w -- #{escape(path_to_shell)}"
end
|
#check_mode(file, mode) ⇒ Object
52
53
54
|
# File 'lib/serverspec/commands/aix.rb', line 52
def check_mode(file, mode)
false unless sprintf("%o",File.stat(file).mode).slice!(3,3) == mode
end
|
#check_owner(file, owner) ⇒ Object
56
57
58
59
|
# File 'lib/serverspec/commands/aix.rb', line 56
def check_owner(file, owner)
regexp = "^#{owner}$"
"ls -al #{escape(file)} | awk '{print $3}' | grep -- #{escape(regexp)}"
end
|
#check_running(service) ⇒ Object
16
17
18
|
# File 'lib/serverspec/commands/aix.rb', line 16
def check_running(service)
"ps -ef | grep -v grep | grep #{escape(service)}"
end
|