From cd2241d7ea1ce53a626adfd58a908cfd822c618c Mon Sep 17 00:00:00 2001 From: mark Date: Tue, 28 Jul 2009 02:12:50 +0000 Subject: [PATCH] Add no_queue option to shellcommands exports --- FS/FS/part_export/shellcommands.pm | 24 +++++++++++++++++++----- FS/FS/part_export/shellcommands_withdomain.pm | 3 +++ 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/FS/FS/part_export/shellcommands.pm b/FS/FS/part_export/shellcommands.pm index c55fa367e..e375302a4 100644 --- a/FS/FS/part_export/shellcommands.pm +++ b/FS/FS/part_export/shellcommands.pm @@ -65,6 +65,9 @@ tie my %options, 'Tie::IxHash', 'Radius group mapping to reason (via template user)', type => 'textarea', }, + 'no_queue' => { label => 'Run command immediately', + type => 'checkbox', + }, ; %info = ( @@ -367,12 +370,23 @@ sub _export_replace { my $command_string = eval(qq("$command")); - $self->shellcommands_queue( $new->svcnum, - user => $self->option('user')||'root', - host => $self->machine, - command => $command_string, - stdin_string => $stdin_string, + my @ssh_cmd_args = ( + user => $self->option('user') || 'root', + host => $self->machine, + command => $command_string, + stdin_string => $stdin_string, ); + + if($self->options('no_queue')) { + # discard return value just like freeside-queued. + eval { ssh_cmd(@ssh_cmd_args) }; + $error = $@; + return $error. ' ('. $self->exporttype. ' to '. $self->machine. ')' + if $error; + } + else { + $self->shellcommands_queue( $new->svcnum, @ssh_cmd_args ); + } } #a good idea to queue anything that could fail or take any time diff --git a/FS/FS/part_export/shellcommands_withdomain.pm b/FS/FS/part_export/shellcommands_withdomain.pm index 7c5d9045f..e1f47e410 100644 --- a/FS/FS/part_export/shellcommands_withdomain.pm +++ b/FS/FS/part_export/shellcommands_withdomain.pm @@ -51,6 +51,9 @@ tie my %options, 'Tie::IxHash', type=>'select', options=>[qw(crypt md5)], default => 'crypt', }, + 'no_queue' => { label => 'Run command immediately', + type => 'checkbox', + }, ; %info = ( -- 2.11.0