[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[leafnode-list] Re: Setting fetchnews to only fetch, or only post, news.



[Message at bottom]

On Wed, 24 Jan 2007 10:14:55 -0500, "Nollaig MacKenzie"
<nollaig@xxxxxxxxxxxxxxxxx> said:
> 
> On 2007.01.24 13:58:59, you,
>  the extraordinary uni-dortmund@xxxxxxxxxxx, opined:
> 
> > Is it possible to set fetchnews to only fetch, or only post, news?
> > 
> > At the moment, my root user has this cronjob:
> > *\10 * * * * /usr/sbin/fetchnews -f >> /var/log/crontablog 2>&1
> > 
> > and what I'd love would be something like:
> > *\10 * * * * /usr/sbin/fetchnews -fetch >> /var/log/crontablog 2>&1
> > *\15 * * * * /usr/sbin/fetchnews -post >> /var/log/crontablog 2>&1
> > ...where the -f and -p denote fetch only and post only.
> > 
> > This would allow news to be fetched on one schedule but posted on a
> > different schedule.
> > There doesn't seem to be provision for this in the fetchnews manpage.
> > 
> > Any possibility of this?
> > =======================
> 
> [Mac OSX, leafnode 1.11.5]
> 
> 	fetchnews -P
> 
> will post but not fetch. I would guess that the author
> expected that users would want to get posts out on a
> faster schedule than that for regular downloading. 
> (Mine is post every 5 minutes, download every hour).
> 
> You could write a little script which moved articles
> out of '..../out.going', ran fetchnews, then moved the
> articles back to '..../out.going'.
> 

I had to go a little further to adjust the dates of the message to
reflect when they were posted, not when they were created.
If you're interested, I came up with the following:

1) Create directory /var/spool/news/leafnodeDelaySending
2) Create the following script at
~/Documents/systemWork/myScripts/leafnodeFetchOnly

#!/bin/sh
# This script is intended to run fetchnews but not send queued messages
from leaf
node.
# It moves the queued messages from /var/spool/news/out.going/ to
/var/spool/news
/leafnodeDelaySending
# then runs fetchmail, and then moves them back.
# The script is called from root's crontab at regular intervals.
# Toby Newman, http://www.asktoby.com
mv /var/spool/news/out.going/* /var/spool/news/leafnodeDelaySending
/usr/sbin/fetchnews
mv /var/spool/news/leafnodeDelaySending/* /var/spool/news/out.going/
# =EOF========================

3) Create the following script at
~/Documents/systemWork/myScripts/leafnodeFetchAndSend

#!/bin/sh
# This script is intended to run fetchnews to fetch and send news, but
modify the outgoing message
# dates to mirror the current system time.
# The script is called from root's crontab at regular intervals.
# Toby Newman, http://www.asktoby.com
# Make var equal to the current systemm date, formatted to slrn's style
of output.
var=$(date +"Date: %a, %d %b %G %k:%M:%S +0000")
# Scan all messages in /var/spool/news/out.going/, and replace all date
headers with 'var'.
# The -i switch edits in place. The '' indicates no backup is needed.
sed -i '' -e "s/Date: .* +0000/$var/" /var/spool/news/out.going/*
# Run fetchnews to fetch and post news.
/usr/sbin/fetchnews -v
# =EOF========================

4) Edit root's crontab to include these two lines:

# Fetchnews script which only fetches, not posts, every ten minutes
except for on the hour
10,20,30,40,50 * * * *
/home/user/Documents/systemWork/myScripts/leafnodeFetchOnly >>
/var/log/crontablog 2>&1

# Fetchnews which first modifies the stored-up files to match the
current system time before fetching and sending
0 7,14,20 * * *
/home/user/Documents/systemWork/myScripts/leafnodeFetchAndSend >>
/var/log/crontablog 2>&1

5) Comment out the following line in /etc/cron.d/leafnode
# 8 * * * *  news if [ -x /etc/news/leafnode/do-fetch-news ]; then
/etc/news/leafnode/do-fetch-news; fi

...and that's it.
HTH,
Toby
=======================

-- 
_______________________________________________
leafnode-list mailing list
leafnode-list@xxxxxxxxxxxxxxxxxxxxxxxxxxxx
https://www.dt.e-technik.uni-dortmund.de/mailman/listinfo/leafnode-list
http://leafnode.sourceforge.net/