ASNMTAP
view release on metacpan or search on metacpan
applications/htmlroot/cgi-bin/admin/generateConfig.pl view on Meta::CPAN
$dbh = DBI->connect("dbi:mysql:$DATABASE:$SERVERNAMEREADWRITE:$SERVERPORTREADWRITE", "$SERVERUSERREADWRITE", "$SERVERPASSREADWRITE" ) or $rv = error_trap_DBI(*STDOUT, "Cannot connect to the database", $debug, $pagedir, $pageset, $htmlTitle, $subT...
if ($dbh and $rv) {
my ( $masterFQDN, $masterASNMTAP_PATH, $masterRSYNC_PATH, $masterSSH_PATH, $slaveFQDN, $slaveASNMTAP_PATH, $slaveRSYNC_PATH, $slaveSSH_PATH );
$sql = "SELECT masterFQDN, masterASNMTAP_PATH, masterRSYNC_PATH, masterSSH_PATH, slaveFQDN, slaveASNMTAP_PATH, slaveRSYNC_PATH, slaveSSH_PATH FROM $SERVERTABLSERVERS where catalogID = '$CATALOGID' and activated = 1";
$sth = $dbh->prepare( $sql ) or $rv = error_trap_DBI(*STDOUT, "Cannot dbh->prepare: $sql", $debug, $pagedir, $pageset, $htmlTitle, $subTitle, -1, '', $sessionID);
$sth->execute() or $rv = error_trap_DBI(*STDOUT, "Cannot sth->execute: $sql", $debug, $pagedir, $pageset, $htmlTitle, $subTitle, -1, '', $sessionID) if $rv;
$sth->bind_columns( \$masterFQDN, \$masterASNMTAP_PATH, \$masterRSYNC_PATH, \$masterSSH_PATH, \$slaveFQDN, \$slaveASNMTAP_PATH, \$slaveRSYNC_PATH, \$slaveSSH_PATH ) or $rv = error_trap_DBI(*STDOUT, "Cannot sth->bind_columns: $sql", $debug, $pag...
if ($rv) {
if ( $sth->rows ) {
while( $sth->fetch() ) {
$ASNMTAP_PATH { 'M' } { $masterFQDN } = $masterASNMTAP_PATH if ( defined $masterFQDN and $masterFQDN and defined $masterASNMTAP_PATH and $masterASNMTAP_PATH );
$ASNMTAP_PATH { 'S'} { $slaveFQDN } = $slaveASNMTAP_PATH if ( defined $slaveFQDN and $slaveFQDN and defined $slaveASNMTAP_PATH and $slaveASNMTAP_PATH );
}
}
$sth->finish() or $rv = error_trap_DBI(*STDOUT, "Cannot sth->finish: $sql", $debug, $pagedir, $pageset, $htmlTitle, $subTitle, -1, '', $sessionID) if $rv;
}
$dbh->disconnect or $rv = error_trap_DBI(*STDOUT, "Sorry, the database was unable to add your entry.", $debug, $pagedir, $pageset, $htmlTitle, $subTitle, -1, '', $sessionID);
}
$installView .= "\n <table width=\"100%\" align=\"center\" border=\"0\" cellpadding=\"1\" cellspacing=\"1\" bgcolor=\"$COLORSTABLE{TABLE}\">";
$installView .= "\n <tr><th>Install Configuration</th></tr>";
if ( -e "$APPLICATIONPATH/tmp/$CONFIGDIR/generated" ) {
my $compareDiff = system_call ("$DIFFCOMMAND -braq -E 'generated on 20[0-9][0-9]/[0-9][0-9]/[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9]'", "$APPLICATIONPATH/tmp/$CONFIGDIR/generated $APPLICATIONPATH/tmp/$CONFIGDIR/installed", $debug);
if ($compareDiff eq '') {
$installView .= "\n <tr bgcolor=\"$COLORSTABLE{NOBLOCK}\"><td>The generated and installed configurations are identical.</td></tr>";
} else {
$installView .= "\n <tr><td align=\"center\"><b>Under construction:</b></td></tr>";
$installView .= "\n <tr bgcolor=\"$COLORSTABLE{ENDBLOCK}\"><td><table width=\"100%\" align=\"center\" border=\"0\" cellpadding=\"1\" cellspacing=\"1\" bgcolor=\"$COLORSTABLE{NOBLOCK}\">$compareDiff</table></td></tr>";
$installView .= "\n <tr><td align=\"center\"> </td></tr>";
$installView .= "\n <tr bgcolor=\"$COLORSTABLE{STARTBLOCK}\"><td>We only are allowed to press the <b>MOVE</b> button when all commands are successfully executed!</td></tr>" if ( $Cauto == 1 );
$installView .= "\n <tr align=\"left\"><td align=\"right\"><input type=\"submit\" value=\"". ( ( $Cauto == 1 ) ? 'MOVE' : 'INSTALL' ) ."\"> <input type=\"reset\" value=\"Reset\"></td></tr>\n";
}
} else {
$installView .= "\n <tr><td>The generated configuration doesn't exist.</td></tr>";
}
$installView .= "\n </table>";
} elsif ($action eq 'install') {
$installView .= "\n <table width=\"100%\" align=\"center\" border=\"0\" cellpadding=\"1\" cellspacing=\"1\" bgcolor=\"$COLORSTABLE{TABLE}\">";
$installView .= "\n <tr><th>Configuration Installed</th></tr>";
if ( -e "$APPLICATIONPATH/tmp/$CONFIGDIR/generated" ) {
$installView .= system_call ("rm -rf", "$APPLICATIONPATH/tmp/$CONFIGDIR/installed", $debug);
$installView .= system_call ("mv", "$APPLICATIONPATH/tmp/$CONFIGDIR/generated $APPLICATIONPATH/tmp/$CONFIGDIR/installed", $debug);
$installView .= "\n <tr bgcolor=\"$COLORSTABLE{STARTBLOCK}\"><td>We <b>moved</b> $APPLICATIONPATH/tmp/$CONFIGDIR/generated to $APPLICATIONPATH/tmp/$CONFIGDIR/installed</td></tr>";
} else {
$installView .= "\n <tr><td>The generated configuration doesn't exist.</td></tr>";
}
$installView .= "\n </table>";
}
if ( $rv ) {
if ($action eq 'installView') {
print " <form action=\"" . $ENV{SCRIPT_NAME} . "\" method=\"post\" name=\"generateConfig\">\n";
my $_action = ( ( $Cauto == 1 ) ? 'install' : $action );
print <<HTML;
<input type="hidden" name="pagedir" value="$pagedir">
<input type="hidden" name="pageset" value="$pageset">
<input type="hidden" name="debug" value="$debug">
<input type="hidden" name="CGISESSID" value="$sessionID">
<input type="hidden" name="action" value="$_action">
<input type="hidden" name="auto" value="1">
HTML
}
if ($action eq 'updateView' or $action eq 'update') {
print " <table width=\"100%\"><tr align=\"center\"><td>\n";
print " <table bgcolor=\"$COLORSTABLE{TABLE}\" border=\"0\" cellspacing=\"1\" cellpadding=\"1\"\n";
print " <tr><td bgcolor=\"$COLORSTABLE{ENDBLOCK}\" colspan=\"2\" align=\"center\"> <b>$action: Under Construction</b> </td></tr>\n";
print " <tr><td bgcolor=\"$COLORSTABLE{NOBLOCK}\"> plugin </td><td> $Cplugin </td></tr>\n";
print " <tr><td bgcolor=\"$COLORSTABLE{NOBLOCK}\"> help plugin filename </td><td> $ChelpPluginFilename </td></tr>\n";
print " <tr><td bgcolor=\"$COLORSTABLE{NOBLOCK}\"> todo </td><td> $Ctodo </td></tr>\n";
print " </table>\n";
print " </td></tr></table>\n";
} else {
print <<HTML;
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr align="center"><td>
<table border="0" cellspacing="0" cellpadding="0"><tr>
<td class="StatusItem"><a href="$urlWithAccessParameters&action=checkView&auto=0">[Check Configuration]</a></td>
<td class="StatusItem"> </td>
<td class="StatusItem"><a href="$urlWithAccessParameters&action=generateView&auto=0">[Generate Configuration]</a></td>
<td class="StatusItem"> </td>
<td class="StatusItem"><a href="$urlWithAccessParameters&action=compareView&auto=0">[Compare Configurations]</a></td>
<td class="StatusItem"> </td>
<td class="StatusItem"><a href="$urlWithAccessParameters&action=installView&auto=0">[Dry Run Generated Configuration]</a></td>
<td class="StatusItem"> </td>
<td class="StatusItem"><a href="$urlWithAccessParameters&action=installView&auto=1">[Install Generated Configuration]</a></td>
</tr></table>
</td></tr>
HTML
}
if ($action ne "menuView") {
print " <tr align=\"center\"><td>\n <table>\n";
if ($action eq 'checkView' or $action eq 'generateView') {
print " <tr align=\"center\"><td> </td></tr>\n <tr align=\"center\"><td>$matchingWarnings</td></tr>\n" if ($countWarnings);
print " <tr align=\"center\"><td> </td></tr>\n <tr align=\"center\"><td>$matchingErrors</td></tr>\n" if ($countErrors);
print " <tr align=\"center\"><td> </td></tr>\n <tr align=\"center\"><td>Warning: $countWarnings, Errors: $countErrors</td></tr>\n";
}
if ($action eq 'generateView') {
if ($countErrors == 0) {
print <<HTML;
<tr align="center"><td> </td></tr>
<tr align="center"><td>$initializeGenerateView</td></tr>
<tr align="center"><td> </td></tr>
<tr align="center"><td>$matchingArchiveCT</td></tr>
<tr align="center"><td> </td></tr>
<tr align="center"><td>$matchingDisplayCT</td></tr>
<tr align="center"><td> </td></tr>
( run in 1.120 second using v1.01-cache-2.11-cpan-ceb78f64989 )