]> git.proxmox.com Git - pmg-api.git/commitdiff
implement API to delete all postfix queues
authorDietmar Maurer <dietmar@proxmox.com>
Tue, 26 Sep 2017 08:14:29 +0000 (10:14 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Tue, 26 Sep 2017 08:14:29 +0000 (10:14 +0200)
PMG/API2/Postfix.pm
PMG/Postfix.pm

index 2dd94e11df725c977b3c4efc144aa8336ef9984c..6e46ad6fccfdc5de4c89f218fbabd1a15cfa15c3 100644 (file)
@@ -273,6 +273,29 @@ __PACKAGE__->register_method ({
     }});
 
 
+__PACKAGE__->register_method ({
+    name => 'delete_all_queues',
+    path => 'queue',
+    method => 'DELETE',
+    description => "Delete all mails in all posfix queues.",
+    proxyto => 'node',
+    permissions => { check => [ 'admin' ] },
+    protected => 1,
+    parameters => {
+       additionalProperties => 0,
+       properties => {
+           node => get_standard_option('pve-node'),
+       },
+    },
+    returns => { type => 'null' },
+    code => sub {
+       my ($param) = @_;
+
+       PMG::Postfix::delete_queue();
+
+       return undef;
+    }});
+
 __PACKAGE__->register_method ({
     name => 'delete_queue',
     path => 'queue/{queue}',
index 5437548b30e77fcb29c0ae73b578d99cf00e7133..c0c8c73492a739ad4cfd93233686d7fcf27c29f9 100644 (file)
@@ -184,7 +184,7 @@ sub postcat {
     return $res;
 }
 
-# flush all queues
+# flush all queuespostconf -d|grep enable_long_queue_ids
 sub flush_queues {
     PVE::Tools::run_command(['/usr/sbin/postqueue', '-f']);
 }
@@ -205,7 +205,10 @@ sub delete_queued_mail {
 sub delete_queue {
     my ($queue) = @_;
 
-    PVE::Tools::run_command(['/usr/sbin/postsuper', '-d', 'ALL', $queue]);
+    my $cmd = ['/usr/sbin/postsuper', '-d', 'ALL'];
+    push @$cmd, $queue if defined($queue);
+
+    PVE::Tools::run_command($cmd);
 }
 
 sub discard_verify_cache {