head	1.1;
access;
symbols;
locks
	news:1.1; strict;
comment	@# @;


1.1
date	97.03.02.03.14.09;	author news;	state Exp;
branches;
next	;


desc
@@


1.1
log
@Initial revision
@
text
@#! /bin/sh
# $Id$
# Trim current pathlog and restart new log for inpaths report.

# The current pathlog is saved on ${PATHLOG_ROOT}/OLD/pathlog.${NUM}.gz
# where ${NUM} is a two-digit number, indicating today.

# Possible interference with other programs:

# 1. innd/pathgrep: The logfile may be opened by "pathgrep".
#    Tell pathgrep to use new logfile.  It can be
#    % mv $PATH_LOG ${PATH_LOG}.old
#    % ctlinnd flush !path

# 2. inpaths: inpaths may be running. ---> don't care

. /usr/local/news/lib/innshellvars

#  Constants
# site name of pathgrep in newsfeeds file
SITE="path!"

# pathlog file name on which pathgrep is writing.
PATHLOG=/usr/local/news/spool/path.log/pathlog

# directory where old pathlogs will be archived.
ARCHIVES=/usr/local/news/spool/path.log/OLD

# make two-digit date number of today.
DATENUM=`date '+%d'`

# Other variables defined by innshellvars
# $Z, $COMPRESS

PROGRAM=trimpathlog
NEWLOG=${ARCHIVES}/pathlog.${DATENUM}${Z}

#echo current_log $PATHLOG
#echo archive_log $NEWLOG

# Is there pathlog file to renew?
if [ ! -f $PATHLOG ] ; then
    echo "${PROGRAM}: can't find $PATHLOG"
    exit 1
fi

# make sure OLD directory is existing.
if [ ! -d $ARCHIVES ] ; then
    mkdir $ARCHIVES
    if [ ! -d $ARCHIVES ] ; then
	echo "can't create $ARCHIVES"
	exit 1
    fi
fi

# tell innd/pathgrep to use new pathlog file
TMP=${PATHLOG}.tmp
mv $PATHLOG $TMP

ctlinnd -s flush ${SITE} 2>&1 || {
    echo "Cannot flush ${SITE}."
    exit 1
}

# archive the file
cat $TMP | ${COMPRESS} > $NEWLOG
rm -f $TMP
exit 0
@
