X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fpart_export%2Fbroadband_shellcommands.pm;h=d3e495c459e99c2ccdfaa1184eab9365d4a19d13;hb=3cdf7e4e0b9f2b1ad44a45e1ab974f7a87372700;hp=b57267ec5520a722ca4198b4ad4600055dfaee13;hpb=6aacceec826a2d835af0ea8759924a83256d3ebe;p=freeside.git
diff --git a/FS/FS/part_export/broadband_shellcommands.pm b/FS/FS/part_export/broadband_shellcommands.pm
index b57267ec5..d3e495c45 100644
--- a/FS/FS/part_export/broadband_shellcommands.pm
+++ b/FS/FS/part_export/broadband_shellcommands.pm
@@ -37,8 +37,8 @@ tie my %options, 'Tie::IxHash',
'notes' => <<'END'
Run remote commands via SSH, for broadband services.
-All fields in svc_broadband are available for interpolation (prefixed with
-new_
or old_
for replace operations).
+All fields in svc_broadband are available for interpolation, as well as pkgnum, locationnum and custnum (prefixed with new_
or old_
+for replace operations).
END
);
@@ -70,7 +70,18 @@ sub _export_command {
my $command = $self->option($action);
return '' if $command =~ /^\s*$/;
- #set variables for the command
+ my $command_string = $self->_export_subvars( $svc_broadband, $command );
+
+ $self->shellcommands_queue( $svc_broadband->svcnum,
+ user => $self->option('user')||'root',
+ host => $self->machine,
+ command => $command_string,
+ );
+}
+
+sub _export_subvars {
+ my( $self, $svc_broadband, $command ) = @_;
+
no strict 'vars';
{
no strict 'refs';
@@ -80,20 +91,30 @@ sub _export_command {
$mac_addr = uc $mac_addr
if $self->option('uppercase_mac');
- #done setting variables for the command
+ my $cust_pkg = $svc_broadband->cust_svc->cust_pkg;
+ $pkgnum = $cust_pkg ? $cust_pkg->pkgnum : '';
+ $locationnum = $cust_pkg ? $cust_pkg->locationnum : '';
+ $custnum = $cust_pkg ? $cust_pkg->custnum : '';
- $self->shellcommands_queue( $svc_broadband->svcnum,
- user => $self->option('user')||'root',
- host => $self->machine,
- command => eval(qq("$command")),
- );
+ eval(qq("$command"));
}
sub _export_replace {
my($self, $new, $old ) = (shift, shift, shift);
my $command = $self->option('replace');
- #set variable for the command
+ my $command_string = $self->_export_subvars_replace( $new, $old, $command );
+
+ $self->shellcommands_queue( $new->svcnum,
+ user => $self->option('user')||'root',
+ host => $self->machine,
+ command => $command_string,
+ );
+}
+
+sub _export_subvars_replace {
+ my( $self, $new, $old, $command ) = @_;
+
no strict 'vars';
{
no strict 'refs';
@@ -106,15 +127,19 @@ sub _export_replace {
$new_mac_addr = uc $new_mac_addr;
}
- #done setting variables for the command
+ my $old_cust_pkg = $old->cust_svc->cust_pkg;
+ my $new_cust_pkg = $new->cust_svc->cust_pkg;
+ $old_pkgnum = $old_cust_pkg ? $old_cust_pkg->pkgnum : '';
+ $old_locationnum = $old_cust_pkg ? $old_cust_pkg->locationnum : '';
+ $old_custnum = $old_cust_pkg ? $old_cust_pkg->custnum : '';
+ $new_pkgnum = $new_cust_pkg ? $new_cust_pkg->pkgnum : '';
+ $new_locationnum = $new_cust_pkg ? $new_cust_pkg->locationnum : '';
+ $new_custnum = $new_cust_pkg ? $new_cust_pkg->custnum : '';
- $self->shellcommands_queue( $new->svcnum,
- user => $self->option('user')||'root',
- host => $self->machine,
- command => eval(qq("$command")),
- );
+ eval(qq("$command"));
}
+
#a good idea to queue anything that could fail or take any time
sub shellcommands_queue {
my( $self, $svcnum ) = (shift, shift);