amnesie 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b826ad698129628f09059fb95e85e661982d473377e1d8721155da1f4aaa0f6c
4
- data.tar.gz: 13c076ddfb5ffa659d320724238382cfecd6c3dca6cd96c1a04afa49fbec6248
3
+ metadata.gz: 7406851da95a1f380d2ad273a5386ecaf28fd6695347b5891d5dcba27bef4f81
4
+ data.tar.gz: e8ebf031381c63faa622524cca82164ea738efadcabdb88adea7b9aef0e702ec
5
5
  SHA512:
6
- metadata.gz: ebd14700e11fa9b919df3c22f1f13a520b7c1d71f916b8d597a9e3a4ca8923b604795326674d43d83a6a2e96ff6181ab96c2b1410f67e9f823b628b27806cbd4
7
- data.tar.gz: dec9e3c4c51e4444d1d448bb88357f55f6499672868813be1d3c70be1021ffcf6416ce95794887e737c346a9e062bcbbac9bc49f35744dcaa0ff80c056c811c6
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
@@ -1,3 +1,6 @@
1
+ ## 0.0.3, release 2020-05-15
2
+ * Add stuff for kill and reload dhclient (tested on debian 10)
3
+
1
4
  ## 0.0.2, release 2020-05-15
2
5
  * Rakefile, add rake as dev dependencie
3
6
  * Check if process/program exist before kill/restart
data/amnesie.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "amnesie"
3
- s.version = "0.0.2"
3
+ s.version = "0.0.3"
4
4
  s.summary = "A tool to make your computer amnesic"
5
5
  s.description = <<-EOF
6
6
  A tool to make your computer amnesic"
@@ -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
- @pkill.run("dhcpcd")
28
+ `pgrep -x dhcpcd`
29
+ @pkill.run("dhcpcd") if $?.success?
15
30
  puts "Killed dhcpcd"
16
31
  end
17
32
 
18
- def restart
19
- return if not TTY::Which.exist?('systemctl')
20
- @procs.each do |p|
21
- if TTY::Which.exist?(p)
22
- @systemctl.run("restart #{p}")
23
- puts "Restarted #{p}"
24
- end
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
@@ -16,7 +16,7 @@ module Amnesie
16
16
  @network = Amnesie::Network.new(@options.netcard)
17
17
  end
18
18
  puts @network.card
19
- process = Amnesie::Process.new
19
+ process = Amnesie::Process.new(@network.card)
20
20
  card = Amnesie::MAC.new(@network.card)
21
21
 
22
22
  process.kill
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: amnesie
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - szorfein
metadata.gz.sig CHANGED
Binary file