ispman/bin ispman-agent,1.65,1.66
Atif Ghaffar <[email protected]>
| Newsgroups | gmane.comp.isp.ispman.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/ispman/ispman/bin
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18236
Modified Files:
ispman-agent
Log Message:
ispman-agent is broken. It will not work. The paramters passed to the task are not in name=value&name=value format
Index: ispman-agent
===================================================================
RCS file: /cvsroot/ispman/ispman/bin/ispman-agent,v
retrieving revision 1.65
retrieving revision 1.66
diff -u -d -r1.65 -r1.66
--- ispman-agent 1 Aug 2004 21:15:51 -0000 1.65
+++ ispman-agent 30 Dec 2004 04:34:23 -0000 1.66
@@ -18,7 +18,7 @@
#use strict;
use vars qw(
- $VERSION @ISA @EXPORT @EXPORT_OK $TEST
+ $VERSION $VERBOSE @ISA @EXPORT @EXPORT_OK $TEST
$name $hostname $hostnames $ispman $domains
);
@@ -27,6 +27,7 @@
@ISA = qw(Exporter AutoLoader);
@EXPORT = qw();
$VERSION = '0.01';
+$VERBOSE=1;
use Data::Dumper;
use File::Path;
@@ -223,7 +224,20 @@
{
for $params ( keys %{ $processHash->{$domain}{$job} } ) {
logsay("Doing $job on $domain with parameters $params");
- $message = &{$job}( $domain, $params );
+ # Make a hash from params
+ my @pairs=();
+ my $pair="";
+ my $pname="";
+ my $pval="";
+ my $phash={};
+
+ @pairs=split('&', $params);
+ for $pair(@pairs) {
+ ($pname, $pval)=split(/\s*=\s*/, $pair);
+ $phash->{$pname}=$pval;
+ }
+ $phash->{'domain'}=$domain;
+ $message = &{$job}($phash);
if ( $message == 1 ) {
$ispman->deleteProcesses(
$processHash->{$domain}{$job}{$params} );
@@ -233,6 +247,8 @@
$processHash->{$domain}{$job}{$params},
"error", $message );
}
+
+
}
}
}
@@ -264,103 +280,8 @@
return 1;
}
-sub createMailbox {
- my ( $domain, $mailbox ) = @_;
-
- my $module = "$install_dir/lib/create_mailbox.lib";
- do $module;
-
- &create_mailbox_handler($mailbox);
- return 1;
-}
-
-sub setMailboxQuota {
- my ( $domain, $params ) = @_;
-
- my ( $mailbox, $quota ) = split( ",", $params );
-
- my $module = "$install_dir/lib/set_mailbox_quota.lib";
- do $module;
-
- &set_mailbox_quota_handler( $mailbox, $quota );
- return 1;
-}
-
-sub deleteMailbox {
- my ( $domain, $mailbox ) = @_;
-
- my $module = "$install_dir/lib/delete_mailbox.lib";
- do $module;
-
- &delete_mailbox_handler($mailbox);
- return 1;
-}
-
-sub createHomeDirectory {
- my ( $domain, $user ) = @_;
-
- my $module = "$install_dir/lib/create_home_directory.lib";
- do $module;
-
- my $user_info = $ispman->getUserInfo($user);
- &create_home_directory_handler(
- $user_info->{'homeDirectory'},
- $user_info->{'uidNumber'},
- $user_info->{'gidNumber'}
- );
- return 1;
-}
-
-sub deleteHomeDirectory {
- my ( $domain, $params ) = @_;
- my ( $user, $home_directory, $owner, $group ) = split( ",", $params );
-
- my $module = "$install_dir/lib/delete_home_directory.lib";
- do $module;
-
- &delete_home_directory_handler( $home_directory, $owner, $group );
- return 1;
-}
-
-sub DeleteVirtualHostDirectories {
- my ( $domain, $params ) = @_;
- my ( $vhost, $home_directory, $htdocs_dir, $cgibin_dir, $log_dir,
- $stats_dir )
- = split( ",", $params );
-
- my $module = "$install_dir/lib/delete_vhost_directories.lib";
- do $module;
-
- &delete_vhost_directories_handler( $vhost, $home_directory, $htdocs_dir,
- $cgibin_dir, $log_dir, $stats_dir );
- return 1;
-}
-
-sub createDomainDirectories {
- my ($domain) = @_;
- my $module = "$install_dir/lib/create_domain_directories.lib";
- do $module;
- my $domain_info = $ispman->getDomainInfo($domain);
- &create_domain_directories_handler(
- $domain_info->{'homeDirectory'},
- $domain_info->{'uidNumber'},
- $domain_info->{'gidNumber'}
- );
- return 1;
-}
-
-sub deleteDomainDirectories {
- my ( $domain, $params ) = @_;
- my ( $home_directory, $owner, $group ) = split( ",", $params );
-
- my $module = "$install_dir/lib/delete_domain_directories.lib";
- do $module;
-
- &delete_domain_directories_handler( $home_directory, $owner, $group );
- return 1;
-}
sub makeCanonicalMaps {
my ( $domain, $params ) = @_;
@@ -435,85 +356,92 @@
return 1;
}
-sub AddVirtualHost {
+
+
+sub modifyTransport {
my ( $domain, $params ) = @_;
- my $module = "$install_dir/lib/http.lib";
+ my $module = "$install_dir/lib/smtp.lib";
do $module;
- my $vhost = $params;
- my $template =
- $ispman->getTemplate("$install_dir/templates/vhosts.conf.template");
- return 1
- if ( add_vhost( $vhost, $domain )
- && make_vhosts_conf( $template, $domain )
- && reloadApache() );
+ &modify_transport_map_entry( $domain, $ispman->getTransportMap($domain) );
+ return 1;
}
-sub ModifyVirtualHost {
+sub NotifyUsers {
my ( $domain, $params ) = @_;
- my $module = "$install_dir/lib/http.lib";
+ my $module = "$install_dir/lib/send_email_to_domain.lib";
do $module;
- my $vhost = $params;
- my $template =
- $ispman->getTemplate("$install_dir/templates/vhosts.conf.template");
- return 1
- if ( modify_vhost( $vhost, $domain )
- && make_vhosts_conf( $template, $domain )
- && reloadApache() );
+ &sendEmailToDomain( $ispman, $domain, $params );
+ return 1;
}
-sub DeleteVirtualHost {
- my ( $domain, $params ) = @_;
+## function called by the task scripts
+sub executeCommands{
+ $NOEXEC=0;
+ my @commands=@_;
+ foreach $command(@commands) {
+ if ($VERBOSE) {
+ print "Command: $command\n";
+ }
+ unless ($NOEXEC){
+ system($command);
+ }
+ }
+}
- my $module = "$install_dir/lib/http.lib";
- do $module;
- my $vhost = $params;
- my $template =
- $ispman->getTemplate("$install_dir/templates/vhosts.conf.template");
- return 1
- if ( delete_vhost( $vhost, $domain )
- && make_vhosts_conf( $template, $domain )
- && reloadApache() );
-}
-sub AddVirtualHostDirectories {
- my ( $domain, $params ) = @_;
- my $module = "$install_dir/lib/create_vhost_directories.lib";
- do $module;
+sub AUTOLOAD {
+ my $self=shift;
+ my $type = ref($self);
+ my $params;
+ my $retVal;
- return 1 if ( &create_vhost_directories_handler( split( ",", $params ) ) );
-}
-sub modifyTransport {
- my ( $domain, $params ) = @_;
- my $module = "$install_dir/lib/smtp.lib";
- do $module;
+ if ($type eq "HASH") {
+ $params=$self;
+ } else {
+ $params=shift;
+ }
- &modify_transport_map_entry( $domain, $ispman->getTransportMap($domain) );
- return 1;
-}
-sub NotifyUsers {
- my ( $domain, $params ) = @_;
+ our @cmd=();
+
+
+ my $name=$AUTOLOAD;
+ $name =~ s/.*://; # strip fully-qualified portion
+ $text="You tried to call $name with ";
+ $text.=join ",", map{"$_=$params->{$_}"} keys %$params;
+ $text.="\n";
+
+ $task_func=join "_", ($name, "task");
+ $task_dir=$FindBin::Bin . "/../tasks/";
+ $task_file="$task_dir/$task_func\.pl";
+
+
+ $text.="Task dir: $task_dir does not exists" unless (-d $task_dir);
+ $text.="Task file: $task_file does not exists" unless (-e $task_file);
+
+ if (-f $task_file) {
+ do $task_file;
+ $retVal=&{$task_func}($params);
+ } else {
+ print $text;
+ }
+ if ($retVal==0) {
+ return 0;
+ } else {
+ executeCommands(@cmd);
+ return 1;
+ }
- my $module = "$install_dir/lib/send_email_to_domain.lib";
- do $module;
- &sendEmailToDomain( $ispman, $domain, $params );
- return 1;
-}
-sub AUTOLOAD {
- my $error = "";
- $error .= "Function $AUTOLOAD is missing. Called by ";
- $error .= join " ", caller;
- return $error;
}
sub DESTROY {
-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues
Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek.
It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt