Class: Invoker::Power::Distro::Base
- Inherits:
-
Object
- Object
- Invoker::Power::Distro::Base
show all
- Defined in:
- lib/invoker/power/setup/distro/base.rb
Constant Summary
collapse
- SOCAT_SHELLSCRIPT =
"/usr/bin/invoker_forwarder.sh"
- SOCAT_SYSTEMD =
"/etc/systemd/system/socat_invoker.service"
- RESOLVER_DIR =
"/etc/dnsmasq.d"
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(tld) ⇒ Base
Returns a new instance of Base.
46
47
48
|
# File 'lib/invoker/power/setup/distro/base.rb', line 46
def initialize(tld)
self.tld = tld
end
|
Instance Attribute Details
#tld ⇒ Object
Returns the value of attribute tld.
8
9
10
|
# File 'lib/invoker/power/setup/distro/base.rb', line 8
def tld
@tld
end
|
Class Method Details
.distro ⇒ Object
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/invoker/power/setup/distro/base.rb', line 35
def self.distro
@distro ||= if File.exist?('/etc/os-release')
File.read('/etc/os-release').each_line do |line|
parsed_line = line.chomp.tr('"', '').split('=')
break parsed_line[1] if parsed_line[0] == 'NAME'
end
else
raise "File /etc/os-release doesn't exist or not Linux"
end
end
|
.distro_installer(tld) ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/invoker/power/setup/distro/base.rb', line 14
def self.distro_installer(tld)
if distro.start_with? "Arch Linux", "Manjaro Linux"
require "invoker/power/setup/distro/arch"
Arch.new(tld)
elsif distro.start_with? "Debian"
require "invoker/power/setup/distro/debian"
Debian.new(tld)
elsif distro.start_with? "Fedora"
require "invoker/power/setup/distro/redhat"
Redhat.new(tld)
elsif distro.start_with? "Linux Mint", "Ubuntu"
require "invoker/power/setup/distro/ubuntu"
Ubuntu.new(tld)
elsif distro.start_with? "openSUSE"
require "invoker/power/setup/distro/opensuse"
Opensuse.new(tld)
else
raise "Your selected distro is not supported by Invoker"
end
end
|
Instance Method Details
#get_user_confirmation? ⇒ Boolean
70
71
72
73
74
75
76
|
# File 'lib/invoker/power/setup/distro/base.rb', line 70
def get_user_confirmation?
Invoker::Logger.puts("Invoker is going to install #{install_packages} on this machine."\
" It is also going to install#{install_other} a socat service"\
" which will forward all local requests on port 80 and 443 to another port")
Invoker::Logger.puts("If you still want to proceed with installation, press y.")
Invoker::CLI::Question.agree("Proceed with installation (y/n) : ")
end
|
#install_other ⇒ Object
66
67
68
|
# File 'lib/invoker/power/setup/distro/base.rb', line 66
def install_other
" a local resolver for .#{tld} domain and"
end
|
#install_packages ⇒ Object
62
63
64
|
# File 'lib/invoker/power/setup/distro/base.rb', line 62
def install_packages
"dnsmasq and socat"
end
|
#install_required_software ⇒ Object
Install required software
51
52
53
|
# File 'lib/invoker/power/setup/distro/base.rb', line 51
def install_required_software
raise "Unimplemented"
end
|
#resolver_file ⇒ Object
10
11
12
|
# File 'lib/invoker/power/setup/distro/base.rb', line 10
def resolver_file
File.join(RESOLVER_DIR, "#{tld}-tld")
end
|
#restart_services ⇒ Object
55
56
57
58
59
60
|
# File 'lib/invoker/power/setup/distro/base.rb', line 55
def restart_services
system("systemctl enable socat_invoker.service")
system("systemctl enable dnsmasq")
system("systemctl start socat_invoker.service")
system("systemctl restart dnsmasq")
end
|