1 package FS::part_export::www_shellcommands;
7 @ISA = qw(FS::part_export);
13 $self->_export_command('useradd', @_);
18 $self->_export_command('userdel', @_);
22 my ( $self, $action, $svc_www) = (shift, shift, shift);
23 my $command = $self->option($action);
25 #set variable for the command
28 ${$_} = $svc_www->getfield($_) foreach $svc_www->fields;
30 my $domain_record = $svc_www->domain_record; # or die ?
31 my $zone = $domain_record->reczone; # or die ?
32 unless ( $zone =~ /\.$/ ) {
33 my $svc_domain = $domain_record->svc_domain; # or die ?
34 $zone .= '.'. $svc_domain->domain;
37 my $svc_acct = $svc_www->svc_acct; # or die ?
38 my $username = $svc_acct->username;
39 my $homedir = $svc_acct->dir; # or die ?
41 #done setting variables for the command
43 $self->shellcommands_queue( $svc_www->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
57 ${"old_$_"} = $old->getfield($_) foreach $old->fields;
58 ${"new_$_"} = $new->getfield($_) foreach $new->fields;
60 my $old_domain_record = $old->domain_record; # or die ?
61 my $old_zone = $old_domain_record->reczone; # or die ?
62 unless ( $old_zone =~ /\.$/ ) {
63 my $old_svc_domain = $old_domain_record->svc_domain; # or die ?
64 $old_zone .= '.'. $old_svc_domain->domain;
67 my $old_svc_acct = $old->svc_acct; # or die ?
68 my $old_username = $old_svc_acct->username;
69 my $old_homedir = $old_svc_acct->dir; # or die ?
71 my $new_domain_record = $new->domain_record; # or die ?
72 my $new_zone = $new_domain_record->reczone; # or die ?
73 unless ( $new_zone =~ /\.$/ ) {
74 my $new_svc_domain = $new_domain_record->svc_domain; # or die ?
75 $new_zone .= '.'. $new_svc_domain->domain;
78 my $new_svc_acct = $new->svc_acct; # or die ?
79 my $new_username = $new_svc_acct->username;
80 my $new_homedir = $new_svc_acct->dir; # or die ?
82 #done setting variables for the command
84 $self->shellcommands_queue( $new->svcnum,
85 user => $self->option('user')||'root',
86 host => $self->machine,
87 command => eval(qq("$command")),
91 #a good idea to queue anything that could fail or take any time
92 sub shellcommands_queue {
93 my( $self, $svcnum ) = (shift, shift);
94 my $queue = new FS::queue {
96 'job' => "FS::part_export::www_shellcommands::ssh_cmd",
101 sub ssh_cmd { #subroutine, not method
103 &Net::SSH::ssh_cmd( { @_ } );
106 #sub shellcommands_insert { #subroutine, not method
108 #sub shellcommands_replace { #subroutine, not method
110 #sub shellcommands_delete { #subroutine, not method