Module: Spior::Dep

Defined in:
lib/spior/dep.rb

Overview

Dep: install all dependencies for Spior

Class Method Summary collapse

Class Method Details

.install(cmd, package) ⇒ Object



38
39
40
# File 'lib/spior/dep.rb', line 38

def install(cmd, package)
  Helpers.cmd("#{cmd} #{package}")
end

.installing_deps(distro_cmd, names) ⇒ Object



31
32
33
34
35
36
# File 'lib/spior/dep.rb', line 31

def installing_deps(distro_cmd, names)
  names.map do |n|
    Msg.p "Search #{n}..."
    install(distro_cmd, n) unless search_dep(n)
  end
end

.lookingObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/spior/dep.rb', line 11

def looking
  case Nomansland.distro?
  when :archlinux
    installing_deps('pacman -S', %w[iptables tor])
  when :debian
    installing_deps('apt-get install', %w[iptables tor])
    use_iptables
  when :gentoo
    installing_deps('emerge -av', %w[iptables tor])
  when :void
    installing_deps('xbps-install -S', %w[iptables tor])
  when :fedora
    installing_deps('dnf install -y', %w[iptables tor])
  when :suse
    installing_deps('zypper install -y', %w[iptables tor])
  else
    Msg.report 'Install for your distro is not yet supported.'
  end
end

.search_dep(name) ⇒ Object



42
43
44
# File 'lib/spior/dep.rb', line 42

def search_dep(name)
  TTY::Which.exist?(name) ? true : false
end

.use_iptablesObject



47
48
49
50
51
52
# File 'lib/spior/dep.rb', line 47

def use_iptables
  Helpers.cmd('update-alternatives --set iptables /usr/sbin/iptables-legacy')
  Helpers.cmd('update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy')
  Helpers.cmd('update-alternatives --set arptables /usr/sbin/arptables-legacy')
  Helpers.cmd('update-alternatives --set ebtables /usr/sbin/ebtables-legacy')
end