X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fpart_export%2Fshellcommands.pm;h=e375302a462ce79f663a017b99a11d2607cd1572;hb=cd2241d7ea1ce53a626adfd58a908cfd822c618c;hp=29e0a57990aff2a7bb307a1f549093a36efd5c7a;hpb=e608d6097db8e63f52679a5686543b86f6bc1830;p=freeside.git diff --git a/FS/FS/part_export/shellcommands.pm b/FS/FS/part_export/shellcommands.pm index 29e0a5799..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 = ( @@ -255,7 +258,9 @@ sub _export_command { @radius_groups = $svc_acct->radius_groups; my ($reasonnum, $reasontext, $reasontypenum, $reasontypetext); - if ( $cust_pkg && $action eq 'suspend' && (my $r = $cust_pkg->last_reason) ) { + if ( $cust_pkg && $action eq 'suspend' && + (my $r = $cust_pkg->last_reason('susp')) ) + { $reasonnum = $r->reasonnum; $reasontext = $r->reason; $reasontypenum = $r->reason_type; @@ -365,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