Class: DnsMasq
- Inherits:
-
Object
- Object
- DnsMasq
- Defined in:
- lib/brisk/dnsmasq.rb
Class Attribute Summary collapse
-
.config_path ⇒ Object
Returns the value of attribute config_path.
-
.dnsmasq_path ⇒ Object
Returns the value of attribute dnsmasq_path.
-
.example_config_path ⇒ Object
Returns the value of attribute example_config_path.
-
.resolver_path ⇒ Object
Returns the value of attribute resolver_path.
Class Method Summary collapse
- .create_custom_configuration(domain) ⇒ Object
- .create_resolver(domain) ⇒ Object
- .download ⇒ Object
- .install(domain = 'dev') ⇒ Object
- .is_installed? ⇒ Boolean
- .update_domain(domain, old_domain) ⇒ Object
Class Attribute Details
.config_path ⇒ Object
Returns the value of attribute config_path.
12 13 14 |
# File 'lib/brisk/dnsmasq.rb', line 12 def config_path @config_path end |
.dnsmasq_path ⇒ Object
Returns the value of attribute dnsmasq_path.
15 16 17 |
# File 'lib/brisk/dnsmasq.rb', line 15 def dnsmasq_path @dnsmasq_path end |
.example_config_path ⇒ Object
Returns the value of attribute example_config_path.
13 14 15 |
# File 'lib/brisk/dnsmasq.rb', line 13 def example_config_path @example_config_path end |
.resolver_path ⇒ Object
Returns the value of attribute resolver_path.
14 15 16 |
# File 'lib/brisk/dnsmasq.rb', line 14 def resolver_path @resolver_path end |
Class Method Details
.create_custom_configuration(domain) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/brisk/dnsmasq.rb', line 43 def self.create_custom_configuration(domain) unless FileSystem.file_exists?(config_path) FileSystem.copy_file(example_config_path,config_path) end if FileSystem.read(config_path).index(dnsmasq_path) == nil FileSystem.append(config_path, "conf-file=#{dnsmasq_path}") end FileSystem.write(dnsmasq_path, "address=/.#{domain}/127.0.0.1") end |
.create_resolver(domain) ⇒ Object
56 57 58 59 60 61 62 63 |
# File 'lib/brisk/dnsmasq.rb', line 56 def self.create_resolver(domain) unless FileSystem.dir_exists?(resolver_path) FileSystem.create_dir(resolver_path) end # File.write('etc/resolver/dev', 'nameserver 127.0.0.1') File.write("#{resolver_path}/#{domain}", "nameserver 127.0.0.1") end |
.download ⇒ Object
39 40 41 |
# File 'lib/brisk/dnsmasq.rb', line 39 def self.download system "sudo -u #{ENV['SUDO_USER']} brew install dnsmasq" end |
.install(domain = 'dev') ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/brisk/dnsmasq.rb', line 19 def self.install(domain = 'dev') unless is_installed? puts "Installing DnsMasq...".colorize(:green) download end create_custom_configuration(domain) create_resolver(domain) system "brew services restart dnsmasq > /dev/null" end |
.is_installed? ⇒ Boolean
33 34 35 36 37 |
# File 'lib/brisk/dnsmasq.rb', line 33 def self.is_installed? system "brew list | grep dnsmasq >> /dev/null" $? == 0 end |
.update_domain(domain, old_domain) ⇒ Object
65 66 67 68 69 |
# File 'lib/brisk/dnsmasq.rb', line 65 def self.update_domain(domain, old_domain) FileSystem.delete("#{resolver_path}/#{old_domain}") install(domain) end |