amnesie 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/CHANGELOG.md +3 -0
- data/amnesie.gemspec +1 -1
- data/lib/amnesie/process.rb +52 -10
- data/lib/amnesie/runner.rb +1 -1
- metadata +1 -1
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7406851da95a1f380d2ad273a5386ecaf28fd6695347b5891d5dcba27bef4f81
|
4
|
+
data.tar.gz: e8ebf031381c63faa622524cca82164ea738efadcabdb88adea7b9aef0e702ec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb59d06668aca29674020a415570dfee42df193facddc1b8dde571ffcf2ea24731dd359ea5e2624b6441956d159b3be0bc81363e73ef814fb6faa0e852f698dc
|
7
|
+
data.tar.gz: 914d52375535c0bdb3e0e5861e646d13d1b18e891d7c3e5e17018b94aa4fc5f9a07852efde1b940db7433b8c2be06118930fd4f43a12e35d76a30ecc3ba2123f
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/CHANGELOG.md
CHANGED
data/amnesie.gemspec
CHANGED
data/lib/amnesie/process.rb
CHANGED
@@ -3,25 +3,67 @@ require_relative 'helpers'
|
|
3
3
|
|
4
4
|
module Amnesie
|
5
5
|
class Process
|
6
|
-
def initialize
|
7
|
-
@procs = [ "dhcpcd", "tor" ]
|
6
|
+
def initialize(card)
|
8
7
|
@systemctl = Helpers::Exec.new("systemctl")
|
9
8
|
@pkill = Helpers::Exec.new("pkill")
|
9
|
+
@rm = Helpers::Exec.new("rm")
|
10
|
+
@card = card
|
10
11
|
end
|
11
12
|
|
12
13
|
def kill
|
14
|
+
kill_dhcpcd
|
15
|
+
kill_dhclient
|
16
|
+
end
|
17
|
+
|
18
|
+
def restart
|
19
|
+
restart_dhcpcd
|
20
|
+
restart_dhclient
|
21
|
+
restart_tor
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def kill_dhcpcd
|
13
27
|
return if not TTY::Which.exist?('dhcpcd')
|
14
|
-
|
28
|
+
`pgrep -x dhcpcd`
|
29
|
+
@pkill.run("dhcpcd") if $?.success?
|
15
30
|
puts "Killed dhcpcd"
|
16
31
|
end
|
17
32
|
|
18
|
-
def
|
19
|
-
return if not TTY::Which.exist?('
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
33
|
+
def kill_dhclient
|
34
|
+
return if not TTY::Which.exist?('dhclient')
|
35
|
+
`pgrep -x dhclient`
|
36
|
+
@pkill.run("dhclient") if $?.success?
|
37
|
+
@rm.run("/run/dhclient.#{@card}.pid") if File.exist? "/run/dhclient.#{@card}.pid"
|
38
|
+
@rm.run("/var/lib/dhcp/dhclient.#{@card}.leases") if File.exist? "/var/lib/dhcp/dhclient.#{@card}.leases"
|
39
|
+
puts "Killed dhclient"
|
40
|
+
end
|
41
|
+
|
42
|
+
def restart_dhcpcd
|
43
|
+
return if not TTY::Which.exist?('dhcpcd')
|
44
|
+
if TTY::Which.exist?('systemctl')
|
45
|
+
@systemctl.run("restart dhcpcd")
|
46
|
+
else
|
47
|
+
dhcpcd = Helpers::Exec.new("dhcpcd")
|
48
|
+
dhcpcd.run("-q")
|
49
|
+
end
|
50
|
+
puts "Restarted dhcpcd"
|
51
|
+
end
|
52
|
+
|
53
|
+
def restart_dhclient
|
54
|
+
return if not TTY::Which.exist?('dhclient')
|
55
|
+
dhclient = Helpers::Exec.new("dhclient")
|
56
|
+
# command tested on debian, not try on another system yet...
|
57
|
+
dhclient.run("-4 -v -i -pf /run/dhclient.#{@card}.pid -lf /var/lib/dhcp/dhclient.#{@card}.leases -I -df /var/lib/dhcp/dhclient6.#{@card}.leases #{@card}")
|
58
|
+
puts "Restarted dhclient"
|
59
|
+
end
|
60
|
+
|
61
|
+
def restart_tor
|
62
|
+
return if not TTY::Which.exist?('tor')
|
63
|
+
if TTY::Which.exist?('systemctl')
|
64
|
+
`systemctl is-active tor`
|
65
|
+
@systemctl.run("restart tor") if $?.success?
|
66
|
+
puts "Restarted tor"
|
25
67
|
end
|
26
68
|
end
|
27
69
|
end
|
data/lib/amnesie/runner.rb
CHANGED
metadata
CHANGED
metadata.gz.sig
CHANGED
Binary file
|