X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fpart_export%2Fdomain_shellcommands.pm;h=994c113bf95d33792a024a126d17e9bd6885a0d8;hb=f98eec7448db3869808e0154969588f0f2e4098d;hp=d295eece0fcc9a6a9790dc05f057e9ab460444f7;hpb=193118008312797e8188145138c6875ba506ff33;p=freeside.git diff --git a/FS/FS/part_export/domain_shellcommands.pm b/FS/FS/part_export/domain_shellcommands.pm index d295eece0..994c113bf 100644 --- a/FS/FS/part_export/domain_shellcommands.pm +++ b/FS/FS/part_export/domain_shellcommands.pm @@ -1,11 +1,60 @@ 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 (qmail, ISPMan).', + '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 { @@ -21,6 +70,7 @@ sub _export_delete { sub _export_command { my ( $self, $action, $svc_domain) = (shift, shift, shift); my $command = $self->option($action); + return '' if $command =~ /^\s*$/; #set variable for the command no strict 'vars'; @@ -62,19 +112,22 @@ sub _export_replace { ( $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); + + if ( $old->catchall ) { + 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 ) { + 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 @@ -108,3 +161,5 @@ sub ssh_cmd { #subroutine, not method #sub shellcommands_delete { #subroutine, not method #} +1; +