1 package FS::part_export::forward_shellcommands;
5 use FS::Record qw(qsearchs);
9 @ISA = qw(FS::part_export);
11 sub rebless { shift; }
15 $self->_export_command('useradd', @_);
20 $self->_export_command('userdel', @_);
24 my ( $self, $action, $svc_forward ) = (shift, shift, shift);
25 my $command = $self->option($action);
27 #set variable for the command
31 ${$_} = $svc_forward->getfield($_) foreach $svc_forward->fields;
34 my $svc_acct = qsearchs( 'svc_acct', { 'svcnum' => $self->srcsvc } );
35 $username = $svc_acct->username;
36 $domain = $svc_acct->domain;
38 $destination = $self->dstsvc_acct->email;
40 $destination = $self->dst;
43 #done setting variables for the command
45 $self->shellcommands_queue( $svc_forward->svcnum,
46 user => $self->option('user')||'root',
47 host => $self->machine,
48 command => eval(qq("$command")),
53 my( $self, $new, $old ) = (shift, shift, shift);
54 my $command = $self->option('usermod');
56 #set variable for the command
60 ${"old_$_"} = $old->getfield($_) foreach $old->fields;
61 ${"new_$_"} = $new->getfield($_) foreach $new->fields;
64 my $old_svc_acct = qsearchs( 'svc_acct', { 'svcnum' => $self->srcsvc } );
65 $old_username = $old_svc_acct->username;
66 $old_domain = $old_svc_acct->domain;
68 $old_destination = $self->dstsvc_acct->email;
70 $old_destination = $self->dst;
73 my $new_svc_acct = qsearchs( 'svc_acct', { 'svcnum' => $self->srcsvc } );
74 $new_username = $new_svc_acct->username;
75 $new_domain = $new_svc_acct->domain;
77 $new_destination = $self->dstsvc_acct->email;
79 $new_destination = $self->dst;
82 #done setting variables for the command
84 $self->shellcommands_queue( $new->svcnum,
85 user => $self->option('user')||'root',
86 host => $self->machine,
87 command => eval(qq("$command")),
91 #a good idea to queue anything that could fail or take any time
92 sub shellcommands_queue {
93 my( $self, $svcnum ) = (shift, shift);
94 my $queue = new FS::queue {
96 'job' => "FS::part_export::forward_shellcommands::ssh_cmd",
101 sub ssh_cmd { #subroutine, not method
103 &Net::SSH::ssh_cmd( { @_ } );
106 #sub shellcommands_insert { #subroutine, not method
108 #sub shellcommands_replace { #subroutine, not method
110 #sub shellcommands_delete { #subroutine, not method