1 package FS::part_export::domain_shellcommands;
7 @ISA = qw(FS::part_export);
13 $self->_export_command('useradd', @_);
18 $self->_export_command('userdel', @_);
22 my ( $self, $action, $svc_domain) = (shift, shift, shift);
23 my $command = $self->option($action);
25 #set variable for the command
29 ${$_} = $svc_domain->getfield($_) foreach $svc_domain->fields;
31 ( $qdomain = $domain ) =~ s/\./:/g; #see dot-qmail(5): EXTENSION ADDRESSES
33 if ( $svc_domain->catchall ) {
35 my $svc_acct = $svc_domain->catchall_svc_acct;
36 ${$_} = $svc_acct->getfield($_) foreach qw(uid gid dir);
39 ${$_} = '' foreach qw(uid gid dir);
42 #done setting variables for the command
44 $self->shellcommands_queue( $svc_domain->svcnum,
45 user => $self->option('user')||'root',
46 host => $self->machine,
47 command => eval(qq("$command")),
52 my($self, $new, $old ) = (shift, shift, shift);
53 my $command = $self->option('usermod');
55 #set variable for the command
59 ${"old_$_"} = $old->getfield($_) foreach $old->fields;
60 ${"new_$_"} = $new->getfield($_) foreach $new->fields;
62 ( $old_qdomain = $old_domain ) =~ s/\./:/g; #see dot-qmail(5): EXTENSION ADDRESSES
63 ( $new_qdomain = $new_domain ) =~ s/\./:/g; #see dot-qmail(5): EXTENSION ADDRESSES
65 if ( $old->catchall ) {
67 my $svc_acct = $old->catchall_svc_acct;
68 ${"old_$_"} = $svc_acct->getfield($_) foreach qw(uid gid dir);
70 ${"old_$_"} = '' foreach qw(uid gid dir);
72 if ( $new->catchall ) {
74 my $svc_acct = $new->catchall_svc_acct;
75 ${"new_$_"} = $svc_acct->getfield($_) foreach qw(uid gid dir);
77 ${"new_$_"} = '' foreach qw(uid gid dir);
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::domain_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