[Fedora-directory-commits] ldapserver/ldap/admin/src/scripts template-dbverify.in, NONE, 1.1 template-verify-db.pl.in, 1.7, 1.8

Noriko Hosoi (nhosoi) fedora-directory-commits at redhat.com
Fri Sep 7 19:08:47 UTC 2007


Author: nhosoi

Update of /cvs/dirsec/ldapserver/ldap/admin/src/scripts
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv13862/ldap/admin/src/scripts

Modified Files:
	template-verify-db.pl.in 
Added Files:
	template-dbverify.in 
Log Message:
Resolves: #236256
Summary: verify-db.pl (db_verify) does not work on a little endian machine
(comment #1-#4)
Description: 1) introducing dbverify mode to ns-slapd.
2) providing new script dbverify to call "ns-slapd dbverify"
3) fixing verify-db.pl to call dbverify instead of db_verify from BDB



--- NEW FILE template-dbverify.in ---
#!/bin/sh

prefix="{{DS-ROOT}}"
if [ "$prefix" = "/" ] ; then
    prefix=""
fi
LD_LIBRARY_PATH=$prefix/{{SERVER-DIR}}:$prefix at nss_libdir@:$prefix at libdir@
if [ -n "$prefix" ] ; then
    LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:@nss_libdir@"
fi
export LD_LIBRARY_PATH
SHLIB_PATH=$LD_LIBRARY_PATH
export SHLIB_PATH

args=""
while [ "$1" != "" ]
do
    if [ "$1" = "-n" ]; then
        args=$args" "$1
        shift
        args=$args" "$1
    elif [ "$1" = "-V" ]; then
        args=$args" "$1
    else
        echo "Usage: dbverify [-n backend_instance] [-V]"
        echo "Note : if \"-n backend_instance\" is not passed, verify all DBs."
        echo "  -V : verbose"
        exit 1
    fi
    shift
done


cd {{SERVERBIN-DIR}}
./ns-slapd dbverify -D {{CONFIG-DIR}} $args
if [ $? -eq 0 ]; then
    echo "DB verify: Passed"
    exit 0
else
    echo "DB verify: Failed"
    exit 1
fi


Index: template-verify-db.pl.in
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/admin/src/scripts/template-verify-db.pl.in,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- template-verify-db.pl.in	21 Mar 2007 17:42:58 -0000	1.7
+++ template-verify-db.pl.in	7 Sep 2007 19:08:45 -0000	1.8
@@ -211,41 +211,48 @@
 }
 
 # Check db files by db_verify
-for (my $i = 0; "$$dbdirs[$i]" ne ""; $i++)
+print "Verify db files ... ";
+open(DBVERIFY, "dbverify $thisdb 2>&1 1> $NULL |");
+sleep 1;
+my $bad_index = 0;
+my $bad_id2entry = 0;
+my $isfirst = 1;
+while ($l = <DBVERIFY>)
 {
-  opendir(DB, $$dbdirs[$i]) or die "can't opendir $$dbdirs[$i] : $!";
-  while (defined($db = readdir(DB)))
-  {
-    if ($db =~ /\.db/)
+    if ($isfirst)
     {
-      my $thisdb = $$dbdirs[$i] . "/" . $db;
-      print "Verify $thisdb ... ";
-      open(DBVERIFY, "db_verify $thisdb 2>&1 1> $NULL |");
-      sleep 1;
-      my $haserr = 0;
-      while ($l = <DBVERIFY>)
-      {
-        if ($haserr == 0)
+        print "\n";
+        $isfirst = 0;
+    }
+    if ("$l" =~ /verify failed/)
+    {
+        if ("$l" =~ /id2entry.db/)
         {
-          print "\n";
+            $bad_id2entry++;
         }
-        if ("$l" ne "")
+        else
         {
-          $haserr++;
-          print "DB ERROR: $l";
+            $bad_index++;
         }
-      }
-      close(DBVERIFY);
-      if ($haserr == 0 && $? == 0)
-      {
-        print "Good\n";
-      }
-      else
-      {
-        print "db file $db in $$dbdirs[$i] is corrupted.\n";
-        print "Please restore your backup and recover the database.\n";
-      }
     }
-  }
-  closedir(DB);
+    print "$l";
+}
+close(DBVERIFY);
+
+if ($bad_id2entry > 0)
+{
+    print "\nFound the db was corrupted\n";
+    print "Please restore your backup and recover the database.\n";
+    exit(1);
+}
+elsif ($bad_index > 0)
+{
+    print "\nFound the index file(s) was corrupted\n";
+    print "Please run db2index on the corrupted index\n";
+    exit(1);
+}
+else
+{
+    print "Good\n";
+    exit(0);
 }




More information about the Fedora-directory-commits mailing list