hast 0.2.2 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG ADDED
@@ -0,0 +1,21 @@
1
+ Master branch
2
+ ===============================================================================
3
+
4
+ Added support for finding Postfix domains in a config file instead of a
5
+ database.
6
+
7
+ Note that the mysql gem therefore isn't a gem dependency anymore. So if you
8
+ plan to use the Postfix database-method, you must manually install the mysql
9
+ gem.
10
+
11
+
12
+ Version 0.2.2 - 2010-02-16
13
+ ===============================================================================
14
+
15
+ Added gem dependencies
16
+
17
+
18
+ Version 0.2.1 - 2010-02-16
19
+ ===============================================================================
20
+
21
+ First version released
data/README.rdoc CHANGED
@@ -3,16 +3,17 @@
3
3
  HAST stands for 'Hosting Account Status Tool'.
4
4
 
5
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.
6
+ from Postfix on a hosting server environment. It will then run a
7
+ report, checking the DNS records for each domain to see if they match
8
+ your server.
9
9
 
10
10
  This is important for finding "dead" domains where the domain either
11
11
  doesn't exist anymore or where the owner have moved it to another
12
12
  hosting provider.
13
13
 
14
- Before you can use HAST, you need to setup a config.yml file. Use
15
- config.yml.example as a template.
14
+ Before you can use HAST, you need to setup a config.yml file. Run 'hast
15
+ --generate-config > config.yml' to create a sample config file that you
16
+ can modify.
16
17
 
17
18
  == Note on Patches/Pull Requests
18
19
 
@@ -37,7 +38,7 @@ For help use: hast -h
37
38
  -v, --version Display version
38
39
  -g, --generate-config Output a config file template (pipe it to a
39
40
  file for easy use: hast -g > config.yml)
40
- -q, --no-dns Do not lookup any domain names or MX records
41
+ -q, --disable-lookup Do not lookup any domain names or MX records
41
42
  -y, --yaml Output as YAML (usefull if you want to pipe:
42
43
  bau.rb > domains.yml)
43
44
  -c, --domain-cache FILE Get the domains from a YAML file
data/Rakefile CHANGED
@@ -5,26 +5,25 @@ begin
5
5
  require 'jeweler'
6
6
  Jeweler::Tasks.new do |gem|
7
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.}
8
+ gem.summary = %Q{Hosting Account Status Tool - Fetch domains from Apache configuration files and Postfix on a hosting server environment. Then run a report checking each domains DNS records to see if they match your server.}
9
9
  gem.description = <<-EOF
10
10
  HAST stands for 'Hosting Account Status Tool'.
11
11
 
12
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.
13
+ from Postfix on a hosting server environment. It will then run a report,
14
+ checking the DNS records for each domain to see if they match your server.
16
15
 
17
16
  This is important for finding "dead" domains where the domain either
18
17
  doesn't exist anymore or where the owner have moved it to another
19
18
  hosting provider.
20
19
 
21
- Before you can use HAST, you need to setup a config.yml file. Use
22
- config.yml.example as a template.
20
+ Before you can use HAST, you need to setup a config.yml file. Run 'hast
21
+ --generate-config > config.yml' to create a sample config file that you
22
+ can modify.
23
23
  EOF
24
24
  gem.email = "w@tson.dk"
25
25
  gem.homepage = "http://github.com/watson/hast"
26
26
  gem.authors = ["Thomas Watson Steen"]
27
- gem.add_dependency "mysql", ">= 0"
28
27
  gem.add_dependency "net-dns", ">= 0.1"
29
28
  gem.add_dependency "deep_merge", ">= 0.1.0"
30
29
  # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.2
1
+ 0.3.0
@@ -44,6 +44,21 @@ postfix:
44
44
  #
45
45
  ip: '192.168.0.2'
46
46
 
47
+ # Specify the method used for finding Postfix domains. Can either be
48
+ # 'file' for using a virtual host file or 'database' for usin a MySQL
49
+ # database.
50
+ #
51
+ # Note that if using the database-method, you need the mysql gem. To
52
+ # install run 'gem install mysql'.
53
+ #
54
+ method: file
55
+
56
+ # The path for the Postfix vhost file
57
+ #
58
+ vhost_file: '/etc/postfix/vhosts.txt'
59
+
60
+ # Enable this group when using the Postfix method 'database'
61
+ #
47
62
  # HAST needs access to the Postfix MySQL database to figure out which
48
63
  # domains you are hosting mail for.
49
64
  #
@@ -51,8 +66,8 @@ postfix:
51
66
  # user and password and finally the name of the database used by
52
67
  # Postfix.
53
68
  #
54
- mysql:
55
- host: localhost
56
- user: postfix
57
- password: secret
58
- database: postfix
69
+ #database:
70
+ # host: localhost
71
+ # user: postfix
72
+ # password: secret
73
+ # database: postfix
data/hast.gemspec CHANGED
@@ -5,25 +5,25 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{hast}
8
- s.version = "0.2.2"
8
+ s.version = "0.3.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Thomas Watson Steen"]
12
- s.date = %q{2010-02-17}
12
+ s.date = %q{2010-02-24}
13
13
  s.default_executable = %q{hast}
14
14
  s.description = %q{ HAST stands for 'Hosting Account Status Tool'.
15
15
 
16
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.
17
+ from Postfix on a hosting server environment. It will then run a report,
18
+ checking the DNS records for each domain to see if they match your server.
20
19
 
21
20
  This is important for finding "dead" domains where the domain either
22
21
  doesn't exist anymore or where the owner have moved it to another
23
22
  hosting provider.
24
23
 
25
- Before you can use HAST, you need to setup a config.yml file. Use
26
- config.yml.example as a template.
24
+ Before you can use HAST, you need to setup a config.yml file. Run 'hast
25
+ --generate-config > config.yml' to create a sample config file that you
26
+ can modify.
27
27
  }
28
28
  s.email = %q{w@tson.dk}
29
29
  s.executables = ["hast"]
@@ -34,12 +34,13 @@ Gem::Specification.new do |s|
34
34
  s.files = [
35
35
  ".document",
36
36
  ".gitignore",
37
+ "CHANGELOG",
37
38
  "LICENSE",
38
39
  "README.rdoc",
39
40
  "Rakefile",
40
41
  "VERSION",
41
42
  "bin/hast",
42
- "config.yml.example",
43
+ "config.yml.template",
43
44
  "hast.gemspec",
44
45
  "lib/hast.rb",
45
46
  "lib/hast/apache.rb",
@@ -49,24 +50,21 @@ Gem::Specification.new do |s|
49
50
  s.homepage = %q{http://github.com/watson/hast}
50
51
  s.rdoc_options = ["--charset=UTF-8"]
51
52
  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.}
53
+ s.rubygems_version = %q{1.3.6}
54
+ s.summary = %q{Hosting Account Status Tool - Fetch domains from Apache configuration files and Postfix on a hosting server environment. Then run a report checking each domains DNS records to see if they match your server.}
54
55
 
55
56
  if s.respond_to? :specification_version then
56
57
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
57
58
  s.specification_version = 3
58
59
 
59
60
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
60
- s.add_runtime_dependency(%q<mysql>, [">= 0"])
61
61
  s.add_runtime_dependency(%q<net-dns>, [">= 0.1"])
62
62
  s.add_runtime_dependency(%q<deep_merge>, [">= 0.1.0"])
63
63
  else
64
- s.add_dependency(%q<mysql>, [">= 0"])
65
64
  s.add_dependency(%q<net-dns>, [">= 0.1"])
66
65
  s.add_dependency(%q<deep_merge>, [">= 0.1.0"])
67
66
  end
68
67
  else
69
- s.add_dependency(%q<mysql>, [">= 0"])
70
68
  s.add_dependency(%q<net-dns>, [">= 0.1"])
71
69
  s.add_dependency(%q<deep_merge>, [">= 0.1.0"])
72
70
  end
data/lib/hast/postfix.rb CHANGED
@@ -1,5 +1,3 @@
1
- require 'mysql'
2
-
3
1
  module HAST
4
2
  class Postfix
5
3
  attr_reader :domains
@@ -8,10 +6,33 @@ module HAST
8
6
  @config = config
9
7
  @domains = []
10
8
 
11
- dbh = Mysql.real_connect(@config['postfix']['mysql']['host'],
12
- @config['postfix']['mysql']['user'],
13
- @config['postfix']['mysql']['password'],
14
- @config['postfix']['mysql']['database'])
9
+ case @config['postfix']['method']
10
+ when 'file'
11
+ vhost_file
12
+ when 'database'
13
+ mysql
14
+ when nil
15
+ raise "ERROR: Postfix method not specified!"
16
+ else
17
+ raise "ERROR: Unknown Postfix method '#{@config['postfix']['method']}'"
18
+ end
19
+ end
20
+
21
+ private
22
+
23
+ def vhost_file
24
+ File.open(@config['postfix']['vhost_file']) do |f|
25
+ @domains = f.readlines.compact.map{ |line| line.chomp }.reject{ |line| line.empty? }
26
+ end
27
+ end
28
+
29
+ def mysql
30
+ require 'mysql'
31
+
32
+ dbh = Mysql.real_connect(@config['postfix']['database']['host'],
33
+ @config['postfix']['database']['user'],
34
+ @config['postfix']['database']['password'],
35
+ @config['postfix']['database']['database'])
15
36
 
16
37
  results = dbh.query('SELECT domain FROM domain')
17
38
  results.each do |row|
data/lib/hast.rb CHANGED
@@ -41,7 +41,7 @@ class Hast
41
41
  end
42
42
 
43
43
  def output_config_template
44
- File.open(File.dirname(__FILE__) + '/../config.yml.example') { |f| puts f.readlines }
44
+ File.open(File.dirname(__FILE__) + '/../config.yml.template') { |f| puts f.readlines }
45
45
  end
46
46
 
47
47
  def load_config
@@ -69,7 +69,7 @@ class Hast
69
69
  opts.on('-g', '--generate-config',
70
70
  'Output a config file template',
71
71
  '(pipe it to a file for easy use: hast -g > config.yml)') { output_config_template; exit 0 }
72
- opts.on('-q', '--no-dns',
72
+ opts.on('-q', '--disable-lookup',
73
73
  'Do not lookup any domain names or MX records') { @config['dns'] = { 'disable' => true } }
74
74
  opts.on('-y', '--yaml',
75
75
  'Output as YAML',
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hast
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 3
8
+ - 0
9
+ version: 0.3.0
5
10
  platform: ruby
6
11
  authors:
7
12
  - Thomas Watson Steen
@@ -9,40 +14,37 @@ autorequire:
9
14
  bindir: bin
10
15
  cert_chain: []
11
16
 
12
- date: 2010-02-17 00:00:00 +01:00
17
+ date: 2010-02-24 00:00:00 +01:00
13
18
  default_executable: hast
14
19
  dependencies:
15
- - !ruby/object:Gem::Dependency
16
- name: mysql
17
- type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
20
- requirements:
21
- - - ">="
22
- - !ruby/object:Gem::Version
23
- version: "0"
24
- version:
25
20
  - !ruby/object:Gem::Dependency
26
21
  name: net-dns
27
- type: :runtime
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
30
24
  requirements:
31
25
  - - ">="
32
26
  - !ruby/object:Gem::Version
27
+ segments:
28
+ - 0
29
+ - 1
33
30
  version: "0.1"
34
- version:
31
+ type: :runtime
32
+ version_requirements: *id001
35
33
  - !ruby/object:Gem::Dependency
36
34
  name: deep_merge
37
- type: :runtime
38
- version_requirement:
39
- version_requirements: !ruby/object:Gem::Requirement
35
+ prerelease: false
36
+ requirement: &id002 !ruby/object:Gem::Requirement
40
37
  requirements:
41
38
  - - ">="
42
39
  - !ruby/object:Gem::Version
40
+ segments:
41
+ - 0
42
+ - 1
43
+ - 0
43
44
  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"
45
+ type: :runtime
46
+ version_requirements: *id002
47
+ description: " HAST stands for 'Hosting Account Status Tool'.\n\n HAST is a tool for fetching domains from Apache configuration files and\n from Postfix on a hosting server environment. It will then run a report,\n checking the DNS records for each domain to see if they 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. Run 'hast\n --generate-config > config.yml' to create a sample config file that you\n can modify.\n"
46
48
  email: w@tson.dk
47
49
  executables:
48
50
  - hast
@@ -54,12 +56,13 @@ extra_rdoc_files:
54
56
  files:
55
57
  - .document
56
58
  - .gitignore
59
+ - CHANGELOG
57
60
  - LICENSE
58
61
  - README.rdoc
59
62
  - Rakefile
60
63
  - VERSION
61
64
  - bin/hast
62
- - config.yml.example
65
+ - config.yml.template
63
66
  - hast.gemspec
64
67
  - lib/hast.rb
65
68
  - lib/hast/apache.rb
@@ -78,20 +81,22 @@ required_ruby_version: !ruby/object:Gem::Requirement
78
81
  requirements:
79
82
  - - ">="
80
83
  - !ruby/object:Gem::Version
84
+ segments:
85
+ - 0
81
86
  version: "0"
82
- version:
83
87
  required_rubygems_version: !ruby/object:Gem::Requirement
84
88
  requirements:
85
89
  - - ">="
86
90
  - !ruby/object:Gem::Version
91
+ segments:
92
+ - 0
87
93
  version: "0"
88
- version:
89
94
  requirements: []
90
95
 
91
96
  rubyforge_project:
92
- rubygems_version: 1.3.5
97
+ rubygems_version: 1.3.6
93
98
  signing_key:
94
99
  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.
100
+ summary: Hosting Account Status Tool - Fetch domains from Apache configuration files and Postfix on a hosting server environment. Then run a report checking each domains DNS records to see if they match your server.
96
101
  test_files: []
97
102