Module: Masquito::Install

Defined in:
lib/masquito/install.rb

Class Method Summary collapse

Class Method Details

.daemon_installObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/masquito/install.rb', line 17

def daemon_install
  abort_if_superuser
  FileUtils.mkdir_p(CONFIG_PATH)

  plist = ERB.new(File.read(TEMPLATE_PLIST_PATH))
  masquito_bin = File.join(GEM_PATH, 'bin', 'masquito')
  template = plist.result(binding)

  filename = File.join(Dir.tmpdir, PLIST_NAME)
  File.open(filename, 'w') { |f| f.write(template) }
  lunchy.install([filename])
  lunchy.start([SERVICE_NAME])
  File.unlink(filename)

  puts 'Daemon was successfully installed.'
  puts 'Run: sudo masquito resolver install'
end

.daemon_uninstallObject



35
36
37
38
39
40
# File 'lib/masquito/install.rb', line 35

def daemon_uninstall
  abort_if_superuser
  lunchy.stop([SERVICE_NAME])
  lunchy.uninstall([PLIST_NAME])
  puts "You can remove #{CONFIG_PATH} if you don't need these settings"
end

.resolver_installObject



42
43
44
45
46
47
# File 'lib/masquito/install.rb', line 42

def resolver_install
  abort_unless_superuser
  resolver = ERB.new(File.read(RESOLVER_TEMPLATE_PATH))
  template = resolver.result(binding)
  File.open(RESOLVER_PATH, 'w') { |f| f.write(template) }
end

.resolver_uninstallObject



49
50
51
52
# File 'lib/masquito/install.rb', line 49

def resolver_uninstall
  abort_unless_superuser
  FileUtils.rm_rf(RESOLVER_PATH)
end