srv2env 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/srv2env.rb +31 -0
  3. metadata +48 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f9ee6ea032e8d802d5bdfca43001377255d1b23b
4
+ data.tar.gz: e1f7845d4c8fbc457407aa6f5d2afc02018fc0b6
5
+ SHA512:
6
+ metadata.gz: cdd92f7d28b13b935f3b9d41ec3fcfff8f885febb679457da67d7afe97c76669be2f99744916f93252b1a4ea2546756f16b169a82d963de1e91383f9e72d854a
7
+ data.tar.gz: 46be3b1b83d6dd378c62d4718061bfa8b46217855267ac5355f7aab50224844ab371839a024545a39de4c3f7828f2d47cbbb0362aff3415f6d587ae05100a883
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # Author: Mateusz Pawlowski <js@yllq.net>
4
+ # License : GPLv2
5
+ #
6
+
7
+ require 'resolv'
8
+
9
+ r = Resolv::DNS.new
10
+ domain=ARGV[0]
11
+ unless domain
12
+ STDERR.puts "Please specify domain as an argument"
13
+ exit 1
14
+ end
15
+ service= domain.split('.').first.gsub("-",'_')
16
+
17
+ resp = r.getresources(domain, Resolv::DNS::Resource::IN::SRV)
18
+
19
+ if resp.empty?
20
+ STDERR.puts "No Resources for #{domain} found"
21
+ exit 1
22
+ end
23
+
24
+ resp.sort_by! { |e| [e.priority, e.weight] }
25
+
26
+ resp.each_index do |index|
27
+ puts "export #{service.upcase}_HOST_#{index}='#{resp[index].target}'"
28
+ puts "export #{service.upcase}_PORT_#{index}='#{resp[index].port}'"
29
+ puts "export #{service.upcase}_PRIORITY_#{index}='#{resp[index].priority}'"
30
+ puts "export #{service.upcase}_WEIGHT_#{index}='#{resp[index].weight}'"
31
+ end
metadata ADDED
@@ -0,0 +1,48 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: srv2env
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Mateusz Pawlowski
8
+ autorequire:
9
+ bindir: "."
10
+ cert_chain: []
11
+ date: 2015-03-26 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: |-
14
+ Allows to export records from DNS SRV to environment variables
15
+ Usage: `srv2env.rb _myservice._protocol.example.com`
16
+ email: js@yllq.net
17
+ executables:
18
+ - srv2env.rb
19
+ extensions: []
20
+ extra_rdoc_files: []
21
+ files:
22
+ - "./srv2env.rb"
23
+ - srv2env.rb
24
+ homepage: https://bitbucket.org/generik/srv2env
25
+ licenses:
26
+ - GPL-2
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: '0'
42
+ requirements: []
43
+ rubyforge_project:
44
+ rubygems_version: 2.2.2
45
+ signing_key:
46
+ specification_version: 4
47
+ summary: DNS SRV to environment variable translator
48
+ test_files: []