hast 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +21 -0
- data/LICENSE +20 -0
- data/README.rdoc +61 -0
- data/Rakefile +37 -0
- data/VERSION +1 -0
- data/bin/hast +2 -0
- data/config.yml.example +58 -0
- data/hast.gemspec +74 -0
- data/lib/hast/apache.rb +60 -0
- data/lib/hast/postfix.rb +29 -0
- data/lib/hast/verifier.rb +72 -0
- data/lib/hast.rb +128 -0
- metadata +97 -0
data/.document
ADDED
data/.gitignore
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2010 Thomas Watson Steen
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
= HAST
|
2
|
+
|
3
|
+
HAST stands for 'Hosting Account Status Tool'.
|
4
|
+
|
5
|
+
HAST is a tool for fetching domains from Apache configuration files and
|
6
|
+
from the Postfix database on a hosting server environment. It will then
|
7
|
+
run a report, checking the DNS records for each domain to see if they
|
8
|
+
match your server.
|
9
|
+
|
10
|
+
This is important for finding "dead" domains where the domain either
|
11
|
+
doesn't exist anymore or where the owner have moved it to another
|
12
|
+
hosting provider.
|
13
|
+
|
14
|
+
Before you can use HAST, you need to setup a config.yml file. Use
|
15
|
+
config.yml.example as a template.
|
16
|
+
|
17
|
+
== Note on Patches/Pull Requests
|
18
|
+
|
19
|
+
* Fork the project.
|
20
|
+
* Make your feature addition or bug fix.
|
21
|
+
* Add tests for it. This is important so I don't break it in a future
|
22
|
+
version unintentionally.
|
23
|
+
* Commit, do not mess with rakefile, version, or history.
|
24
|
+
(if you want to have your own version, that is fine but bump version
|
25
|
+
in a commit by itself I can ignore when I pull)
|
26
|
+
* Send me a pull request. Bonus points for topic branches.
|
27
|
+
|
28
|
+
== Usage
|
29
|
+
|
30
|
+
hast config-file [options]
|
31
|
+
|
32
|
+
For help use: hast -h
|
33
|
+
|
34
|
+
=== Options
|
35
|
+
|
36
|
+
-h, --help Displays help message
|
37
|
+
-v, --version Display version
|
38
|
+
-g, --generate-config Output a config file template (pipe it to a
|
39
|
+
file for easy use: hast -g > config.yml)
|
40
|
+
-q, --no-dns Do not lookup any domain names or MX records
|
41
|
+
-y, --yaml Output as YAML (usefull if you want to pipe:
|
42
|
+
bau.rb > domains.yml)
|
43
|
+
-c, --domain-cache FILE Get the domains from a YAML file
|
44
|
+
|
45
|
+
=== Examples
|
46
|
+
|
47
|
+
Generate a human-readable report:
|
48
|
+
hast config.yml
|
49
|
+
|
50
|
+
Do not perfom DNS lookups:
|
51
|
+
hast config.yml -q
|
52
|
+
|
53
|
+
Do not perfom DNS lookups and genereate a YAML file with the result:
|
54
|
+
hast config.yml -yq > domains.yml
|
55
|
+
|
56
|
+
Load the domains to check from a YAML file:
|
57
|
+
hast config.yml -c domains.yml
|
58
|
+
|
59
|
+
== Copyright
|
60
|
+
|
61
|
+
Copyright (c) 2010 Thomas Watson Steen. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "hast"
|
8
|
+
gem.summary = %Q{Hosting Account Status Tool - Fetch domains from Apache configuration files and the Postfix database on a hosting server environment. Then run a report checking each domains DNS records to see if they match your server.}
|
9
|
+
gem.description = <<-EOF
|
10
|
+
HAST stands for 'Hosting Account Status Tool'.
|
11
|
+
|
12
|
+
HAST is a tool for fetching domains from Apache configuration files and
|
13
|
+
from the Postfix database on a hosting server environment. It will then
|
14
|
+
run a report, checking the DNS records for each domain to see if they
|
15
|
+
match your server.
|
16
|
+
|
17
|
+
This is important for finding "dead" domains where the domain either
|
18
|
+
doesn't exist anymore or where the owner have moved it to another
|
19
|
+
hosting provider.
|
20
|
+
|
21
|
+
Before you can use HAST, you need to setup a config.yml file. Use
|
22
|
+
config.yml.example as a template.
|
23
|
+
EOF
|
24
|
+
gem.email = "w@tson.dk"
|
25
|
+
gem.homepage = "http://github.com/watson/hast"
|
26
|
+
gem.authors = ["Thomas Watson Steen"]
|
27
|
+
gem.add_development_dependency "mysql", ">= 0"
|
28
|
+
gem.add_development_dependency "net-dns", ">= 0"
|
29
|
+
gem.add_development_dependency "deep_merge", ">= 0.1.0"
|
30
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
31
|
+
end
|
32
|
+
Jeweler::GemcutterTasks.new
|
33
|
+
rescue LoadError
|
34
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
35
|
+
end
|
36
|
+
|
37
|
+
task :default => :version
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.2.1
|
data/bin/hast
ADDED
data/config.yml.example
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
dns:
|
2
|
+
# The nameserver used when looking op domains.
|
3
|
+
#
|
4
|
+
# In most cases you can just leave this as 8.8.8.8 which is the
|
5
|
+
# primary Google nameserver.
|
6
|
+
#
|
7
|
+
nameserver: '8.8.8.8'
|
8
|
+
|
9
|
+
apache:
|
10
|
+
# The IP address of your Apache webserver.
|
11
|
+
#
|
12
|
+
# This is the one you expect all of your domians to resolve to.
|
13
|
+
#
|
14
|
+
ip: '192.168.0.1'
|
15
|
+
|
16
|
+
# The location of the main Apache config file.
|
17
|
+
#
|
18
|
+
# HAST will automatically load any depended configuration files that
|
19
|
+
# are included using the Apache 'Include' option.
|
20
|
+
#
|
21
|
+
config: '/usr/local/etc/apache22/httpd.conf'
|
22
|
+
|
23
|
+
# The configuration files specified using the Apache 'Include' option
|
24
|
+
# might not be specified using the absolute path. Use this option to
|
25
|
+
# prepend a path to the 'Include'-values.
|
26
|
+
#
|
27
|
+
base_path: '/usr/local'
|
28
|
+
|
29
|
+
# Enable this option to make HAST seach for domains in a directory as
|
30
|
+
# well as in the Apache configuration files.
|
31
|
+
#
|
32
|
+
# The names of all entries in this directory will be treated as
|
33
|
+
# domain names. This can be needed when the hosting solution involves
|
34
|
+
# Mass-Virtual-Hosting where the Apache Virtual-Hosts are created
|
35
|
+
# runtime by just adding directories to a specific folder on the
|
36
|
+
# filesystem.
|
37
|
+
#
|
38
|
+
#extra_domains_directory: '/usr/local/www/apache22/vhosts/'
|
39
|
+
|
40
|
+
postfix:
|
41
|
+
# The IP address of your Postfix mail-server.
|
42
|
+
#
|
43
|
+
# This is the one you expect all of your MX records to resolve to.
|
44
|
+
#
|
45
|
+
ip: '192.168.0.2'
|
46
|
+
|
47
|
+
# HAST needs access to the Postfix MySQL database to figure out which
|
48
|
+
# domains you are hosting mail for.
|
49
|
+
#
|
50
|
+
# Use theese options to specify the servername (host), the database
|
51
|
+
# user and password and finally the name of the database used by
|
52
|
+
# Postfix.
|
53
|
+
#
|
54
|
+
mysql:
|
55
|
+
host: localhost
|
56
|
+
user: postfix
|
57
|
+
password: secret
|
58
|
+
database: postfix
|
data/hast.gemspec
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{hast}
|
8
|
+
s.version = "0.2.1"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Thomas Watson Steen"]
|
12
|
+
s.date = %q{2010-02-17}
|
13
|
+
s.default_executable = %q{hast}
|
14
|
+
s.description = %q{ HAST stands for 'Hosting Account Status Tool'.
|
15
|
+
|
16
|
+
HAST is a tool for fetching domains from Apache configuration files and
|
17
|
+
from the Postfix database on a hosting server environment. It will then
|
18
|
+
run a report, checking the DNS records for each domain to see if they
|
19
|
+
match your server.
|
20
|
+
|
21
|
+
This is important for finding "dead" domains where the domain either
|
22
|
+
doesn't exist anymore or where the owner have moved it to another
|
23
|
+
hosting provider.
|
24
|
+
|
25
|
+
Before you can use HAST, you need to setup a config.yml file. Use
|
26
|
+
config.yml.example as a template.
|
27
|
+
}
|
28
|
+
s.email = %q{w@tson.dk}
|
29
|
+
s.executables = ["hast"]
|
30
|
+
s.extra_rdoc_files = [
|
31
|
+
"LICENSE",
|
32
|
+
"README.rdoc"
|
33
|
+
]
|
34
|
+
s.files = [
|
35
|
+
".document",
|
36
|
+
".gitignore",
|
37
|
+
"LICENSE",
|
38
|
+
"README.rdoc",
|
39
|
+
"Rakefile",
|
40
|
+
"VERSION",
|
41
|
+
"bin/hast",
|
42
|
+
"config.yml.example",
|
43
|
+
"hast.gemspec",
|
44
|
+
"lib/hast.rb",
|
45
|
+
"lib/hast/apache.rb",
|
46
|
+
"lib/hast/postfix.rb",
|
47
|
+
"lib/hast/verifier.rb"
|
48
|
+
]
|
49
|
+
s.homepage = %q{http://github.com/watson/hast}
|
50
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
51
|
+
s.require_paths = ["lib"]
|
52
|
+
s.rubygems_version = %q{1.3.5}
|
53
|
+
s.summary = %q{Hosting Account Status Tool - Fetch domains from Apache configuration files and the Postfix database on a hosting server environment. Then run a report checking each domains DNS records to see if they match your server.}
|
54
|
+
|
55
|
+
if s.respond_to? :specification_version then
|
56
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
57
|
+
s.specification_version = 3
|
58
|
+
|
59
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
60
|
+
s.add_development_dependency(%q<mysql>, [">= 0"])
|
61
|
+
s.add_development_dependency(%q<net-dns>, [">= 0"])
|
62
|
+
s.add_development_dependency(%q<deep_merge>, [">= 0.1.0"])
|
63
|
+
else
|
64
|
+
s.add_dependency(%q<mysql>, [">= 0"])
|
65
|
+
s.add_dependency(%q<net-dns>, [">= 0"])
|
66
|
+
s.add_dependency(%q<deep_merge>, [">= 0.1.0"])
|
67
|
+
end
|
68
|
+
else
|
69
|
+
s.add_dependency(%q<mysql>, [">= 0"])
|
70
|
+
s.add_dependency(%q<net-dns>, [">= 0"])
|
71
|
+
s.add_dependency(%q<deep_merge>, [">= 0.1.0"])
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
data/lib/hast/apache.rb
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
module HAST
|
2
|
+
class Apache
|
3
|
+
attr_reader :domains
|
4
|
+
|
5
|
+
def initialize(config)
|
6
|
+
@config = config
|
7
|
+
|
8
|
+
config_files = find_config_files(@config['apache']['config'])
|
9
|
+
|
10
|
+
domains = find_domains_in_config(config_files)
|
11
|
+
domains << find_extra_domains if @config['apache']['extra_domains_directory']
|
12
|
+
domains.flatten!
|
13
|
+
domains.uniq!
|
14
|
+
|
15
|
+
@domains = domains
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def find_pattern_in_file(filename, pattern, ignore_pattern = /^\s*#/, &block)
|
21
|
+
File.open(filename).each_line do |line|
|
22
|
+
line.chomp!
|
23
|
+
next if line =~ ignore_pattern
|
24
|
+
if match = line.match(pattern)
|
25
|
+
yield match
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def find_config_files(filename)
|
31
|
+
config_files = [filename]
|
32
|
+
find_pattern_in_file(filename, /^\s*Include\s+(.*)$/i) do |match|
|
33
|
+
# the include file might be a filename pattern instead of a real filname
|
34
|
+
Dir.glob(@config['apache']['base_path'] + match[1]).each do |include_file|
|
35
|
+
config_files << find_config_files(include_file)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
config_files.flatten.uniq
|
39
|
+
end
|
40
|
+
|
41
|
+
def find_domains_in_config(config_files)
|
42
|
+
domains = []
|
43
|
+
config_files.each do |filename|
|
44
|
+
find_pattern_in_file(filename, /^\s*(ServerName|ServerAlias)\s+(.*)$/i) do |match|
|
45
|
+
domains << match[2].split.map { |domain| domain.gsub(/:\d+$/, '') }
|
46
|
+
end
|
47
|
+
end
|
48
|
+
domains.flatten.uniq
|
49
|
+
end
|
50
|
+
|
51
|
+
def find_extra_domains
|
52
|
+
domains = []
|
53
|
+
Dir.foreach(@config['apache']['extra_domains_directory']) do |entry|
|
54
|
+
next if entry =~ /^\.\.?$/
|
55
|
+
domains << entry
|
56
|
+
end
|
57
|
+
domains
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
data/lib/hast/postfix.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'mysql'
|
2
|
+
|
3
|
+
module HAST
|
4
|
+
class Postfix
|
5
|
+
attr_reader :domains
|
6
|
+
|
7
|
+
def initialize(config)
|
8
|
+
@config = config
|
9
|
+
@domains = []
|
10
|
+
|
11
|
+
dbh = Mysql.real_connect(@config['postfix']['mysql']['host'],
|
12
|
+
@config['postfix']['mysql']['user'],
|
13
|
+
@config['postfix']['mysql']['password'],
|
14
|
+
@config['postfix']['mysql']['database'])
|
15
|
+
|
16
|
+
results = dbh.query('SELECT domain FROM domain')
|
17
|
+
results.each do |row|
|
18
|
+
next if row[0] == 'ALL'
|
19
|
+
@domains << row[0]
|
20
|
+
end
|
21
|
+
rescue Mysql::Error => e
|
22
|
+
puts "Error code: #{e.errno}"
|
23
|
+
puts "Error message: #{e.error}"
|
24
|
+
puts "Error SQLSTATE: #{e.sqlstate}" if e.respond_to?("sqlstate")
|
25
|
+
ensure
|
26
|
+
dbh.close if dbh
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
require 'net/dns/resolver'
|
2
|
+
|
3
|
+
module HAST
|
4
|
+
class Verifier
|
5
|
+
class << self
|
6
|
+
def run(config, domains, type, &output_block)
|
7
|
+
instance = self.new(config, domains, type, &output_block)
|
8
|
+
instance.verify_domains
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def initialize(config, domains, type, &output_block)
|
13
|
+
@config = config
|
14
|
+
@domains = domains
|
15
|
+
@type = type
|
16
|
+
@output_block = output_block
|
17
|
+
@dns = Net::DNS::Resolver.new
|
18
|
+
@dns.nameservers = @config['dns']['nameserver']
|
19
|
+
end
|
20
|
+
|
21
|
+
def verify_domains
|
22
|
+
@domains.each do |domain|
|
23
|
+
if @config['dns']['disable']
|
24
|
+
ips = nil
|
25
|
+
else
|
26
|
+
case @type
|
27
|
+
when :web
|
28
|
+
ips = get_server_ips(domain)
|
29
|
+
expected_ip = @config['apache']['ip']
|
30
|
+
when :mail
|
31
|
+
ips = get_mailserver_ips(domain)
|
32
|
+
expected_ip = @config['postfix']['ip']
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
if ips.nil?
|
37
|
+
@output_block.call domain, max_length, :unknown
|
38
|
+
elsif ips.empty?
|
39
|
+
@output_block.call domain, max_length, :inactive
|
40
|
+
elsif ips.include? expected_ip
|
41
|
+
@output_block.call domain, max_length, :active
|
42
|
+
else
|
43
|
+
@output_block.call domain, max_length, :other, ips
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
def max_length
|
51
|
+
max_length = 0
|
52
|
+
@domains.each do |domain|
|
53
|
+
max_length = domain.length if domain.length > max_length
|
54
|
+
end
|
55
|
+
max_length
|
56
|
+
end
|
57
|
+
|
58
|
+
def get_server_ips(domain)
|
59
|
+
ips = []
|
60
|
+
@dns.query(domain).each_address { |ip| ips << ip.to_s }
|
61
|
+
ips
|
62
|
+
end
|
63
|
+
|
64
|
+
def get_mailserver_ips(domain)
|
65
|
+
ips = []
|
66
|
+
@dns.query(domain, Net::DNS::MX).each_mx do |pref, name|
|
67
|
+
ips << get_server_ips(name)
|
68
|
+
end
|
69
|
+
ips.flatten.uniq
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
data/lib/hast.rb
ADDED
@@ -0,0 +1,128 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'optparse'
|
3
|
+
require 'yaml'
|
4
|
+
require 'deep_merge'
|
5
|
+
require 'hast/apache'
|
6
|
+
require 'hast/postfix'
|
7
|
+
require 'hast/verifier'
|
8
|
+
|
9
|
+
class Hast
|
10
|
+
NAME = "HAST - Hosting Account Status Tool"
|
11
|
+
|
12
|
+
attr_reader :config
|
13
|
+
|
14
|
+
def initialize
|
15
|
+
parse_command_line_args
|
16
|
+
load_config
|
17
|
+
load_domains
|
18
|
+
verify_domains
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def logger(text, newline = true, yaml = nil)
|
24
|
+
if @config['output'] == :yaml
|
25
|
+
return if yaml.nil?
|
26
|
+
text = yaml
|
27
|
+
end
|
28
|
+
|
29
|
+
if newline
|
30
|
+
puts text
|
31
|
+
else
|
32
|
+
print text
|
33
|
+
$stdout.flush
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def output_version
|
38
|
+
version = nil
|
39
|
+
File.open(File.dirname(__FILE__) + '/../VERSION') { |f| version = f.gets }
|
40
|
+
puts "#{NAME} v#{version}"
|
41
|
+
end
|
42
|
+
|
43
|
+
def output_config_template
|
44
|
+
File.open(File.dirname(__FILE__) + '/../config.yml.example') { |f| puts f.readlines }
|
45
|
+
end
|
46
|
+
|
47
|
+
def load_config
|
48
|
+
unless File.exists? @config_file
|
49
|
+
puts "ERROR: Could not find config file '#{@config_file}'... aborting"
|
50
|
+
exit 1
|
51
|
+
end
|
52
|
+
|
53
|
+
@config.deep_merge! YAML::load(File.open(@config_file))
|
54
|
+
unless @config['apache']['base_path'].empty? && @config['apache']['base_path'] !~ /\/$/
|
55
|
+
@config['apache']['base_path'] += '/'
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def parse_command_line_args
|
60
|
+
@config = {'output' => :stdout}
|
61
|
+
options = OptionParser.new do |opts|
|
62
|
+
opts.banner = "Usage: hast config-file [options]"
|
63
|
+
opts.separator ''
|
64
|
+
opts.separator 'Specific options:'
|
65
|
+
opts.on('-v', '--version',
|
66
|
+
'Show this message') { output_version; exit 0 }
|
67
|
+
opts.on('-h', '--help',
|
68
|
+
'Show version') { puts opts; exit 0 }
|
69
|
+
opts.on('-g', '--generate-config',
|
70
|
+
'Output a config file template',
|
71
|
+
'(pipe it to a file for easy use: hast -g > config.yml)') { output_config_template; exit 0 }
|
72
|
+
opts.on('-q', '--no-dns',
|
73
|
+
'Do not lookup any domain names or MX records') { @config['dns'] = { 'disable' => true } }
|
74
|
+
opts.on('-y', '--yaml',
|
75
|
+
'Output as YAML',
|
76
|
+
'(usefull if you want to pipe: bau.rb > domains.yml)') { @config['output'] = :yaml }
|
77
|
+
opts.on('-c', '--domain-cache FILE',
|
78
|
+
'Get the domains from a YAML file') { |file| @config['domain_cache'] = file }
|
79
|
+
opts.separator ''
|
80
|
+
opts.separator 'See http://github.com/watson/hast for details'
|
81
|
+
end
|
82
|
+
options.parse!
|
83
|
+
|
84
|
+
unless @config_file = ARGV.delete_at(0)
|
85
|
+
puts "ERROR: You must supply a config file as the first argument!"
|
86
|
+
puts " To generate a config file template use the -g argument"
|
87
|
+
puts
|
88
|
+
puts options
|
89
|
+
exit 1
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
def load_domains
|
94
|
+
logger "Finding domains..."
|
95
|
+
|
96
|
+
if @config['domain_cache']
|
97
|
+
domains = YAML::load(File.open(@config['domain_cache']))
|
98
|
+
@apache = domains['apache']
|
99
|
+
@postfix = domains['postfix']
|
100
|
+
else
|
101
|
+
@apache = HAST::Apache.new(@config).domains
|
102
|
+
@postfix = HAST::Postfix.new(@config).domains
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
def verify_domains
|
107
|
+
divider = '------------------------------------------------------------------------'
|
108
|
+
output_block = Proc.new do |domain, max_length, status, ips|
|
109
|
+
logger sprintf("%#{max_length}s : ", domain), false, " - #{domain}\n"
|
110
|
+
logger case status
|
111
|
+
when :active
|
112
|
+
'Active'
|
113
|
+
when :inactive
|
114
|
+
'Inactive (no record)'
|
115
|
+
when :unknown
|
116
|
+
'Status ukendt'
|
117
|
+
when :other
|
118
|
+
"Inactive (unexpected ip#{ips.size > 1 ? '\'s' : ''}: #{ips.join(', ')})"
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
logger "\nWebhosting status:\n#{divider}", true, 'apache:'
|
123
|
+
@apache.nil? ? logger('No domains found') : HAST::Verifier.run(@config, @apache, :web, &output_block)
|
124
|
+
|
125
|
+
logger "\nMailhosting status:\n#{divider}", true, 'postfix:'
|
126
|
+
@postfix.nil? ? logger('No domains found') : HAST::Verifier.run(@config, @postfix, :mail, &output_block)
|
127
|
+
end
|
128
|
+
end
|
metadata
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: hast
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Thomas Watson Steen
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2010-02-17 00:00:00 +01:00
|
13
|
+
default_executable: hast
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: mysql
|
17
|
+
type: :development
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: net-dns
|
27
|
+
type: :development
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: "0"
|
34
|
+
version:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: deep_merge
|
37
|
+
type: :development
|
38
|
+
version_requirement:
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 0.1.0
|
44
|
+
version:
|
45
|
+
description: " HAST stands for 'Hosting Account Status Tool'.\n\n HAST is a tool for fetching domains from Apache configuration files and\n from the Postfix database on a hosting server environment. It will then\n run a report, checking the DNS records for each domain to see if they\n match your server.\n\n This is important for finding \"dead\" domains where the domain either\n doesn't exist anymore or where the owner have moved it to another\n hosting provider.\n\n Before you can use HAST, you need to setup a config.yml file. Use\n config.yml.example as a template.\n"
|
46
|
+
email: w@tson.dk
|
47
|
+
executables:
|
48
|
+
- hast
|
49
|
+
extensions: []
|
50
|
+
|
51
|
+
extra_rdoc_files:
|
52
|
+
- LICENSE
|
53
|
+
- README.rdoc
|
54
|
+
files:
|
55
|
+
- .document
|
56
|
+
- .gitignore
|
57
|
+
- LICENSE
|
58
|
+
- README.rdoc
|
59
|
+
- Rakefile
|
60
|
+
- VERSION
|
61
|
+
- bin/hast
|
62
|
+
- config.yml.example
|
63
|
+
- hast.gemspec
|
64
|
+
- lib/hast.rb
|
65
|
+
- lib/hast/apache.rb
|
66
|
+
- lib/hast/postfix.rb
|
67
|
+
- lib/hast/verifier.rb
|
68
|
+
has_rdoc: true
|
69
|
+
homepage: http://github.com/watson/hast
|
70
|
+
licenses: []
|
71
|
+
|
72
|
+
post_install_message:
|
73
|
+
rdoc_options:
|
74
|
+
- --charset=UTF-8
|
75
|
+
require_paths:
|
76
|
+
- lib
|
77
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: "0"
|
82
|
+
version:
|
83
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - ">="
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: "0"
|
88
|
+
version:
|
89
|
+
requirements: []
|
90
|
+
|
91
|
+
rubyforge_project:
|
92
|
+
rubygems_version: 1.3.5
|
93
|
+
signing_key:
|
94
|
+
specification_version: 3
|
95
|
+
summary: Hosting Account Status Tool - Fetch domains from Apache configuration files and the Postfix database on a hosting server environment. Then run a report checking each domains DNS records to see if they match your server.
|
96
|
+
test_files: []
|
97
|
+
|