]> gitweb.michael.orlitzky.com - mailshears.git/blob - lib/rm/rm_runner.rb
039ae61f7d489c9a0a7807608b959fd912f3c99c
[mailshears.git] / lib / rm / rm_runner.rb
1 class RmRunner
2 include Runner
3
4 def run(plugin, targets)
5 targets.each do |target|
6 # Why think too hard? An account has an @, a domain doesn't.
7 if target.include?('@') then
8 begin
9 account_description = plugin.describe_account(target)
10 plugin.delete_account(target)
11 puts "Removed account: #{target} (#{account_description})"
12 rescue StandardError => e
13 puts "There was an error removing the account: #{e.to_s}"
14 Kernel.exit(ExitCodes::DATABASE_ERROR)
15 end
16 else
17 begin
18 # TODO: Delete all accounts first.
19 domain_description = plugin.describe_domain(target)
20 plugin.delete_domain(target)
21 puts "Removed domain: #{target} (#{domain_description})"
22 rescue StandardError => e
23 puts "There was an error removing the domain: #{e.to_s}"
24 Kernel.exit(ExitCodes::DATABASE_ERROR)
25 end
26 end
27 end
28
29 # TODO: remove from postfixadmin as well.
30 end
31
32 end