module Spior::Persist

Public Instance Methods

enable() click to toggle source
# File lib/spior/persist.rb, line 8
def enable
  case Nomansland::distro?
  when :gentoo
    for_gentoo
  else
    Msg.p "Your distro is not yet supported."
  end
end

Private Instance Methods

for_gentoo() click to toggle source
# File lib/spior/persist.rb, line 19
def for_gentoo
  if TTY::Which.exist?('systemctl')
    systemd_start("iptables-store")
    systemd_enable("iptables-restore")
    systemd_enable("tor")
  else
    system("sudo /etc/init.d/iptables save")
    rc_upd = Helpers::Exec.new("rc-update")
    rc_upd.run("rc-update add iptables boot")
    rc_upd.run("rc-update add tor")
    rc_upd.run("rc-update add tor default")
  end
end
systemd_enable(service) click to toggle source
# File lib/spior/persist.rb, line 33
def systemd_enable(service)
  systemctl = Helpers::Exec.new("systemctl")
  Msg.p "Search for service #{service}..."
  `systemctl is-enabled #{service}`
  if not $?.success? then
    systemctl.run("enable #{service}")
  end
end
systemd_start(service) click to toggle source
# File lib/spior/persist.rb, line 42
def systemd_start(service)
  systemctl = Helpers::Exec.new("systemctl")
  Msg.p "Search for service #{service}..."
  `systemctl is-active #{service}`
  if not $?.success? then
    systemctl.run("start #{service}")
  end
end