From 5cd74fe56eda588402ec20f351674a011fb4889d Mon Sep 17 00:00:00 2001 From: Brian Cunnie Date: Wed, 31 Aug 2016 20:39:21 -0700 Subject: [PATCH] check-dns.rb has 2 checks, better than none. --- ci/tasks/check-dns.rb | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/ci/tasks/check-dns.rb b/ci/tasks/check-dns.rb index 49ffd26..a711bff 100755 --- a/ci/tasks/check-dns.rb +++ b/ci/tasks/check-dns.rb @@ -1 +1,23 @@ #!/usr/bin/env ruby + +domain=ENV['DOMAIN'] + +def check_domain(domain) + raise "'DOMAIN' environment variable not set!" if domain.nil? + raise "'DOMAIN' environment variable is empty string!" if domain == "" +end + +def get_whois_nameservers(domain) + whois_output = `whois #{domain}` + whois_lines = whois_output.split(/\n+/) + nameserver_lines = whois_lines.select { |line| line =~ /^NS/ } + nameservers = nameserver_lines.map { |line| line.split.last } + raise "#{domain}'s whois entry has no name servers" unless nameservers.length > 0 + nameservers +end + +check_domain(domain) +puts "[PASS] #{domain} basic check ('DOMAIN' variable set & not empty)" + +whois_nameservers = get_whois_nameservers(domain) +puts "[PASS] #{domain} has whois entry with nameservers"