X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fpart_export%2Fphone_shellcommands.pm;h=71445bf2779b613e8689f316ebf3ea56d68c7af1;hb=691e990886ec62d387833fa74a860946682fcf26;hp=bddac19715d5e6639130852fbf04b5cf7455a53e;hpb=b7de08cc66e2f6e427c6fbcc1393b7eaba56b0fb;p=freeside.git
diff --git a/FS/FS/part_export/phone_shellcommands.pm b/FS/FS/part_export/phone_shellcommands.pm
index bddac1971..71445bf27 100644
--- a/FS/FS/part_export/phone_shellcommands.pm
+++ b/FS/FS/part_export/phone_shellcommands.pm
@@ -13,21 +13,23 @@ use FS::part_export;
#- suspension/unsuspension
tie my %options, 'Tie::IxHash',
- 'user' => { label=>'Remote username', default=>'root', },
- 'useradd' => { label=>'Insert command', },
- 'userdel' => { label=>'Delete command', },
- 'usermod' => { label=>'Modify command', },
- 'suspend' => { label=>'Suspension command', },
- 'unsuspend' => { label=>'Unsuspension command', },
+ 'user' => { label=>'Remote username', default=>'root', },
+ 'useradd' => { label=>'Insert command', },
+ 'userdel' => { label=>'Delete command', },
+ 'usermod' => { label=>'Modify command', },
+ 'suspend' => { label=>'Suspension command', },
+ 'unsuspend' => { label=>'Unsuspension command', },
+ 'mac_insert' => { label=>'Device MAC address insert command', },
+ 'mac_delete' => { label=>'Device MAC address delete command', },
;
%info = (
- 'svc' => 'svc_phone',
+ 'svc' => [qw( svc_phone part_device )],
'desc' => 'Run remote commands via SSH, for phone numbers',
'options' => \%options,
'notes' => <<'END'
Run remote commands via SSH, for phone numbers. You will need to
-setup SSH for unattended operation.
+setup SSH for unattended operation.
Use these buttons for some useful presets:
-
@@ -35,7 +37,7 @@ Run remote commands via SSH, for phone numbers. You will need to
this.form.user.value = "root";
this.form.useradd.value = "build_exten.php --create --exten $phonenum --directdid 1$phonenum --sip-secret $sip_password --name $cust_name --vm-password $pin && /usr/share/asterisk/bin/module_admin reload";
this.form.userdel.value = "build_exten.php --delete --exten $phonenum && /usr/share/asterisk/bin/module_admin reload";
- this.form.usermod.value = "";
+ this.form.usermod.value = "build_exten.php --modify --exten $new_phonenum --directdid 1$new_phonenum --sip-secret $new_sip_password --name $new_cust_name --vm-password $new_pin && /usr/share/asterisk/bin/module_admin reload";
this.form.suspend.value = "";
this.form.unsuspend.value = "";
'> (Important note: Reduce freeside-queued "max_kids" to 1 when using FreePBX integration)
@@ -49,6 +51,11 @@ old_ for replace operations):
$sip_password
- SIP secret (quoted for the shell)
$pin
- Personal identification number
$cust_name
- Customer name (quoted for the shell)
+ $pkgnum
- Internal package number
+ $custnum
- Internal customer number
+ $phone_name
- Phone name (quoted for the shell)
+ $mac_addr
- MAC address (Device MAC address insert and delete commands only)
+ $devicename
- Device type (Device type insert and delete commands only)
END
);
@@ -56,27 +63,43 @@ END
sub rebless { shift; }
sub _export_insert {
- my($self) = shift;
+ my $self = shift;
$self->_export_command('useradd', @_);
}
sub _export_delete {
- my($self) = shift;
+ my $self = shift;
$self->_export_command('userdel', @_);
}
sub _export_suspend {
- my($self) = shift;
+ my $self = shift;
$self->_export_command('suspend', @_);
}
sub _export_unsuspend {
- my($self) = shift;
+ my $self = shift;
$self->_export_command('unsuspend', @_);
}
+sub export_device_insert {
+ my( $self, $svc_phone, $phone_device ) = @_;
+ $self->_export_command('mac_insert', $svc_phone,
+ mac_addr => $phone_device->mac_addr,
+ devicename => $phone_device->part_device->devicename,
+ );
+}
+
+sub export_device_delete {
+ my( $self, $svc_phone, $phone_device ) = @_;
+ $self->_export_command('mac_delete', $svc_phone,
+ mac_addr => $phone_device->mac_addr,
+ devicename => $phone_device->part_device->devicename,
+ );
+}
+
sub _export_command {
- my ( $self, $action, $svc_phone) = (shift, shift, shift);
+ my ( $self, $action, $svc_phone, %addl_vars) = @_;
my $command = $self->option($action);
return '' if $command =~ /^\s*$/;
@@ -85,11 +108,15 @@ sub _export_command {
{
no strict 'refs';
${$_} = $svc_phone->getfield($_) foreach $svc_phone->fields;
+ ${$_} = $addl_vars{$_} foreach keys %addl_vars;
}
my $cust_pkg = $svc_phone->cust_svc->cust_pkg;
+ my $pkgnum = $cust_pkg ? $cust_pkg->pkgnum : '';
+ my $custnum = $cust_pkg ? $cust_pkg->custnum : '';
my $cust_name = $cust_pkg ? $cust_pkg->cust_main->name : '';
$cust_name = shell_quote $cust_name;
my $sip_password = shell_quote $svc_phone->sip_password;
+ my $phone_name = shell_quote $svc_phone->phone_name;
#done setting variables for the command
$self->shellcommands_queue( $svc_phone->svcnum,
@@ -111,7 +138,12 @@ sub _export_replace {
${"new_$_"} = $new->getfield($_) foreach $new->fields;
}
+ my $old_cust_pkg = $old->cust_svc->cust_pkg;
+ my $old_pkgnum = $old_cust_pkg ? $old_cust_pkg->pkgnum : '';
+ my $old_custnum = $old_cust_pkg ? $old_cust_pkg->custnum : '';
my $cust_pkg = $new->cust_svc->cust_pkg;
+ my $new_pkgnum = $cust_pkg ? $cust_pkg->pkgnum : '';
+ my $new_custnum = $new_cust_pkg ? $new_cust_pkg->custnum : '';
my $new_cust_name = $cust_pkg ? $cust_pkg->cust_main->name : '';
$new_cust_name = shell_quote $new_cust_name;
#done setting variables for the command
@@ -138,3 +170,4 @@ sub ssh_cmd { #subroutine, not method
&Net::SSH::ssh_cmd( { @_ } );
}
+1;