ASNMTAP
view release on metacpan or search on metacpan
applications/htmlroot/cgi-bin/admin/generateConfig.pl view on Meta::CPAN
$commandsTODO .= "\n <tr bgcolor=\"$COLORSTABLE{STARTBLOCK}\"><td><FONT COLOR=\"cyaan\">match rule: $match - $capture</FONT></td></tr>";
}
}
$color = '#99CC99' unless ( $exitCurrentServer );
} else {
$exitCurrentServer = 1;
foreach my $capture ( @capture ) {
$capture =~ s/\r$//g;
$capture =~ s/\n$//g;
next unless ( defined $capture );
my $match = '0';
if ( $debug eq 'T' ) {
for ( $capture ) {
/^ksh:(?:\s)*(.)*:(?:\s)*not found$/ && do { $match = 127; last; }; # exit_value = 127
/^ksh:(?:\s)*(.)*:(?:\s)*cannot execute$/ && do { $match = 126; last; }; # exit_value = 126
/^scp:(?:\s)*(.)*:(?:\s)*No such file or directory$/ && do { $match = 1; last; }; # exit_value = 1
$match = '?';
}
}
$commandsTODO .= "\n <tr bgcolor=\"$COLORSTABLE{STARTBLOCK}\"><td><FONT COLOR=\"cyaan\">match rule: $match = exit_value: $exit_value - $capture</FONT></td></tr>";
}
}
my $prefix = ( ( $debug eq 'T' ) ? "A) '$label' [$_id] " : '' );
$commandsTODO .= "\n <tr bgcolor=\"$COLORSTABLE{ENDBLOCK}\"><td><b><FONT COLOR=\"$color\">${prefix}${command}</FONT></b></td></tr>";
} else { # implementatie moet nog gebeuren
my $color = ( ( $auto == 1 ) ? '#99CC99' : 'white');
my $prefix = ( ( $debug eq 'T' ) ? "I) '$label' [$_id] " : '' );
$commandsTODO .= "\n <tr bgcolor=\"$COLORSTABLE{ENDBLOCK}\"><td><b><FONT COLOR=\"$color\">${prefix}${command}</FONT></b></td></tr>";
}
} else { # no action required
my $prefix = ( ( $debug eq 'T' ) ? "N) '$label' [$_id] " : '' );
$commandsTODO .= "\n <tr bgcolor=\"$COLORSTABLE{ENDBLOCK}\"><td><FONT COLOR=\"#99CC99\">${prefix}${command}</FONT></td></tr>";
}
$commandsExecuted++ unless ( $exitCurrentServer );
}
}
}
$statusMessage .= $commandsTODO if (defined $commandsTODO);
# APE #
# unless ($details)
# $action = 'errorView' unless ( $commandsToExecute eq $commandsExecuted );
# }
return ($statusMessage);
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub do_system_call {
my ($command, $debug) = @_;
my ($stdout, $stderr, $exit_value, $signal_num, $dumped_core, $status, $statusMessage);
if ($CAPTUREOUTPUT) {
use IO::CaptureOutput qw(capture_exec);
($stdout, $stderr) = capture_exec("$command");
} else {
system ("$command"); $stdout = $stderr = '';
}
if ( $debug eq 'T' ) {
$exit_value = $? >> 8;
$signal_num = $? & 127;
$dumped_core = $? & 128;
$statusMessage = "<tr bgcolor=\"$COLORSTABLE{STARTBLOCK}\"><td>$command: ";
$statusMessage .= ( $exit_value == 0 && $signal_num == 0 && $dumped_core == 0 && $stderr eq '' ) ? 'Success' : "Failed '$stderr'";
$statusMessage .= "</td></tr>";
} else {
$statusMessage = '';
}
return ($statusMessage);
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub system_call {
my ($command, $parameters, $debug) = @_;
my $doSystemCall = 0;
my $statusMessage = '';
if ( $command eq "mkdir" ) {
$doSystemCall = 1 unless ( -e "$parameters" );
} elsif ( $command eq "rm -rf" ) {
if ($parameters =~ /$APPLICATIONPATH\/tmp\/$CONFIGDIR\// and -e "$parameters") { $doSystemCall = 1; }
} elsif ( $command eq "cp" ) {
if ($parameters =~ /^$APPLICATIONPATH\/tmp\/$CONFIGDIR/) { $doSystemCall = 1; }
} elsif ( $command eq "mv" ) {
if ($parameters =~ /^$APPLICATIONPATH\/tmp\/$CONFIGDIR/) { $doSystemCall = 1; }
} elsif ( $command =~ /diff -braq -I/ ) {
if ($parameters =~ /^$APPLICATIONPATH\/tmp\/$CONFIGDIR\/generated $APPLICATIONPATH\/tmp\/$CONFIGDIR\/installed/) { $statusMessage = do_compare_view("$command $parameters", 1, $debug); }
} elsif ( $command =~ /diff -braq -E/ ) {
$command =~ s/diff -braq -E/diff -braq -I/g;
if ($parameters =~ /^$APPLICATIONPATH\/tmp\/$CONFIGDIR\/generated $APPLICATIONPATH\/tmp\/$CONFIGDIR\/installed/) { $statusMessage = do_compare_view("$command $parameters", 0, $debug); }
}
if ( $doSystemCall ) {
$statusMessage = do_system_call ("$command $parameters", $debug);
if ( $command eq "mkdir" and $parameters =~ /^$APPLICATIONPATH\/tmp\/$CONFIGDIR/ ) {
$statusMessage .= do_system_call ("cp $APPLICATIONPATH/tools/templates/HEADER.html $parameters/", $debug);
$statusMessage .= do_system_call ("cp $APPLICATIONPATH/tools/templates/FOOTER.html $parameters/", $debug);
}
}
return ($statusMessage);
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
( run in 0.624 second using v1.01-cache-2.11-cpan-0bb4e1dffa6 )