+
+# Load each of the plugins that we'll need.
+cfg.plugins.each do |plugin_file|
+ require "#{mode_name}/plugins/#{plugin_file}"
+end
+
+# Always enabled, for now.
+require "#{mode_name}/plugins/postfixadmin_db"
+
+# And the runners.
+require "#{mode_name}/#{mode_name}_runner"
+require "#{mode_name}/#{mode_name}_dummy_runner"
+
+def make_header(plugin_name)
+ # The header that we output before the list of domains/accounts.
+ # Just the path of this script, the current time, and the plugin name.
+ exe = File.basename($PROGRAM_NAME)
+ header = "#{exe}, "
+
+ current_time = Time.now()
+ if current_time.respond_to?(:iso8601)
+ # Somehow this method is missing on some machines.
+ header += current_time.iso8601.to_s
+ else
+ # Fall back to whatever this looks like.
+ header += current_time.to_s
+ end
+
+ header += ' (Plugin: ' + plugin_name + ")\n"
+ header += '-' * header.size # Underline the header.
+
+ return header
+end
+
+
+plugin_class = nil
+runner_class = nil
+dummy_runner_class = nil
+
+if mode == :rm then
+ plugin_class = RmPlugin
+ runner_class = RmRunner
+ dummy_runner_class = RmDummyRunner
+elsif mode == :mv then
+ plugin_class = MvPlugin
+ runner_class = MvRunner
+ dummy_runner_class = MvDummyRunner
+else
+ # Safe, catch-all default
+ plugin_class = PrunePlugin
+ runner_class = PruneRunner
+ dummy_runner_class = PruneDummyRunner
+end
+
+puts make_header(plugin_class.to_s())
+
+plugin_class.includers.each do |plugin_class_includer|
+ plugin = plugin_class_includer.new()
+
+ if cfg.i_mean_business then
+ runner = runner_class.new()
+ else
+ runner = dummy_runner_class.new()
+ end
+
+ # The splat passes the correct (we hope) number of arguments to the
+ # appropriate runner. The Rm(Dummy)Runner have splats on their
+ # *target arguments as well, to turn ARGV back into an array.
+ runner.run(plugin, *ARGV)
+
+ puts ""
+end
+
+
+
+Kernel.exit(0)