X-Git-Url: http://gitweb.michael.orlitzky.com/?p=mailshears.git;a=blobdiff_plain;f=lib%2Fprune%2Fprune_runner.rb;h=a9e2282857fc3be027a14d0410ae75436c25f934;hp=0f1dfeb3832a70c7baf77b59d3b8d0bfbd493e07;hb=df4e02ebf6a4e28a58abcb298a4442a245ad0b15;hpb=e3826d8926e11763837a591986d453e9ef5d9dec diff --git a/lib/prune/prune_runner.rb b/lib/prune/prune_runner.rb index 0f1dfeb..a9e2282 100644 --- a/lib/prune/prune_runner.rb +++ b/lib/prune/prune_runner.rb @@ -1,8 +1,34 @@ +require 'common/runner' +require 'prune/plugins/postfixadmin' +require 'rm/rm_runner' + +# Perform the pruning of users/domains using {PrunePlugin}s. +# class PruneRunner include Runner - def run(plugin) - puts "Not implemented" + # Run *plugin* to prune leftover users and directories. + # + # @param cfg [Configuration] configuration options passed to + # {PostfixadminPrune}. + # + # @param plugin [Class] plugin class that will perform the pruning. + # + def run(cfg, plugin) + # We don't want to check the PostfixAdmin database against itself. + return if plugin.class == PostfixadminPrune + + pfa = PostfixadminPrune.new(cfg) + + db_users = pfa.list_users() + db_domains = pfa.list_domains() + + leftovers = plugin.get_leftover_users(db_users) + leftovers += plugin.get_leftover_domains(db_domains) + + # We're counting on our PrunePlugin also being an RmPlugin here. + rm_runner = RmRunner.new() + rm_runner.run(cfg, plugin, *leftovers) end end