ispman/bin ispman-agent,1.70,1.71

Joerg Delker <[email protected]>
Newsgroups gmane.comp.isp.ispman.cvs
Message-ID <[email protected]>
Update of /cvsroot/ispman/ispman/bin
In directory sc8-pr-cvs2.sourceforge.net:/tmp/cvs-serv13307/bin

Modified Files:
	ispman-agent 
Log Message:
perltidy

Index: ispman-agent
===================================================================
RCS file: /cvsroot/ispman/ispman/bin/ispman-agent,v
retrieving revision 1.70
retrieving revision 1.71
diff -u -d -r1.70 -r1.71
--- ispman-agent	7 Sep 2006 20:56:53 -0000	1.70
+++ ispman-agent	7 Sep 2006 20:58:16 -0000	1.71
@@ -27,7 +27,7 @@
 @ISA     = qw(Exporter AutoLoader);
 @EXPORT  = qw();
 $VERSION = '0.01';
-$VERBOSE=1;
+$VERBOSE = 1;
 
 use Data::Dumper;
 use File::Path;
@@ -120,18 +120,18 @@
 }
 
 sub init_log {
-    require Log::Agent::Driver::File;  # logging made to file
-    logconfig(-driver =>
-              Log::Agent::Driver::File->make(
-                                             -prefix      => $name,
-                                             -showpid     => $pid,
-                                             -channels    => {
-                                                 'error'  => "$log_file",
-                                                 'output' => "$log_file",
-                                                 'debug'  => "$log_file",
-                                             },
-                                             )
-              );
+    require Log::Agent::Driver::File;    # logging made to file
+    logconfig(
+        -driver => Log::Agent::Driver::File->make(
+            -prefix   => $name,
+            -showpid  => $pid,
+            -channels => {
+                'error'  => "$log_file",
+                'output' => "$log_file",
+                'debug'  => "$log_file",
+            },
+        )
+    );
 
 }
 
@@ -159,8 +159,8 @@
 
 $ispman = ISPMan->new();
 
-$agentFrequency      = $ispman->getConf("agentFrequency") || 1;
-$ldapBaseDN          = $ispman->getConf('ldapBaseDN');
+$agentFrequency = $ispman->getConf("agentFrequency") || 1;
+$ldapBaseDN     = $ispman->getConf('ldapBaseDN');
 
 # get all host aliases
 my $hostInfo = $ispman->getHostInfo($hostname);
@@ -212,19 +212,20 @@
         {
             for $params ( keys %{ $processHash->{$domain}{$job} } ) {
                 logsay("Doing $job on $domain with parameters $params");
+
                 # Make a hash from params
-                my @pairs=();
-                my $pair="";
-                my $pname="";
-                my $pval="";
-                my $phash={};
+                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;
+                @pairs = split( '&', $params );
+                for $pair (@pairs) {
+                    ( $pname, $pval ) = split( /\s*=\s*/, $pair );
+                    $phash->{$pname} = $pval;
                 }
-                $phash->{'domain'}=$domain;
+                $phash->{'domain'} = $domain;
                 $message = &{$job}($phash);
                 if ( $message == 1 ) {
                     $ispman->deleteProcesses(
@@ -236,7 +237,6 @@
                         "error", $message );
                 }
 
-
             }
         }
     }
@@ -252,78 +252,70 @@
 
 }
 
-
-
-
 ## function called by the task scripts
-sub executeCommands{
-    $NOEXEC=0;
-    my @commands=@_;
-    my $errs=0;
-    foreach $command(@commands) {
-        my $rc=-1;
-        
-        unless ($NOEXEC){
-            $rc=system($command);
+sub executeCommands {
+    $NOEXEC = 0;
+    my @commands = @_;
+    my $errs     = 0;
+    foreach $command (@commands) {
+        my $rc = -1;
+
+        unless ($NOEXEC) {
+            $rc = system($command);
         }
-        logsay("Command=\"$command\", rc=".$rc);
+        logsay( "Command=\"$command\", rc=" . $rc );
 
-        $errs+=($rc!=0);
+        $errs += ( $rc != 0 );
 
     }
     return $errs;
 }
 
-
-
-
 sub AUTOLOAD {
-    my $self=shift;
+    my $self = shift;
     my $type = ref($self);
     my $params;
     my $retVal;
 
-
-
-    if ($type eq "HASH") {
-       $params=$self;
-    } else {
-       $params=shift;
+    if ( $type eq "HASH" ) {
+        $params = $self;
+    }
+    else {
+        $params = shift;
     }
 
+    our @cmd = ();
 
-    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";
+    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);
+    $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 ( -f $task_file ) {
+        do $task_file;
+        $retVal = &{$task_func}($params);
     }
-    if ($retVal==0) {
-       return $text;
+    else {
+        print $text;
     }
-    
+    if ( $retVal == 0 ) {
+        return $text;
+    }
+
     my $errs = executeCommands(@cmd);
-    if ($errs==0) { 
-      return 1;
-    } else {
-        return "There were $errs errors on\n".join("\n",@cmd);
+    if ( $errs == 0 ) {
+        return 1;
+    }
+    else {
+        return "There were $errs errors on\n" . join( "\n", @cmd );
     }
 }
 


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.