Get prune working, at least in a simple case.
[mailshears.git] / lib / prune / prune_dummy_runner.rb
1 require 'common/runner'
2
3 # This is always needed, regardless of which plugin is running.
4 require 'prune/plugins/postfixadmin'
5
6 class PruneDummyRunner
7 include Runner
8
9 def run(plugin)
10 # We don't want to check the PostfixAdmin database against itself.
11 return if plugin.class == PostfixadminPrune
12
13 pfa = PostfixadminPrune.new()
14
15 db_users = pfa.list_users()
16 db_domains = pfa.list_domains()
17
18 leftover_users = plugin.get_leftover_accounts(db_users)
19 leftover_domains = plugin.get_leftover_domains(db_domains)
20
21 leftover_users.each do |user|
22 user_description = plugin.describe_account(user)
23 report(plugin, "Would remove user: #{user} (#{user_description})")
24 end
25
26 leftover_domains.each do |domain|
27 domain_description = plugin.describe_domain(domain)
28 report(plugin, "Would remove domain: #{domain} (#{domain_description})")
29 end
30 end
31
32 end