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;
32 # my $domain_record = $svc_www->domain_record; # or die ?
33 # my $zone = $domain_record->reczone; # or die ?
34 # unless ( $zone =~ /\.$/ ) {
35 # my $svc_domain = $domain_record->svc_domain; # or die ?
36 # $zone .= '.'. $svc_domain->domain;
39 # my $svc_acct = $svc_www->svc_acct; # or die ?
40 # my $username = $svc_acct->username;
41 # my $homedir = $svc_acct->dir; # or die ?
43 #done setting variables for the command
45 $self->shellcommands_queue( $svc_domain->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;
63 # my $old_domain_record = $old->domain_record; # or die ?
64 # my $old_zone = $old_domain_record->reczone; # or die ?
65 # unless ( $old_zone =~ /\.$/ ) {
66 # my $old_svc_domain = $old_domain_record->svc_domain; # or die ?
67 # $old_zone .= '.'. $old_svc_domain->domain;
70 # my $old_svc_acct = $old->svc_acct; # or die ?
71 # my $old_username = $old_svc_acct->username;
72 # my $old_homedir = $old_svc_acct->dir; # or die ?
74 # my $new_domain_record = $new->domain_record; # or die ?
75 # my $new_zone = $new_domain_record->reczone; # or die ?
76 # unless ( $new_zone =~ /\.$/ ) {
77 # my $new_svc_domain = $new_domain_record->svc_domain; # or die ?
78 # $new_zone .= '.'. $new_svc_domain->domain;
81 # my $new_svc_acct = $new->svc_acct; # or die ?
82 # my $new_username = $new_svc_acct->username;
83 # my $new_homedir = $new_svc_acct->dir; # or die ?
85 #done setting variables for the command
87 $self->shellcommands_queue( $new->svcnum,
88 user => $self->option('user')||'root',
89 host => $self->machine,
90 command => eval(qq("$command")),
94 #a good idea to queue anything that could fail or take any time
95 sub shellcommands_queue {
96 my( $self, $svcnum ) = (shift, shift);
97 my $queue = new FS::queue {
99 'job' => "FS::part_export::domain_shellcommands::ssh_cmd",
101 $queue->insert( @_ );
104 sub ssh_cmd { #subroutine, not method
106 &Net::SSH::ssh_cmd( { @_ } );
109 #sub shellcommands_insert { #subroutine, not method
111 #sub shellcommands_replace { #subroutine, not method
113 #sub shellcommands_delete { #subroutine, not method