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
28 ${$_} = $svc_domain->getfield($_) foreach $svc_domain->fields;
31 # my $domain_record = $svc_www->domain_record; # or die ?
32 # my $zone = $domain_record->reczone; # or die ?
33 # unless ( $zone =~ /\.$/ ) {
34 # my $svc_domain = $domain_record->svc_domain; # or die ?
35 # $zone .= '.'. $svc_domain->domain;
38 # my $svc_acct = $svc_www->svc_acct; # or die ?
39 # my $username = $svc_acct->username;
40 # my $homedir = $svc_acct->dir; # or die ?
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
58 ${"old_$_"} = $old->getfield($_) foreach $old->fields;
59 ${"new_$_"} = $new->getfield($_) foreach $new->fields;
61 # my $old_domain_record = $old->domain_record; # or die ?
62 # my $old_zone = $old_domain_record->reczone; # or die ?
63 # unless ( $old_zone =~ /\.$/ ) {
64 # my $old_svc_domain = $old_domain_record->svc_domain; # or die ?
65 # $old_zone .= '.'. $old_svc_domain->domain;
68 # my $old_svc_acct = $old->svc_acct; # or die ?
69 # my $old_username = $old_svc_acct->username;
70 # my $old_homedir = $old_svc_acct->dir; # or die ?
72 # my $new_domain_record = $new->domain_record; # or die ?
73 # my $new_zone = $new_domain_record->reczone; # or die ?
74 # unless ( $new_zone =~ /\.$/ ) {
75 # my $new_svc_domain = $new_domain_record->svc_domain; # or die ?
76 # $new_zone .= '.'. $new_svc_domain->domain;
79 # my $new_svc_acct = $new->svc_acct; # or die ?
80 # my $new_username = $new_svc_acct->username;
81 # my $new_homedir = $new_svc_acct->dir; # or die ?
83 #done setting variables for the command
85 $self->shellcommands_queue( $new->svcnum,
86 user => $self->option('user')||'root',
87 host => $self->machine,
88 command => eval(qq("$command")),
92 #a good idea to queue anything that could fail or take any time
93 sub shellcommands_queue {
94 my( $self, $svcnum ) = (shift, shift);
95 my $queue = new FS::queue {
97 'job' => "FS::part_export::domain_shellcommands::ssh_cmd",
102 sub ssh_cmd { #subroutine, not method
104 &Net::SSH::ssh_cmd( { @_ } );
107 #sub shellcommands_insert { #subroutine, not method
109 #sub shellcommands_replace { #subroutine, not method
111 #sub shellcommands_delete { #subroutine, not method