dynx 0.1b

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +7 -0
  2. data/bin/dynx +11 -0
  3. data/bin/dynx-start +59 -0
  4. data/bin/dynx-stop +9 -0
  5. metadata +48 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2440172df450a6161a8d5bfa326c408f3d379854
4
+ data.tar.gz: 392029d682b9f306ddabc7fa7d374f0c6eccb0bc
5
+ SHA512:
6
+ metadata.gz: 45c267a8d43767579efabbc8559b70737ced12a388bd5071c5afa6d6585bdafff0a148c218f0c2f8f1294636fc8aeb22d587d9e484fcc411a54c93f0b3e8373d
7
+ data.tar.gz: 3810ef0a0e7c3369d8492d7a8178c6054e2eb01cc6fe50c2c0e7e1a8d9d5e2755fd0734f944b5ea550733a56de8be3a25363dc2da30e9df37fd0bbd90294207b
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/ruby
2
+
3
+ command = ARGV.join(" ")
4
+ File.exists?("/tmp/dynx/.lock")||(puts("No dynx host process runnning");exit(1))
5
+ File.write("/tmp/dynx/dynx-in",command)
6
+ loop do
7
+ c = File.read("/tmp/dynx/dynx-out").chomp
8
+ c.split("\n").each do |l|
9
+ l=="__END_OF_REQUEST__" ? exit : puts(l)
10
+ end
11
+ end
@@ -0,0 +1,59 @@
1
+ #!/usr/bin/ruby
2
+
3
+ require 'fileutils'
4
+ require 'open3'
5
+
6
+ $USER = ENV["HOME"].split("/")[-1]
7
+
8
+ def setup
9
+ Dir.mkdir("/tmp/dynx")
10
+ currdir = Dir.pwd
11
+ Dir.chdir("/tmp/dynx")
12
+ File.mkfifo("dynx-in")
13
+ File.mkfifo("dynx-out")
14
+ File.write(".lock",$USER)
15
+ for f in %w/dynx-in dynx-out .lock/
16
+ File.chmod(0666,f)
17
+ end
18
+ Dir.chdir(currdir)
19
+ end
20
+
21
+ if Dir.exist?("/tmp/dynx")
22
+ if File.exists?("/tmp/dynx/.lock")&&File.read("/tmp/dynx/.lock").chomp==$USER
23
+ puts "A dynx service is already running for `#{$USER}`"
24
+ exit 0
25
+ elsif File.exists?("/tmp/dynx/.lock")&&File.read("/tmp/dynx/.lock").chomp!=$USER
26
+ puts "A dynx service is already running for `#{File.read("/tmp/dynx/.lock").chomp}`."
27
+ puts "Please first stop the service for this user."
28
+ exit 0
29
+ end
30
+ else
31
+ setup
32
+ end
33
+
34
+ fork do
35
+ Dir.chdir("/tmp/dynx");mydir=Dir.pwd
36
+ loop do
37
+ instr_arr = File.read("dynx-in").split("\n")
38
+ instr_arr.each do |instr|
39
+ case instr # to check for commands
40
+ when "DYNX_KILL"
41
+ File.write("dynx-out","Terminating dynx...")
42
+ File.delete(".lock") rescue nil
43
+ File.write("dynx-out","__EOF__")
44
+ exit 0
45
+ else
46
+ begin
47
+ out = Open3.capture3(instr)
48
+ rescue Errno::ENOENT => e
49
+ File.write("dynx-out","#{e.class}: #{e.message}")
50
+ else
51
+ out[0]!="" ? File.write("dynx-out",out[0]) : File.write("dynx-out",out[1])
52
+ end
53
+ end
54
+ end
55
+ File.write("dynx-out","__END_OF_REQUEST__")
56
+ end
57
+ end
58
+
59
+ puts "Started dynx service on this system as user `#{$USER}`"
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/ruby
2
+
3
+ File.write("/tmp/dynx/dynx-in","DYNX_KILL") rescue (puts "Error: Pipe was not found.";exit(1))
4
+ loop do
5
+ cont = File.read("/tmp/dynx/dynx-out").split("\n")
6
+ for l in cont
7
+ l=="__EOF__" ? exit : puts(l)
8
+ end
9
+ end
metadata ADDED
@@ -0,0 +1,48 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dynx
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1b
5
+ platform: ruby
6
+ authors:
7
+ - sesshomariu
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-01-24 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Execute a command on a Unix user account while being logged into another
14
+ email:
15
+ executables:
16
+ - dynx
17
+ - dynx-start
18
+ - dynx-stop
19
+ extensions: []
20
+ extra_rdoc_files: []
21
+ files:
22
+ - bin/dynx
23
+ - bin/dynx-start
24
+ - bin/dynx-stop
25
+ homepage:
26
+ licenses: []
27
+ metadata: {}
28
+ post_install_message:
29
+ rdoc_options: []
30
+ require_paths:
31
+ - lib
32
+ required_ruby_version: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: '0'
37
+ required_rubygems_version: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">"
40
+ - !ruby/object:Gem::Version
41
+ version: 1.3.1
42
+ requirements: []
43
+ rubyforge_project:
44
+ rubygems_version: 2.6.8
45
+ signing_key:
46
+ specification_version: 4
47
+ summary: dynx
48
+ test_files: []