X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2Fpart_export%2Fdomain_shellcommands.pm;h=d8ae0c376620884675befaca68ef91a122514e28;hp=5b3cd5d7960b5564484c203c9bfd016fd3a0eb01;hb=dabdf357484badff95afcae50b08ec1c3bb58343;hpb=22abdc37d4ec5699b62d295dc7ec1e41a8daf23b diff --git a/FS/FS/part_export/domain_shellcommands.pm b/FS/FS/part_export/domain_shellcommands.pm index 5b3cd5d79..d8ae0c376 100644 --- a/FS/FS/part_export/domain_shellcommands.pm +++ b/FS/FS/part_export/domain_shellcommands.pm @@ -1,11 +1,54 @@ package FS::part_export::domain_shellcommands; use strict; -use vars qw(@ISA); +use vars qw(@ISA %info); +use Tie::IxHash; use FS::part_export; @ISA = qw(FS::part_export); +tie my %options, 'Tie::IxHash', + 'user' => { label=>'Remote username', default=>'root' }, + 'useradd' => { label=>'Insert command', + default=>'', + }, + 'userdel' => { label=>'Delete command', + default=>'', + }, + 'usermod' => { label=>'Modify command', + default=>'', + }, +; + +%info = ( + 'svc' => 'svc_domain', + 'desc' => 'Run remote commands via SSH, for domains.', + 'options' => \%options, + 'notes' => <<'END' +Run remote commands via SSH, for domains. You will need to +setup SSH for unattended operation. +

Use these buttons for some useful presets: + +The following variables are available for interpolation (prefixed with new_ or old_ for replace operations): + +END +); + sub rebless { shift; } sub _export_insert { @@ -28,17 +71,16 @@ sub _export_command { no strict 'refs'; ${$_} = $svc_domain->getfield($_) foreach $svc_domain->fields; } + ( $qdomain = $domain ) =~ s/\./:/g; #see dot-qmail(5): EXTENSION ADDRESSES -# my $domain_record = $svc_www->domain_record; # or die ? -# my $zone = $domain_record->reczone; # or die ? -# unless ( $zone =~ /\.$/ ) { -# my $svc_domain = $domain_record->svc_domain; # or die ? -# $zone .= '.'. $svc_domain->domain; -# } - -# my $svc_acct = $svc_www->svc_acct; # or die ? -# my $username = $svc_acct->username; -# my $homedir = $svc_acct->dir; # or die ? + if ( $svc_domain->catchall ) { + no strict 'refs'; + my $svc_acct = $svc_domain->catchall_svc_acct; + ${$_} = $svc_acct->getfield($_) foreach qw(uid gid dir); + } else { + no strict 'refs'; + ${$_} = '' foreach qw(uid gid dir); + } #done setting variables for the command @@ -60,27 +102,23 @@ sub _export_replace { ${"old_$_"} = $old->getfield($_) foreach $old->fields; ${"new_$_"} = $new->getfield($_) foreach $new->fields; } -# my $old_domain_record = $old->domain_record; # or die ? -# my $old_zone = $old_domain_record->reczone; # or die ? -# unless ( $old_zone =~ /\.$/ ) { -# my $old_svc_domain = $old_domain_record->svc_domain; # or die ? -# $old_zone .= '.'. $old_svc_domain->domain; -# } -# -# my $old_svc_acct = $old->svc_acct; # or die ? -# my $old_username = $old_svc_acct->username; -# my $old_homedir = $old_svc_acct->dir; # or die ? -# -# my $new_domain_record = $new->domain_record; # or die ? -# my $new_zone = $new_domain_record->reczone; # or die ? -# unless ( $new_zone =~ /\.$/ ) { -# my $new_svc_domain = $new_domain_record->svc_domain; # or die ? -# $new_zone .= '.'. $new_svc_domain->domain; -# } - -# my $new_svc_acct = $new->svc_acct; # or die ? -# my $new_username = $new_svc_acct->username; -# my $new_homedir = $new_svc_acct->dir; # or die ? + ( $old_qdomain = $old_domain ) =~ s/\./:/g; #see dot-qmail(5): EXTENSION ADDRESSES + ( $new_qdomain = $new_domain ) =~ s/\./:/g; #see dot-qmail(5): EXTENSION ADDRESSES + + if ( $old->catchall ) { + no strict 'refs'; + my $svc_acct = $old->catchall_svc_acct; + ${"old_$_"} = $svc_acct->getfield($_) foreach qw(uid gid dir); + } else { + ${"old_$_"} = '' foreach qw(uid gid dir); + } + if ( $new->catchall ) { + no strict 'refs'; + my $svc_acct = $new->catchall_svc_acct; + ${"new_$_"} = $svc_acct->getfield($_) foreach qw(uid gid dir); + } else { + ${"new_$_"} = '' foreach qw(uid gid dir); + } #done setting variables for the command @@ -102,7 +140,7 @@ sub shellcommands_queue { } sub ssh_cmd { #subroutine, not method - use Net::SSH '0.07'; + use Net::SSH '0.08'; &Net::SSH::ssh_cmd( { @_ } ); } @@ -113,3 +151,5 @@ sub ssh_cmd { #subroutine, not method #sub shellcommands_delete { #subroutine, not method #} +1; +