]>
gitweb.michael.orlitzky.com - mailshears.git/blob - lib/rm/rm_runner.rb
0392d1192acbac86218c0813218e37b5b5c56929
1 require 'common/runner'
6 def run(plugin
, *targets
)
7 targets
.each
do |target
|
8 # Why think too hard? An account has an @, a domain doesn't.
9 if target
.include?('@') then
11 account_description
= plugin
.describe_account(target
)
12 plugin
.delete_account(target
)
13 report(plugin
, "Removed account: #{target} (#{account_description})")
15 rescue NonexistentAccountError
=> e
16 report(plugin
, "Account not found: #{e.to_s}")
17 rescue StandardError
=> e
18 report(plugin
, "There was an error removing the account: #{e.to_s}")
19 Kernel
.exit(ExitCodes
::DATABASE_ERROR)
23 # We must delete all accounts belonging to the domain first.
24 # This prevents us from leaving behind accounts. Not a
25 # problem with the mailstore, since we'll delete the domain
26 # directory anyway, but it is for the database plugins.
27 usernames
= plugin
.get_domain_usernames(target
)
28 usernames
.each
{ |u
| run(plugin
, u
) }
30 domain_description
= plugin
.describe_domain(target
)
31 plugin
.delete_domain(target
)
32 report(plugin
, "Removed domain: #{target} (#{domain_description})")
34 rescue NonexistentAccountError
=> e
35 # Can happen in the usernames.each... block.
36 report(plugin
, "Account not found: #{e.to_s}")
37 rescue NonexistentDomainError
=> e
38 report(plugin
, "Domain not found: #{e.to_s}")
39 rescue StandardError
=> e
40 report(plugin
, "There was an error removing the domain: #{e.to_s}")
41 Kernel
.exit(ExitCodes
::DATABASE_ERROR)