X-Git-Url: http://gitweb.michael.orlitzky.com/?p=mailshears.git;a=blobdiff_plain;f=lib%2Frm%2Frm_runner.rb;fp=lib%2Frm%2Frm_runner.rb;h=039ae61f7d489c9a0a7807608b959fd912f3c99c;hp=0000000000000000000000000000000000000000;hb=a6ae98f0423603445b621a8eaa17443c8d590b45;hpb=616d9c0f3260f4d8e9bf26140fa6032c3eabca8b diff --git a/lib/rm/rm_runner.rb b/lib/rm/rm_runner.rb new file mode 100644 index 0000000..039ae61 --- /dev/null +++ b/lib/rm/rm_runner.rb @@ -0,0 +1,32 @@ +class RmRunner + include Runner + + def run(plugin, targets) + targets.each do |target| + # Why think too hard? An account has an @, a domain doesn't. + if target.include?('@') then + begin + account_description = plugin.describe_account(target) + plugin.delete_account(target) + puts "Removed account: #{target} (#{account_description})" + rescue StandardError => e + puts "There was an error removing the account: #{e.to_s}" + Kernel.exit(ExitCodes::DATABASE_ERROR) + end + else + begin + # TODO: Delete all accounts first. + domain_description = plugin.describe_domain(target) + plugin.delete_domain(target) + puts "Removed domain: #{target} (#{domain_description})" + rescue StandardError => e + puts "There was an error removing the domain: #{e.to_s}" + Kernel.exit(ExitCodes::DATABASE_ERROR) + end + end + end + + # TODO: remove from postfixadmin as well. + end + +end