]> gitweb.michael.orlitzky.com - mailshears.git/blob - lib/prune/prune_runner.rb
Document everything with YARD and fix some bugs along the way.
[mailshears.git] / lib / prune / prune_runner.rb
1 require 'common/runner'
2 require 'prune/plugins/postfixadmin'
3 require 'rm/rm_runner'
4
5 # Perform the pruning of users/domains using {PrunePlugin}s.
6 #
7 class PruneRunner
8 include Runner
9
10 # Run *plugin* to prune leftover users and directories.
11 #
12 # @param cfg [Configuration] configuration options passed to
13 # {PostfixadminPrune}.
14 #
15 # @param plugin [Class] plugin class that will perform the pruning.
16 #
17 def run(cfg, plugin)
18 # We don't want to check the PostfixAdmin database against itself.
19 return if plugin.class == PostfixadminPrune
20
21 pfa = PostfixadminPrune.new(cfg)
22
23 db_users = pfa.list_users()
24 db_domains = pfa.list_domains()
25
26 leftovers = plugin.get_leftover_users(db_users)
27 leftovers += plugin.get_leftover_domains(db_domains)
28
29 # We're counting on our PrunePlugin also being an RmPlugin here.
30 rm_runner = RmRunner.new()
31 rm_runner.run(cfg, plugin, *leftovers)
32 end
33
34 end