Module: DevDNSd::OSX
- Included in:
- Application
- Defined in:
- lib/devdnsd/osx.rb
Overview
OSX management methods.
Instance Method Summary (collapse)
-
- (Boolean) action_add(options)
Adds aliases to an interface.
-
- (Boolean) action_install
Installs the application into the autolaunch.
-
- (Boolean) action_remove(options)
Removes aliases from an interface.
-
- (Boolean) action_uninstall
Uninstalls the application from the autolaunch.
-
- (Boolean) dns_update
Updates DNS cache.
-
- (Boolean) execute_command(command)
Executes a shell command.
-
- (String) launch_agent_path(name = "it.cowtech.devdnsd")
Gets the path for the launch agent file.
-
- (Boolean) osx?
(also: #is_osx?)
Checks if we are running on MacOS X.
-
- (String) resolver_path(tld = nil)
Gets the path for the resolver file.
Instance Method Details
- (Boolean) action_add(options)
Adds aliases to an interface.
64 65 66 |
# File 'lib/devdnsd/osx.rb', line 64 def action_add() manage_aliases(:add, i18n.add_empty, ) end |
- (Boolean) action_install
Installs the application into the autolaunch.
79 80 81 |
# File 'lib/devdnsd/osx.rb', line 79 def action_install manage_installation(launch_agent_path, resolver_path, :create_resolver, :create_agent, :load_agent) end |
- (Boolean) action_remove(options)
Removes aliases from an interface.
72 73 74 |
# File 'lib/devdnsd/osx.rb', line 72 def action_remove() manage_aliases(:remove, i18n.remove_empty, ) end |
- (Boolean) action_uninstall
Uninstalls the application from the autolaunch.
86 87 88 |
# File 'lib/devdnsd/osx.rb', line 86 def action_uninstall manage_installation(launch_agent_path, resolver_path, :delete_resolver, :unload_agent, :delete_agent) end |
- (Boolean) dns_update
Updates DNS cache.
37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/devdnsd/osx.rb', line 37 def dns_update @logger.info(i18n.dns_update) script = Tempfile.new("devdnsd-dns-cache-script") script.write("dscacheutil -flushcache 2>&1 > /dev/null\n") script.write("killall -9 mDNSResponder 2>&1 > /dev/null\n") script.write("killall -9 mDNSResponderHelper 2>&1 > /dev/null\n") script.close Kernel.system("/usr/bin/osascript -e 'do shell script \"sh #{script.path}\" with administrator privileges' 2>&1 > /dev/null") script.unlink end |
- (Boolean) execute_command(command)
Executes a shell command.
30 31 32 |
# File 'lib/devdnsd/osx.rb', line 30 def execute_command(command) system("#{command} 2>&1 > /dev/null") end |
- (String) launch_agent_path(name = "it.cowtech.devdnsd")
Gets the path for the launch agent file.
22 23 24 |
# File 'lib/devdnsd/osx.rb', line 22 def launch_agent_path(name = "it.cowtech.devdnsd") ENV["HOME"] + "/Library/LaunchAgents/#{name}.plist" end |
- (Boolean) osx? Also known as: is_osx?
Checks if we are running on MacOS X.
System services are only available on that platform.
55 56 57 |
# File 'lib/devdnsd/osx.rb', line 55 def osx? ::RbConfig::CONFIG['host_os'] =~ /^darwin/ end |
- (String) resolver_path(tld = nil)
Gets the path for the resolver file.
13 14 15 16 |
# File 'lib/devdnsd/osx.rb', line 13 def resolver_path(tld = nil) tld ||= @config.tld "/etc/resolver/#{tld}" end |