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);
38 ${$_} = '' foreach qw(uid gid dir);
41 #done setting variables for the command
43 $self->shellcommands_queue( $svc_domain->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;
61 ( $old_qdomain = $old_domain ) =~ s/\./:/g; #see dot-qmail(5): EXTENSION ADDRESSES
62 ( $new_qdomain = $new_domain ) =~ s/\./:/g; #see dot-qmail(5): EXTENSION ADDRESSES
64 if ( $old->catchall ) {
66 my $svc_acct = $old->catchall_svc_acct;
67 ${"old_$_"} = $svc_acct->getfield($_) foreach qw(uid gid dir);
69 ${"old_$_"} = '' foreach qw(uid gid dir);
71 if ( $new->catchall ) {
73 my $svc_acct = $new->catchall_svc_acct;
74 ${"new_$_"} = $svc_acct->getfield($_) foreach qw(uid gid dir);
76 ${"new_$_"} = '' foreach qw(uid gid dir);
79 #done setting variables for the command
81 $self->shellcommands_queue( $new->svcnum,
82 user => $self->option('user')||'root',
83 host => $self->machine,
84 command => eval(qq("$command")),
88 #a good idea to queue anything that could fail or take any time
89 sub shellcommands_queue {
90 my( $self, $svcnum ) = (shift, shift);
91 my $queue = new FS::queue {
93 'job' => "FS::part_export::domain_shellcommands::ssh_cmd",
98 sub ssh_cmd { #subroutine, not method
100 &Net::SSH::ssh_cmd( { @_ } );
103 #sub shellcommands_insert { #subroutine, not method
105 #sub shellcommands_replace { #subroutine, not method
107 #sub shellcommands_delete { #subroutine, not method