class Amnesie::Persist::Systemd
Public Class Methods
new(card = nil)
click to toggle source
# File lib/amnesie/persist/systemd.rb, line 4 def initialize(card = nil) @card = card @systemd_dir = search_systemd_dir @systemctl = Helpers::Exec.new("systemctl") end
Public Instance Methods
mac_exist?()
click to toggle source
# File lib/amnesie/persist/systemd.rb, line 10 def mac_exist? File.exist? "#{@systemd_dir}/amnesie-mac@.service" end
services()
click to toggle source
# File lib/amnesie/persist/systemd.rb, line 18 def services mac_service new_service = Helpers::NewSystemd.new(@string, "amnesie-mac@.service") new_service.add new_service.perm("root", "644") end
to_s()
click to toggle source
# File lib/amnesie/persist/systemd.rb, line 14 def to_s @systemd_dir end
update_mac()
click to toggle source
# File lib/amnesie/persist/systemd.rb, line 25 def update_mac print "Found a old amnesie-mac@.service, update? (y|n) " answer = gets.chomp case answer when /^y|^Y/ services end end
Private Instance Methods
mac_disable()
click to toggle source
# File lib/amnesie/persist/systemd.rb, line 51 def mac_disable @systemctl.run("disable amnesie-mac@#{@card}.service") end
mac_enable()
click to toggle source
# File lib/amnesie/persist/systemd.rb, line 47 def mac_enable @systemctl.run("enable amnesie-mac@#{@card}.service") end
mac_service()
click to toggle source
# File lib/amnesie/persist/systemd.rb, line 66 def mac_service dhcp = TTY::Which.exist?("dhcpcd") ? 'dhcpcd.service' : '' @string=<<EOF [Unit] Description=Spoof MAC Address on %I Wants=network-pre.target Before=network-pre.target #{dhcp} BindsTo=sys-subsystem-net-devices-%i.device After=sys-subsystem-net-devices-%i.device [Service] Type=oneshot ExecStart=/usr/bin/env bash -lc "amnesie -i -n %I" ExecReload=/usr/bin/env bash -lc "amnesie -m -n %I" TimeoutSec=30 [Install] WantedBy=multi-user.target EOF end
search_systemd_dir()
click to toggle source
# File lib/amnesie/persist/systemd.rb, line 55 def search_systemd_dir if Dir.exist? "/lib/systemd/system" "/lib/systemd/system" elsif Dir.exist? "/usr/lib/systemd/system" "/usr/lib/systemd/system" else raise "No directory systemd found" exit end end