;/* uucp:c/RebuildHistory, (c) 1993 by Gerald Malitz <gm@germal.escape.de> */
;/* uucp:c/RebuildHistory, chngs (c) 1993 Kai 'wusel' Siering <wusel@hactar.hanse.de> */

; Versuch, das Newssystem zu locken; ist etwas trickreich, da mein
; LockFile-Programm arg blöd ist -- daher erst der Versuch, im Script
; sicherzustellen, daß relaynews grade nicht läuft, bevor das umbenannte
; LockFile gestartet wird. -wusel

copy `which LockFile` t:LockCNews clone

failat 20
lab loop
   echo >t:LockedCNews "RebuildHistory"
   if $RC not eq 0
      skip lab loop back
   endif

failat 10
run t:LockCNews LockedCNews

; Die Funktion des P-Parameters hat sich irgendwann geändert.
; 37.5 ist nur ein Tip von mir, also vorher austesten!

Version >nil: c:list 37 5
If WARN
        C:List UUNEWS: FILES ALL P #?/[1-9]#[0-9] LFORMAT %p%n TO t:rh1.$process
Else
        C:List UUNEWS: FILES ALL P [1-9]#[0-9] LFORMAT %p%n TO t:rh1.$process
EndIf

copy uulib:news/history uulib:news/history.old clone
rx <t:rh1.$process >t:rh2.$process rh.pass1.rexx
sort t:rh2.$process t:rh3.$process
delete t:rh1.$process t:rh2.$process >nil:
rx <t:rh3.$process >uulib:news/history rh.pass2.rexx
mkdbm uulib:news/history

;history.pag ist jetzt wahrscheinlich noch riesengroß.
;Mit dem nächsten expire sollte sich das bessern.

break `status com=t:LockCNews` all
delete t:rh3.$process#? >nil:
delete t:LockCNews >nil:
