Changeset 852 for branches


Ignore:
Timestamp:
Feb 19, 2014, 6:26:31 PM (11 years ago)
Author:
Herwig Bauernfeind
Message:

chktdb 1.2: Try to restore defective TDB and show cause of error

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/scripts/server/chktdb.cmd

    r779 r852  
    1 /*
    2 
    3   Samba Server for eComStation (OS/2) tools
    4  
    5   (c) 2013 Herwig Bauernfeind for bww bitwise works GmbH.
    6   Script:  ChkTDB.CMD, requires REXX and tdbtool.exe from Samba 3.3 or better.
    7   Purpose: Test the integrity of all TDB files in the current diectory.
    8            In case a TDB file fails the integrity check the resulting
    9            logfile is preserved and carries a name of xxx.tdb.err
    10   Syntax:  No parameters.
    11  
    12  */
    13 
    14 call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
    15 call SysLoadFuncs
     1/* Test all Samba TDB files for integrity
     2   Version 1.2 (c) 2013 by Herwig Bauernfeind
     3   for bww bitwiseworks GmbH. */
    164
    175ok = SysFileTree("*.TDB",tdb.,'FO')
    186
     7error = 0
     8
    199do I = 1 to tdb.0
    20     call charout , left(filespec('N',tdb.I), 24)
     10    call charout , left(filespec('N',tdb.I), 22)
    2111    address cmd '@tdbtool 'tdb.I' check 2>'tdb.I'.err 1>'tdb.I'.out'
    2212    out = linein(tdb.I'.out')
    2313    ok = stream(tdb.I'.out','c','close')
    2414    say out
    25     if pos('integrity is OK',out) = 0 then call beep 880, 20
     15    if pos('integrity is OK',out) = 0 then do
     16        call beep 880, 20
     17        address cmd '@tdbbackup -s.bak -v 'tdb.I' 2>NUL 1>NUL'
     18        error = 1
     19        do while lines(tdb.I'.err') > 0
     20            errline = linein(tdb.I'.err')
     21            select
     22                /* skip unnecessary lines of log */
     23                when pos("bww ",errline) > 0 then iterate
     24                when pos("fcntl",errline) > 0 then iterate
     25                otherwise say copies(' ',22)'Cause: 'errline'!'
     26            end
     27        end
     28        ok = stream(tdb.I'.err','c','close')
     29    end
    2630    else do
    2731        ok = SysFileDelete(tdb.I'.err')
    2832        ok = SysFileDelete(tdb.I'.out')
     33        address cmd '@tdbbackup -s.bak 'tdb.I' 2>NUL 1>NUL'
    2934    end
    3035end
Note: See TracChangeset for help on using the changeset viewer.