Module: DevDNSd::ApplicationMethods::System
- Extended by:
- ActiveSupport::Concern
- Included in:
- DevDNSd::Application
- Defined in:
- lib/devdnsd/application.rb
Overview
System management methods.
Defined Under Namespace
Modules: ClassMethods
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_start
Starts the server in background.
-
- (Boolean) action_stop
Stops the server in background.
-
- (Boolean) action_uninstall
Uninstalls the application from the autolaunch.
-
- (Boolean) dns_update
Updates DNS cache.
-
- (Boolean) execute_command(command)
Executes a shell command.
-
- (Boolean) is_osx?
Checks if we are running on MacOS X.
-
- (String) launch_agent_path(name = "it.cowtech.devdnsd")
Gets the path for the launch agent file.
-
- (String) resolver_path(tld = nil)
Gets the path for the resolver file.
Instance Method Details
- (Boolean) action_add(options)
Adds aliases to an interface.
110 111 112 |
# File 'lib/devdnsd/application.rb', line 110 def action_add() manage_aliases(:add, i18n.add_empty, ) end |
- (Boolean) action_install
Installs the application into the autolaunch.
126 127 128 |
# File 'lib/devdnsd/application.rb', line 126 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.
118 119 120 |
# File 'lib/devdnsd/application.rb', line 118 def action_remove() manage_aliases(:remove, i18n.remove_empty, ) end |
- (Boolean) action_start
Starts the server in background.
84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/devdnsd/application.rb', line 84 def action_start get_logger.info(i18n.starting) if !Process.respond_to?(:fork) then logger.warn(i18n.no_fork) @config.foreground = true elsif @command.[:foreground].value then @config.foreground = true end @config.foreground ? perform_server : RExec::Daemon::Controller.start(self.class) true end |
- (Boolean) action_stop
Stops the server in background.
101 102 103 104 |
# File 'lib/devdnsd/application.rb', line 101 def action_stop RExec::Daemon::Controller.stop(self.class) true end |
- (Boolean) action_uninstall
Uninstalls the application from the autolaunch.
133 134 135 |
# File 'lib/devdnsd/application.rb', line 133 def action_uninstall manage_installation(launch_agent_path, resolver_path, :delete_resolver, :unload_agent, :delete_agent) end |
- (Boolean) dns_update
Updates DNS cache.
67 68 69 70 |
# File 'lib/devdnsd/application.rb', line 67 def dns_update @logger.info(i18n.dns_update) execute_command("dscacheutil -flushcache") end |
- (Boolean) execute_command(command)
Executes a shell command.
60 61 62 |
# File 'lib/devdnsd/application.rb', line 60 def execute_command(command) system(command) end |
- (Boolean) is_osx?
Checks if we are running on MacOS X.
System services are only available on that platform.
77 78 79 |
# File 'lib/devdnsd/application.rb', line 77 def is_osx? ::RbConfig::CONFIG['host_os'] =~ /^darwin/ end |
- (String) launch_agent_path(name = "it.cowtech.devdnsd")
Gets the path for the launch agent file.
52 53 54 |
# File 'lib/devdnsd/application.rb', line 52 def launch_agent_path(name = "it.cowtech.devdnsd") ENV["HOME"] + "/Library/LaunchAgents/#{name}.plist" end |
- (String) resolver_path(tld = nil)
Gets the path for the resolver file.
43 44 45 46 |
# File 'lib/devdnsd/application.rb', line 43 def resolver_path(tld = nil) tld ||= @config.tld "/etc/resolver/#{tld}" end |