Class: SpecInfra::Command::FreeBSD

Inherits:
Base
  • Object
show all
Defined in:
lib/specinfra/command/freebsd.rb

Direct Known Subclasses

FreeBSD10

Instance Method Summary collapse

Methods inherited from Base

#check_access_by_user, #check_authorized_key, #check_belonging_group, #check_container, #check_cotainer_running, #check_cron_entry, #check_directory, #check_file, #check_file_checksum, #check_file_contain, #check_file_contain_lines, #check_file_contain_with_fixed_strings, #check_file_contain_with_regexp, #check_file_contain_within, #check_file_md5checksum, #check_file_sha256checksum, #check_gid, #check_group, #check_grouped, #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_link, #check_listening_with_protocol, #check_login_shell, #check_mail_alias, #check_monitored_by_god, #check_monitored_by_monit, #check_mounted, #check_owner, #check_process, #check_reachable, #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_process

Instance Method Details

#check_enabled(service, level = 3) ⇒ Object



4
5
6
# File 'lib/specinfra/command/freebsd.rb', line 4

def check_enabled(service, level=3)
  "service -e | grep -- #{escape(service)}"
end

#check_installed(package, version = nil) ⇒ Object



8
9
10
11
12
13
14
# File 'lib/specinfra/command/freebsd.rb', line 8

def check_installed(package, version=nil)
  if version
    "pkg_info -I #{escape(package)}-#{escape(version)}"
  else
    "pkg_info -Ix #{escape(package)}"
  end
end

#check_listening(port) ⇒ Object



16
17
18
19
# File 'lib/specinfra/command/freebsd.rb', line 16

def check_listening(port)
  regexp = ":#{port} "
  "sockstat -46l -p #{port} | grep -- #{escape(regexp)}"
end

#check_mode(file, mode) ⇒ Object



21
22
23
24
# File 'lib/specinfra/command/freebsd.rb', line 21

def check_mode(file, mode)
  regexp = "^#{mode}$"
  "stat -f%Lp #{escape(file)} | grep -- #{escape(regexp)}"
end

#get_mode(file) ⇒ Object



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

def get_mode(file)
  "stat -f%Lp #{escape(file)}"
end

#get_package_version(package, opts = nil) ⇒ Object



34
35
36
# File 'lib/specinfra/command/freebsd.rb', line 34

def get_package_version(package, opts=nil)
  "pkg_info -Ix #{escape(package)} | cut -f 1 -w | sed -n 's/^#{escape(package)}-//p'"
end

#install(package) ⇒ Object



30
31
32
# File 'lib/specinfra/command/freebsd.rb', line 30

def install(package)
  "pkg_add -r install #{package}"
end