Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!ut-sally!husc6!think!ames!xanth!john From: john@xanth.UUCP (John Owens) Newsgroups: news.admin Subject: Fixing up your news system (handy script) Message-ID: <1603@xanth.UUCP> Date: Mon, 20-Jul-87 21:31:06 EDT Article-I.D.: xanth.1603 Posted: Mon Jul 20 21:31:06 1987 Date-Received: Thu, 23-Jul-87 04:52:18 EDT Organization: Old Dominion University, Norfolk Va. Lines: 58 Keywords: active Late last week, our system crashed, destroying /usr but leaving the news filesystem intact. We recovered /usr from a few days earlier, but the history and active files didn't reflect the current articles. Fixing the history file was easy with expire -r, but there was no good way to fix the active file. (Posting and cancelling a local article to all newsgroups was a bit ridiculous.) So, here's a script I cooked up, along with a C program to lock the active file while you work on it. (Run "flockex active", then suspend the job (BSD) or run it in the background or on another terminal (SysV). To unlock the file, kill the process.) Hope it helps someone out there! #!/bin/sh # This is a shell archive. # Run the file through sh to extract its contents. # shar: Shell Archiver # Run the following text with /bin/sh to create: # fixactive.sh # flockex.c # This archive created: Mon Jul 20 21:29:57 1987 cat << \SHAR_EOF > fixactive.sh : fix active file - a throwaway, but keep it anyway cp active active.prefix ; : no pun intended while read line ; do set $line : cannot nest backquotes dir=` echo $1 | sed 's/\./\//g' ` : was '[0-9]*', but need numerical order.... last=` (cd /news/$dir ; echo [0-9] [0-9][0-9] [0-9][0-9][0-9] [0-9][0-9][0-9][0-9] [0-9][0-9][0-9][0-9][0-9]) 2>/dev/null | sed 's/\[[][09-]*\]//g' | sed 's/.* \([0-9][0-9]*\) *$/\1/' ` case $last in [0-9][0-9]*) new=`echo $last | awk '{ printf("%05d",$1) }' ` echo $1 $new $3 $4 ;; *) echo $line ;; esac done < active.prefix > active SHAR_EOF cat << \SHAR_EOF > flockex.c #includemain(argc,argv) char **argv; { printf("%s: %d\n",argv[1],flock(open(argv[1],0), LOCK_EX)); pause(); } SHAR_EOF # End of shell archive exit 0 -- John Owens Old Dominion University - Norfolk, Virginia, USA john@ODU.EDU old arpa: john%odu.edu@RELAY.CS.NET +1 804 440 4529 old uucp: {decuac,harvard,hoptoad,mcnc}!xanth!john