X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fpart_export%2Fshellcommands.pm;h=9408d1454fc2f0c709ea88f38afa857d36e2aa2e;hb=aa7d05879906fde83caf3989d288c4e42de6df86;hp=b9d6551db96e29fd2477a04d770a48a8c5408ecd;hpb=1ad547a47f16b4230762e752fbe48d460ed997e1;p=freeside.git diff --git a/FS/FS/part_export/shellcommands.pm b/FS/FS/part_export/shellcommands.pm index b9d6551db..9408d1454 100644 --- a/FS/FS/part_export/shellcommands.pm +++ b/FS/FS/part_export/shellcommands.pm @@ -98,8 +98,7 @@ tie my %options, 'Tie::IxHash', %info = ( 'svc' => 'svc_acct', - 'desc' => - 'Real-time export via remote SSH (i.e. useradd, userdel, etc.)', + 'desc' => 'Real-time export via remote SSH (i.e. useradd, userdel, etc.)', 'options' => \%options, 'nodomain' => 'Y', 'svc_machine' => 1, @@ -244,12 +243,12 @@ sub _export_command { ${$_} = $svc_acct->getfield($_) foreach $svc_acct->fields; # snarfs are unused at this point? - my $count = 1; - foreach my $acct_snarf ( $svc_acct->acct_snarf ) { - ${"snarf_$_$count"} = shell_quote( $acct_snarf->get($_) ) - foreach qw( machine username _password ); - $count++; - } + # my $count = 1; + # foreach my $acct_snarf ( $svc_acct->acct_snarf ) { + # ${"snarf_$_$count"} = shell_quote( $acct_snarf->get($_) ) + # foreach qw( machine username _password ); + # $count++; + # } } my $cust_pkg = $svc_acct->cust_svc->cust_pkg; @@ -344,7 +343,7 @@ sub _export_command { my @ssh_cmd_args = ( user => $self->option('user') || 'root', - host => $self->machine, + host => $self->svc_machine($svc_acct), command => $command_string, stdin_string => $stdin_string, ignored_errors => $self->option('ignored_errors') || '', @@ -357,7 +356,7 @@ sub _export_command { eval { ssh_cmd(@ssh_cmd_args) }; $error = $@; $error = $error->full_message if ref $error; # Exception::Class::Base - return $error. ' ('. $self->exporttype. ' to '. $self->machine. ')' + return $error. ' ('. $self->exporttype. ' to '. $self->svc_machine($svc_acct). ')' if $error; } else { @@ -417,7 +416,7 @@ sub _export_replace { # $error ||= "can't change RADIUS groups"; #} } - return $error. ' ('. $self->exporttype. ' to '. $self->machine. ')' + return $error. ' ('. $self->exporttype. ' to '. $self->svc_machine($new). ')' if $error; $new_agent_custid = $new_cust_main ? $new_cust_main->agent_custid : ''; @@ -441,7 +440,7 @@ sub _export_replace { my @ssh_cmd_args = ( user => $self->option('user') || 'root', - host => $self->machine, + host => $self->svc_machine($new), command => $command_string, stdin_string => $stdin_string, ignored_errors => $self->option('ignored_errors') || '', @@ -454,7 +453,7 @@ sub _export_replace { eval { ssh_cmd(@ssh_cmd_args) }; $error = $@; $error = $error->full_message if ref $error; # Exception::Class::Base - return $error. ' ('. $self->exporttype. ' to '. $self->machine. ')' + return $error. ' ('. $self->exporttype. ' to '. $self->svc_machine($new). ')' if $error; } else { @@ -491,7 +490,7 @@ sub ssh_cmd { #subroutine, not method my ($output, $errput) = $ssh->capture2($ssh_opt, $opt->{'command'}); return if $opt->{'ignore_all_errors'}; - die "Error running SSH command: ". $ssh->error if $ssh->error; + #die "Error running SSH command: ". $ssh->error if $ssh->error; if ( ($output || $errput) && $opt->{'ignored_errors'} && length($opt->{'ignored_errors'}) @@ -505,7 +504,9 @@ sub ssh_cmd { #subroutine, not method $errput =~ s/[\s\n]//g; } - die "$errput\n" if $errput; + die (($errput || $ssh->error). "\n") if $errput || $ssh->error; + #die "$errput\n" if $errput; + die "$output\n" if $output and $opt->{'fail_on_output'}; ''; }