lib/invoker/power/setup/linux_setup.rb in invoker-1.5.6 vs lib/invoker/power/setup/linux_setup.rb in invoker-1.5.7

- old
+ new

@@ -1,18 +1,17 @@ require "invoker/power/setup/distro/base" -require "facter" require 'erb' require 'fileutils' module Invoker module Power class LinuxSetup < Setup attr_accessor :distro_installer def setup_invoker - if get_user_confirmation? - initialize_distro_installer + initialize_distro_installer + if distro_installer.get_user_confirmation? find_open_ports distro_installer.install_required_software install_resolver install_port_forwarder distro_installer.restart_services @@ -33,10 +32,16 @@ remove_resolver_file drop_to_normal_user Invoker::Power::Config.delete end + def build_power_config + config = super + config[:tld] = distro_installer.tld + config + end + def resolver_file distro_installer.resolver_file end def forwarder_script @@ -48,20 +53,15 @@ end private def initialize_distro_installer - # Create a new facter check for systemctl (in systemd) - Facter.add(:systemctl) do - setcode do - Facter::Util::Resolution.exec("[ -e /usr/bin/systemctl ] && echo 'true' || echo 'false'") - end - end - @distro_installer = Invoker::Power::Distro::Base.distro_installer(tld) + @distro_installer ||= Invoker::Power::Distro::Base.distro_installer(tld) end def install_resolver + return if resolver_file.nil? File.open(resolver_file, "w") do |fl| fl.write(resolver_file_content) end end @@ -89,17 +89,9 @@ end def install_systemd_unit FileUtils.cp(socat_unit, Invoker::Power::Distro::Base::SOCAT_SYSTEMD) system("chmod 644 #{Invoker::Power::Distro::Base::SOCAT_SYSTEMD}") - end - - def get_user_confirmation? - Invoker::Logger.puts("Invoker is going to install dnsmasq and socat on this machine."\ - " It is also going to install a local resolver for .#{tld} domain and 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 end end end