1 package FS::part_export::forward_shellcommands;
7 @ISA = qw(FS::part_export);
13 $self->_export_command('useradd', @_);
18 $self->_export_command('userdel', @_);
22 my ( $self, $action, $svc_forward ) = (shift, shift, shift);
23 my $command = $self->option($action);
25 #set variable for the command
29 ${$_} = $svc_forward->getfield($_) foreach $svc_forward->fields;
32 my $svc_acct = $svc_forward->srcsvc_acct;
33 $username = $svc_acct->username;
34 $domain = $svc_acct->domain;
35 if ($svc_forward->dstsvc_acct) {
36 $destination = $svc_forward->dstsvc_acct->email;
38 $destination = $svc_forward->dst;
41 #done setting variables for the command
43 $self->shellcommands_queue( $svc_forward->svcnum,
44 user => $self->option('user')||'root',
45 host => $self->machine,
46 command => eval(qq("$command")),
51 my( $self, $new, $old ) = (shift, shift, shift);
52 my $command = $self->option('usermod');
54 #set variable for the command
58 ${"old_$_"} = $old->getfield($_) foreach $old->fields;
59 ${"new_$_"} = $new->getfield($_) foreach $new->fields;
62 my $old_svc_acct = $old->srcsvc_acct;
63 $old_username = $old_svc_acct->username;
64 $old_domain = $old_svc_acct->domain;
65 if ($old->dstsvc_acct) {
66 $old_destination = $old->dstsvc_acct->email;
68 $old_destination = $old->dst;
71 my $new_svc_acct = $new->srcsvc_acct;
72 $new_username = $new_svc_acct->username;
73 $new_domain = $new_svc_acct->domain;
75 $new_destination = $new->dstsvc_acct->email;
77 $new_destination = $new->dst;
80 #done setting variables for the command
82 $self->shellcommands_queue( $new->svcnum,
83 user => $self->option('user')||'root',
84 host => $self->machine,
85 command => eval(qq("$command")),
89 #a good idea to queue anything that could fail or take any time
90 sub shellcommands_queue {
91 my( $self, $svcnum ) = (shift, shift);
92 my $queue = new FS::queue {
94 'job' => "FS::part_export::forward_shellcommands::ssh_cmd",
99 sub ssh_cmd { #subroutine, not method
101 &Net::SSH::ssh_cmd( { @_ } );
104 #sub shellcommands_insert { #subroutine, not method
106 #sub shellcommands_replace { #subroutine, not method
108 #sub shellcommands_delete { #subroutine, not method