#!/bin/sh
# @(#) $Id: renumber,v 1.2 1997/07/18 01:55:35 brister Exp $
# From Landon Curt Noll <chongo@toad.com>.
#
# renumber - renumber an existing active file

# preset vars
#
# =()<. @<_PATH_SHELLVARS>@>()=
. /var/news/etc/innshellvars

# verify that we have the findlow tool
#
if [ ! -f "$NEWSLBIN/findlow" ]; then
    echo "$0: cannot find findlow" 1>&2
    exit 1
fi

# form the lowmark file
#
LOWMARK="$TMPDIR/lowmark.$$"
trap "rm -f $LOWMARK; exit" 0 1 2 3 15
rm -f "$LOWMARK"
$PERL $NEWSLBIN/findlow > "$LOWMARK"
if [ ! -s "$LOWMARK" ]; then
    echo "$0: lowmark file: $LOWMARK is missing or empty" 1>&2
    exit 2
fi

# lock out news.daily and friends
#
if ${NEWSBIN}/shlock -p $$ -f ${LOCKS}/LOCK.news.daily ; then
    :
else
    echo "$0 Locked by `cat ${LOCKS}/LOCK.news.daily`" 1>&2
    exit 3
fi

# renumber
#
ctlinnd -s renumberlow "$LOWMARK"

# cleanup
#
rm -f "${LOCKS}/LOCK.news.daily" "$LOWMARK"

# all done
#
exit 0

