]> git.donarmstrong.com Git - infobot.git/commitdiff
- basically fix up openDB to allow unix sockets. -lear.
authordms <dms@c11ca15a-4712-0410-83d8-924469b57eb5>
Sun, 14 Oct 2001 13:03:14 +0000 (13:03 +0000)
committerdms <dms@c11ca15a-4712-0410-83d8-924469b57eb5>
Sun, 14 Oct 2001 13:03:14 +0000 (13:03 +0000)
- forgot fixDist for one DebianDownload line.

git-svn-id: https://svn.code.sf.net/p/infobot/code/trunk/blootbot@524 c11ca15a-4712-0410-83d8-924469b57eb5

src/Modules/Debian.pl
src/db_mysql.pl
src/db_pgsql.pl

index bbe28476cf4aa5c97d46d30611f26766e2d2f3eb..1c438fc968a1dfe90a3e7754a4de1233e973525e 100644 (file)
@@ -871,7 +871,7 @@ sub generateIndex {
        }
 
        &::DEBUG("deb: gIndex: calling DebianDownload($dist, ...).");
-       &DebianDownload($dist, %urlpackages);
+       &DebianDownload($dist, &fixDist($dist, %urlpackages) );
 
        &::status("Debian: generating index for '$dist'.");
        if (!open(OUT,">$idx")) {
index 1b3f3dc617a23ecaaf09fe970302d11ec0c556d3..266dd69f07eb534f4209f20309d8165054e0e6cd 100644 (file)
@@ -9,20 +9,29 @@ package main;
 
 if (&IsParam("useStrict")) { use strict; }
 
+#####
+# &openDB($dbname, $sqluser, $sqlpass, $nofail);
 sub openDB {
-    my ($db, $user, $pass) = @_;
-    my $dsn = "DBI:mysql:$db:$param{'SQLHost'}";
+    my ($db, $user, $pass, $no_fail) = @_;
+    my $dsn = "DBI:mysql:$db";
+    my $hoststr = "";
+    if (exists $param{'SQLHost'} and $param{'SQLHost'}) {
+       $dsn    .= ":$param{SQLHost}";
+       $hoststr = " to $param{'SQLHost'}";
+    }
     $dbh    = DBI->connect($dsn, $user, $pass);
 
     if ($dbh) {
-       &status("Opened MySQL connection to $param{'SQLHost'}");
+       &status("Opened MySQL connection$hoststr");
     } else {
-       &ERROR("cannot connect to $param{'SQLHost'}.");
+       &ERROR("cannot connect$hoststr.");
        &ERROR("since mysql is not available, shutting down bot!");
        &closePID();
        &closeSHM($shm);
        &closeLog();
 
+       return if ($no_fail);
+
        exit 1;
     }
 }
@@ -30,7 +39,10 @@ sub openDB {
 sub closeDB {
     return 0 unless ($dbh);
 
-    &status("Closed MySQL connection to $param{'SQLHost'}.");
+    my $hoststr = "";
+    $hoststr = " to $param{'SQLHost'}" if (exists $param{'SQLHost'});
+
+    &status("Closed MySQL connection$hoststr.");
     $dbh->disconnect();
 
     return 1;
index 7d025f9547401bdd891669fe6ea78d31362becbc..f7d91ae3016c69ae02e699ae58c636c33c6fb541 100644 (file)
@@ -7,22 +7,30 @@
 
 if (&IsParam("useStrict")) { use strict; }
 
+#####
+# openDB($dbname, $sqluser, $sqlpass, $nofail);
 sub openDB {
-    my $connectstr="dbi:Pg:dbname=$param{DBName};";
-    $connectstr.=";host=$param{SQLHost}" if(defined $param{'SQLHost'});
-    $dbh = DBI->connect($connectstr, $param{'SQLUser'}, $param{'SQLPass'});
+    my($dbname, $sqluser, $sqlpass, $nofail) = @_;
+    my $connectstr = "dbi:Pg:dbname=$dbname;";
+    my $hoststr           = "";
+    if (exists $param{'SQLHost'} and $param{'SQLHost'}) {
+       $hoststr     = " to $param{'SQLHost'}";
+       $connectstr .= ";host=$param{SQLHost}";
+    }
+    $dbh = DBI->connect($connectstr, $sqluser, $sqlpass);
 
-    if (!$dbh->err) {
-       &status("Opened pgSQL connection".
-               (exists $param{'SQLHost'} ? " to ".$param{'SQLHost'} : ""));
+    if ($dbh and !$dbh->err) {
+       &status("Opened pgSQL connection$hoststr");
     } else {
-       &ERROR("cannot connect to $param{'SQLHost'}.");
-       &ERROR("pgSQL: ".$dbh->errstr);
+       &ERROR("cannot connect$hoststr.");
+       &ERROR("pgSQL: ".$dbh->errstr) if ($dbh);
 
        &closePID();
        &closeSHM($shm);
        &closeLog();
 
+       return 0 if ($nofail);
+
        exit 1;
     }
 }