8ae8ad218bcbc402e167509dca190ab62cbec5fb
[mailshears.git] / lib / prune / prune_runner.rb
1 require 'common/runner'
2 require 'prune/plugins/postfixadmin'
3 require 'rm/rm_runner'
4
5 class PruneRunner
6 include Runner
7
8 def run(plugin)
9 # We don't want to check the PostfixAdmin database against itself.
10 return if plugin.class == PostfixadminPrune
11
12 cfg = Configuration.new()
13 pfa = PostfixadminPrune.new(cfg)
14
15 db_users = pfa.list_users()
16 db_domains = pfa.list_domains()
17
18 leftovers = plugin.get_leftover_users(db_users)
19 leftovers += plugin.get_leftover_domains(db_domains)
20
21 rm_runner = RmRunner.new()
22 rm_runner.run(plugin, *leftovers)
23 end
24
25 end