Class: SpecInfra::Command::Solaris10

Inherits:
Solaris show all
Defined in:
lib/specinfra/command/solaris10.rb

Instance Method Summary collapse

Methods inherited from Solaris

#check_access_by_user, #check_cron_entry, #check_enabled, #check_file_contain_within, #check_gid, #check_home_directory, #check_ipfilter_rule, #check_ipnat_rule, #check_listening, #check_listening_with_protocol, #check_login_shell, #check_running, #check_svcprop, #check_svcprops, #check_zfs

Methods inherited from Base

#check_access_by_user, #check_container, #check_cotainer_running, #check_cron_entry, #check_directory, #check_enabled, #check_file, #check_file_checksum, #check_file_contain_lines, #check_file_contain_with_fixed_strings, #check_file_contain_with_regexp, #check_file_contain_within, #check_file_sha256checksum, #check_gid, #check_home_directory, #check_installed_by_cpan, #check_installed_by_gem, #check_installed_by_npm, #check_installed_by_pear, #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_listening, #check_listening_with_protocol, #check_login_shell, #check_mail_alias, #check_monitored_by_god, #check_monitored_by_monit, #check_mounted, #check_process, #check_resolvable, #check_routing_table, #check_running, #check_running_under_supervisor, #check_running_under_upstart, #check_selinux, #check_service_installed, #check_service_start_mode, #check_socket, #check_svcprop, #check_svcprops, #check_uid, #check_user, #check_yumrepo, #check_yumrepo_enabled, #check_zfs, #escape, #get_file_content, #get_ipaddress_of_host, #get_package_version, #get_process

Instance Method Details

#check_authorized_key(user, key) ⇒ Object



71
72
73
74
# File 'lib/specinfra/command/solaris10.rb', line 71

def check_authorized_key(user, key)
  key.sub!(/\s+\S*$/, '') if key.match(/^\S+\s+\S+\s+\S*$/)
  "grep -- #{escape(key)} ~#{escape(user)}/.ssh/authorized_keys"
end

#check_belonging_group(user, group) ⇒ Object



67
68
69
# File 'lib/specinfra/command/solaris10.rb', line 67

def check_belonging_group(user, group)
  "id -ap #{escape(user)} | grep -- #{escape(group)}"
end

#check_file_contain(file, expected_pattern) ⇒ Object



41
42
43
# File 'lib/specinfra/command/solaris10.rb', line 41

def check_file_contain(file, expected_pattern)
  "grep -- #{escape(expected_pattern)} #{escape(file)}"
end

#check_file_md5checksum(file, expected) ⇒ Object



63
64
65
# File 'lib/specinfra/command/solaris10.rb', line 63

def check_file_md5checksum(file, expected)
  "digest -a md5 -v #{escape(file)} | grep -iw -- #{escape(expected)}"
end

#check_group(group) ⇒ Object



19
20
21
# File 'lib/specinfra/command/solaris10.rb', line 19

def check_group(group)
  "getent group | grep -w -- #{escape(group)}"
end

#check_grouped(file, group) ⇒ Object

reference: perldoc.perl.org/functions/stat.html

http://www.tutorialspoint.com/perl/perl_getgrgid.htm


25
26
27
28
# File 'lib/specinfra/command/solaris10.rb', line 25

def check_grouped(file, group)
  regexp = "^#{group}$"
  "perl -e 'printf \"%s\", getgrgid((stat(\"#{escape(file)}\"))[5])'  | grep -- #{escape(regexp)}"
end

#check_installed(package, version = nil) ⇒ Object



55
56
57
58
59
60
61
# File 'lib/specinfra/command/solaris10.rb', line 55

def check_installed(package, version=nil)
  cmd = "pkginfo -q  #{escape(package)}"
  if version
    cmd = "#{cmd} | grep -- #{escape(version)}"
  end
  cmd
end


31
32
33
34
# File 'lib/specinfra/command/solaris10.rb', line 31

def check_link(link, target)
  regexp = "^#{target}$"
  "perl -e 'printf \"%s\", readlink(\"#{escape(link)}\")' | grep -- #{escape(regexp)}"
end

#check_mode(file, mode) ⇒ Object



7
8
9
10
# File 'lib/specinfra/command/solaris10.rb', line 7

def check_mode(file, mode)
  regexp = "^#{mode}$"
  "perl -e 'printf \"%o\", (stat shift)[2]&07777' #{escape(file)}  | grep -- #{escape(regexp)}"
end

#check_owner(file, owner) ⇒ Object

reference: perldoc.perl.org/functions/stat.html

http://www.tutorialspoint.com/perl/perl_getpwuid.htm


14
15
16
17
# File 'lib/specinfra/command/solaris10.rb', line 14

def check_owner(file, owner)
  regexp = "^#{owner}$"
  "perl -e 'printf \"%s\", getpwuid((stat(\"#{escape(file)}\"))[4])' | grep -- #{escape(regexp)}"
end

#check_reachable(host, port, proto, timeout) ⇒ Object



45
46
47
48
49
50
51
52
53
# File 'lib/specinfra/command/solaris10.rb', line 45

def check_reachable(host, port, proto, timeout)
  if port.nil?
    "ping -n #{escape(host)} #{escape(timeout)}"
  elsif proto == 'tcp'
    "echo 'quit' | mconnect -p #{escape(port)} #{escape(host)} > /dev/null 2>&1"
  else
    raise NotImplementedError.new
  end
end

#get_mode(file) ⇒ Object



37
38
39
# File 'lib/specinfra/command/solaris10.rb', line 37

def get_mode(file)
  "perl -e 'printf \"%o\", (stat shift)[2]&07777' #{escape(file)}"
end