Class: Amnesie::Persist::Systemd

Inherits:
Object
  • Object
show all
Defined in:
lib/amnesie/persist/systemd.rb

Instance Method Summary collapse

Constructor Details

#initialize(card = nil) ⇒ Systemd

Returns a new instance of Systemd.



4
5
6
7
8
# 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

Instance Method Details

#mac_exist?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/amnesie/persist/systemd.rb', line 10

def mac_exist?
  File.exist? "#{@systemd_dir}/[email protected]"
end


34
35
36
37
38
39
40
41
42
43
# File 'lib/amnesie/persist/systemd.rb', line 34

def menu_mac
  print "Action on [email protected] for #{@card} (enable/disable) ? (e/d) "
  answer = gets.chomp
  case answer
  when /^e|^E/
    mac_enable
  when /^d|^D/
    mac_disable
  end
end

#servicesObject



18
19
20
21
22
23
# File 'lib/amnesie/persist/systemd.rb', line 18

def services
  mac_service
  new_service = Helpers::NewSystemd.new(@string, "[email protected]")
  new_service.add
  new_service.perm("root", "644")
end

#to_sObject



14
15
16
# File 'lib/amnesie/persist/systemd.rb', line 14

def to_s
  @systemd_dir
end

#update_macObject



25
26
27
28
29
30
31
32
# File 'lib/amnesie/persist/systemd.rb', line 25

def update_mac
  print "Found a old [email protected], update? (y|n) "
  answer = gets.chomp
  case answer
  when /^y|^Y/
    services
  end
end