Article View: news.software.nntp
Article #47297newspush (for INN)
From: Brad Knowles
Date: Mon, 10 Jul 2000 00:00
Date: Mon, 10 Jul 2000 00:00
155 lines
6420 bytes
6420 bytes
Folks,
I'm in the process of bringing up a new spool server, and I'm sure
that most of you will understand that I don't want to wait a month or
more for the spool on the new server to catch up to the old server.
So, I've taken a hint from an earlier article from Russ on this
topic, and I've expanded it somewhat into the script I call "newspush".
Basically, my script goes through the news spool directory of an INN
traditional spool server, and uses innxmit to push the articles over to
the new server.
However, it gives you some additional flexibility, and allows you to
specify hierarchies you do want, and hiearchies you do not want. For
example, you might want to push over all hierarchies beginning with a
"c", except for "comp.*" and "control.*". My script gives you the
ability to do that, with relatively little pain.
Keep in mind that this is not a particularly bright script, and
because of command-line argument length limitations, if for example you
were to try to feed over everything under "alt.*" but not
"alt.binaries.*", you probably would fail. You would instead have to
individually feed "alt.[0-9a]*" and then for "alt.b*", you could specify
"alt.binaries.*" as an exception.
I'm sure further improvements could be made, but one thing in
particular I was trying to avoid doing was searching hierarchies that
were going to get omitted anyway. My previous solution searched
everything under $SPOOLDIR/articles and then grep'ed for the stuff you
wanted, and grep'ed out the stuff you didn't. Trust me, you don't want
ten of these things running in parallel. ;-)
The current version just feeds your "wanted" arguments directly on
the command line to "find" as subdirectories you do want to search,
after picking out the subdirectories you may want omitted.
If you have any suggested improvements, they would be welcomed.
However, I am releasing this script because I will probably do this
process once and once only (the replacement server is based on Diablo
2.2-STABLE and dreaderd), so I won't be needing it again, and I don't
want to continue to support the code. Also note that it doesn't do you
any good if you've got a CNFS, timehash, or timecaf storage mechanism.
Observant readers will note that this is a BSD-style license. In
fact, it is shamelessly stolen from the FreeBSD web site, with the most
minimal of changes. ;-)
Enjoy!
#!/bin/sh
# Copyright (c) 2000 by Brad Knowles. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# 1. Redistributions of source code must retain the above
# copyright notice, this list of conditions and the following
# disclaimer.
#
# 2. Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials
# provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY BRAD KNOWLES ``AS IS'' AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#------------------------------------------------------------------------
# Author: Brad Knowles <brad@shub-internet.org>
# Date: Mon Jul 10 16:57:10 MET DST 2000
#------------------------------------------------------------------------
# NOTE: These definitions are highly specific to our site. You will need
# to change them, otherwise this program will not work.
PROG=`/usr/bin/basename $0`
TMPDIR="/usr/local/news/tmp"
TMPARTS="$TMPDIR/.$PROG.$$.articles"
TMPHIER="$TMPDIR/.$PROG.$$.hierarchies"
SPOOLDIR="/usr/local/news/spool"
NEWSERVER="recipient.news.spool.server.name.goes.here"
AWK="/usr/bin/awk"
ECHO="/usr/bin/echo"
EGREP="/usr/bin/egrep"
EXPR="/sbin/expr"
FIND="/sbin/find"
GREP="/sbin/grep"
HEAD="/usr/bin/head"
LSL="/sbin/ls -l"
RM="/sbin/rm"
SED="/usr/bin/sed"
SORT="/sbin/sort"
TAIL="/usr/bin/tail"
INNXMIT="/usr/local/news/bin/innxmit"
if [ -d $SPOOLDIR ] ; then
cd $SPOOLDIR
else
echo "$PROG: ERROR -- Cannot cd to $SPOOLDIR"
echo "Exiting..."
exit 1
fi
if [ "x$1" != "x" ] ; then
ARGS=`$ECHO $1`
shift
if [ $# -ge 1 ] ; then
while [ $# -ge 1 ]
do
ARGS=`$ECHO $ARGS | $SED "s|$1||g"`
shift
done
fi
else
ARGS="articles"
fi
$FIND $ARGS -type d -print | $SORT > $TMPHIER
MAXLINES=`/usr/bin/wc -l < $TMPHIER`
MAXLINES=`$EXPR $MAXLINES + 0`
CURR_LINE=1
while [ $CURR_LINE -le $MAXLINES ]
do
HIER=`$HEAD -$CURR_LINE $TMPHIER | $TAIL -1`
$FIND $HIER -type f -print > $TMPARTS
$INNXMIT $NEWSERVER $TMPARTS
CURR_LINE=`$EXPR $CURR_LINE + 1`
done
$RM -f $TMPHIER $TMPARTS
--
Brad Knowles <brad@shub-internet.org> <http://www.shub-internet.org/brad/>
Technical Details
Message-ID:
<brad-09C542.17010110072000@audrey.skynet.be>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mailShow Full Headers
Complete Article Headers
Message-ID: <brad-09C542.17010110072000@audrey.skynet.be> Subject: newspush (for INN) Date: Mon, 10 Jul 2000 00:00:00 +0000 From: Brad Knowles <brad@shub-internet.org> Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mail X-Deja-AN: 644627129 Mail-Copies-To: poster Posted-And-Mailed: yes X-Complaints-To: abuse@skynet.be Organization: Shub-Internet X-URL: http://www.shub-internet.org/ User-Agent: MT-NewsWatcher/3.0 (PPC) Newsgroups: news.software.nntp