PDA

View Full Version : [Howto] Setup and use Leafnode-2 with the newsreader slrn


andrew.46
January 24th, 2008, 09:02 AM
======================
Introduction
======================

This 'Howto' aims to show how to use the amazing NNTP proxy server Leafnode-2 with your copy of John E Davis' slrn. If you do not have slrn running already I suggest you spend some time with my other Ubuntu Forums 'HowTo': HOWTO: Setup slrn, the CLI newsreader (http://ubuntuforums.org/showthread.php?t=475246). Leafnode-2 can be used by any newsreader that can utilise a local news spool so this guide can also be used in conjunction with other news clients. I concentrate mostly on slrn as this is the newsreader I am most familiar with :-).

First some preparation work:

====================
Set a FQDN
====================

For the best setup you should have an unique Fully Qualified Domain Name (FQDN) set to your system. Check this with the following command:
$ hostname --fqdn

If this is not set you will need to alter your /etc/hosts file to reflect your FQDN. The default Ubuntu /etc/hosts file tends to look something like this:

127.0.0.1 localhost
127.0.1.1 desktop

Alter this to something like:

127.0.0.1 localhost
127.0.1.1 desktop.your.domain desktop

(Thanks to PJR for the information above). For your own, unique FQDN you have 3 good choices:


If you own your own Domain Name use this in conjunction with a subdomain and the hostname of your computer.
Use a service such as dyndns.org (http://www.dyndns.com/services/dns/dyndns/) which will give you a domain name for free.
Use the news service individual.net (http://www.individual.net/faq.php#4.4) which will give you a free FQDN.


I suggest you burrow into the Leafnode-2 source code that we will download shortly and read the excellent document: README-FQDN.html. This speaks of the FQDN in much greater detail. A word of warning: an incorrect or false FQDN might expose you to merciless flaming so spend a little time getting this set correctly :-).

But now to start installing the program:

======================
Install some Files
======================

First some development files are required from the Ubuntu repositories. Leafnode-2 depends on the PCRE regular-expression matching library, as well some compiling tools are needed plus checkinstall and an inetd package:

$ sudo apt-get install libpcre3 libpcre3-dev openbsd-inetd build-essential checkinstall

Now to download and extract the source for Leafnode-2 from the home page:

$ cd $HOME/Desktop
$ wget http://home.pages.de/~mandree/leafnode/beta/leafnode-2.0.0.alpha20081229a.tar.bz2
$ tar xjvf leafnode-2.0.0.alpha20081229a.tar.bz2
$ cd leafnode-2.0.0.alpha20081229a

The ./configure options that I have given here are designed to make final configuration of this program a little easier so can I suggest you compile exactly as follows:

$ ./configure --prefix=/usr \
--sysconfdir=/etc/leafnode \
--mandir=/usr/man \
--localstatedir=/var \
--enable-runas-user=news \
--enable-spooldir=/var/spool/news
$ make
$ sudo checkinstall -D --install=yes --fstrans=no

That was the easy part, now for some configuration:

======================
Some Leafnode Settings
======================

There is a sample config file that Leafnode-2 installs as /etc/leafnode/config.example and unless you already have a configuration file you will need to do the following:

$ sudo touch /etc/leafnode/local.groups
$ sudo cp /etc/leafnode/config.example /etc/leafnode/config
$ sudo vim /etc/leafnode/config

and at the very least add the following settings, you will see the relevant sections in the second half of the file:

server = your.news.server
username = your.username
password = your.password

I would also suggest the following which sets how many articles to initially download when sunscribing to a new group, this will save you downloading many 1,000s of messages when you first log in:

initialfetch = 500

If you wish to selectively download more messages to fill the Leafnode-2 cache at a later stage there is always the option of running a command such as:

$ sudo fetchnews -vvv -N alt.os.linux.ubuntu -x 2000

which will look at the last 2,000 messages posted on this newsgroup and fill the Leafnode-2 cache with whatever is missing. There are many other options to tweak here but these ones are essential. Now to set the server:

======================
Setting the server
======================

The following steps set the NNTP proxy server. Open the file inetd.conf as follows:

$ sudo vim /etc/inetd.conf

First check that there are no lines starting with nntp and if they exist you will need to comment them out by adding a # mark at the beginning of the line. Then add the following line using keyboard 'TAB' for the spaces:

nntp stream tcp nowait news /usr/sbin/tcpd /usr/sbin/leafnode

To safe-guard you computer you will also need to add the following lines, firstly to the file /etc/hosts.allow:

#-- leafnode begin
leafnode: 127.0.0.1
#-- leafnode end

and secondly to /etc/hosts.deny:

#-- leafnode begin
leafnode: ALL
#-- leafnode end

With this hopefully all in place we can now test the server by forcing a restart and then running telnet on the NNTP server:

$ sudo kill -HUP `cat /var/run/inetd.pid`
$ telnet localhost 119

If all is well you will see something very similar to the following:

andrew@ilium:~$ telnet localhost 119
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
200 Leafnode NNTP daemon, version 2.0.0.alpha20070602a at <domain>

Type 'quit' to exit and your server is ready to go. Now to set the programs Fetchnews and Texpire running:

======================
Fetchnews & Texpire
======================

Fetchnews transports news to and from Leafnode-2 while Texpire cleans out old messages. There are many ways to set these running but I will demonstrate a method using crontab that sets Fetchnews to run every hour at 15 past the hour and runs Texpire at 2145 every night. Open or create the news crontab as follows:

$ sudo crontab -u news -e

and add the following settings:

# Sets texpire to clean out news at 2145hrs every day:
45 21 * * * /usr/sbin/texpire 1>/dev/null
# Sets fetchnews to run at 15 past every hour:
15 * * * * /usr/sbin/fetchnews 1>/dev/null

These are fairly conservative settings and many people set Fetchnews running much more often that every hour and Texpire perhaps a little less frequently. Experiment a little until you find settings that agree with your Usenet habits. Check your settings after every change as follows:

$ sudo crontab -u news -l

With Fetchnews and Texpire set it is time to organise logging for Leafnode-2:

======================
Logging for Leafnode
======================

It is a good idea to set some logging for Leafnode and we will be doing this by tapping into Linux system logging. Before doing this there is a small amount of bug-work to do: if you have had a previous version of Leafnode installed there may be a residual configuration file that must be removed:

$ sudo mv -v /etc/logrotate.d/leafnode $HOME/Desktop/leafnode_bak

This file interferes with the following log settings and must be removed, not simply renamed. Now to set the required directory structure and files:

$ sudo mkdir -pv /var/log/news/oldnews
$ sudo touch /var/log/news/news.info
$ sudo touch /var/log/news/news.crit
$ sudo touch /var/log/news/news.err
$ sudo touch /var/log/news/news.notice

With the directory and file structure in place now open syslog.conf:

$ sudo vim /etc/syslog.conf

and add the following settings, making sure that there are 'TAB' spaces (using your keyboard) separating the file from the path:

news.=crit -/var/log/news/news.crit
news.=err -/var/log/news/news.err
news.notice -/var/log/news/news.notice
news.info -/var/log/news/news.info

And finally we set the program logrotate to rotate the files daily for 7 days and then delete them, saving and compressing the old logs to /var/log/news/oldnews. First open the file logrotate.conf:

$ sudo vim /etc/logrotate.conf

and add the following settings:

/var/log/news/* {
daily
rotate 7
olddir /var/log/news/oldnews
missingok
postrotate
kill -1 `cat /var/run/syslogd.pid`
endscript
compress
}

It is best to test all these setting before proceding and this can be done as follows. The first command 'resets' system logging and the second command performs a 'dry run' logrotate without actually changing anything:

$ sudo kill -1 `cat /var/run/syslogd.pid`
$ sudo logrotate -dv /etc/logrotate.conf

It may seem a little complex but this provides a very detailed logging for Leafnode-2 that is perfect for troubleshooting. But now finally to actually run the program:

======================
Running the program
======================

First run fetchnews from the command line with the following parameters:

$ sudo fetchnews -vvv

This may take a while. When it has finished run:

$ sudo texpire -vvv

And now the spool is setup for use with slrn, or the news client of your choice.

==============================
Set slrn to read the spool
=============================

There are really only 2 extra steps required to get slrn talking with Leafnode-2. Enter the following into ~/.bashrc:

NNTPSERVER=localhost && export NNTPSERVER

You might consider using a different newsrc file with your local host, in which case you would later the following line in your ~/.slrnrc file:

% Tell slrn which newsrc file it should use for which server.
server "localhost" ".jnewsrc"

And finally open slrn and select the groups you want to subscribe to. You will find these groups empty except a default Leafnode-2 article. For example:

Leafnode placeholder for group alt.os.linux.ubuntu

You will need to mark this article as read, close slrn, run Fetchnews again and then you are in business!

======================
In conclusion...
======================

A big 'Thank you' to Gary Knight whose page Using Leafnode as a caching news proxy (http://homepage.ntlworld.com/garryknight/linux/leafnode.html) provided a huge amount of information for this page. And a special thanks again to PJR, always my most helpful critic, and all those from news.software.readers who proffered advice.

April 7th, 2009.
Andrew Strong

Mary.Riley
February 3rd, 2008, 07:34 PM
That's super useful. Thank you for the tutorial.

andrew.46
February 3rd, 2008, 09:16 PM
Hi Mary:

That's super useful. Thank you for the tutorial.

It is my pleasure! I hope you enjoy this amazing sodtware. A fellow australian has produced a nice macro that places an 'X-NNTP-Proxy'' (leafnode 2' header in slrn which may interest you:

http://piggo.com/~troy/slrn#custom

He does not give the full syntax on the page, which is:


define post_hook ()
{
set_string_variable ( "custom_headers",
sprintf ("Message-ID: <%s>\nX-NNTP-Proxy: Leafnode-2 (http://www-dt.e-technik.uni-dortmund.de/~ma/leafnode/beta/)", create_msg_id ()));
}

define followup_hook()
{
set_string_variable ( "followup_custom_headers",
sprintf ("Message-ID: <%s>\nX-NNTP-Proxy: Leafnode-2 (http://www-dt.e-technik.uni-dortmund.de/~ma/leafnode/beta/)", create_msg_id ()));
}

define reply_hook()
{
set_string_variable ( "reply_custom_headers",
sprintf ("Message-ID: <%s>\nX-NNTP-Proxy: Leafnode-2 (http://www-dt.e-technik.uni-dortmund.de/~ma/leafnode/beta/)", create_msg_id ()));
}




All the very best,

Andrew

PS My apologies for giving mangled syntax in the initial post, I have corrected it.

andrew.46
April 7th, 2009, 12:45 AM
Hi,

I have updated the guide to the most stable, recent version of Leafnode-2 and I suspect I shall leave the guide to slumber quietly now. There has been little interest in the guide, which is a great pity as Leafnode-2 is a fantastic piece of software and once setup no trouble to administer.

I will be available for questions but in the meantime slumber on my least utilised guide :-).

All the best,

Andrew

alipensen
May 19th, 2009, 12:54 PM
Thanks very much for the update on the guide.
wow gold (http://www.wowgold.net/)
Just to let you know; it's still appreciated, even if not the most popular!

andrew.46
May 19th, 2009, 06:42 PM
Hi alipensen,

Thanks very much for the update on the guide.
wow gold (http://www.wowgold.net/)
Just to let you know; it's still appreciated, even if not the most popular!

Thanks for your kind words, I do plan on at the very least testing the guide under Karmic Koala and ensuring that it works there. But thanks again or a little encouragement :-).

Andrew

kevinguillorytraining
October 9th, 2009, 01:28 PM
Thanks for a nice how-to.

andrew.46
October 9th, 2009, 06:50 PM
Hi kevin,

Thanks for a nice how-to.

My pleasure! Good to see that this guide is still being used, as I promised above I intend polishing it a little with the release of Karmic Koala which is only a few weeks away now...

All the best,

Andrew

andrew.46
October 27th, 2009, 03:08 AM
Hmmm.... unfortunately this version of leafnode-2 does not compile under Karmic Koala. I shall investigate..... Looks like the latest version fails as well, I have posted to leafnode-list (http://www.dt.e-technik.uni-dortmund.de/pipermail/leafnode-list/2009q4/002180.html).

Andrew

orphean
November 23rd, 2009, 02:03 AM
I managed to get leafnode up and running easily enough with the leafnode in the official universe repository. It seems to work fine so far, I was curious what benefit your procedure gives? :)

andrew.46
November 23rd, 2009, 02:51 AM
Hi orphean,

I managed to get leafnode up and running easily enough with the leafnode in the official universe repository. It seems to work fine so far, I was curious what benefit your procedure gives? :)

The repository leafnode is the stable version, sometimes known as leafnode 1, while this guide deals with the development version known as leafnode 2. To tell the truth if you are happy enough with the repository version I would advise you to stick with it. In particular 2009 has been a turbulent year for Leafnode 2 with some big changes (lua scripting) which still have not settled in vey well.

Andrew

orphean
November 23rd, 2009, 04:33 AM
Ahh. Sounds like something I should read up on since leafnode 1 is a seriously slick piece of software and it sounds like the new version is getting more bells and whistles. Thank you for putting up this guide so I can play with the new version (probably in a vm if it is as turbulent as you say.)

And just to editorialize for a bit, any readers of this thread who are wondering if they should do this: yes, you should! USENET is still a great resource where you can get connected with highly clued in people (as well as a... colorful cast of other folk at times).

If your ISP no longer provides USENET access you can get free, text-only (which is all you need really unless you are into copyright infringement or pornography), USENET access from sites like eternal-september.org so you really have nothing to lose to check it out.

Anyway, back to the thread proper.

andrew.46
November 23rd, 2009, 04:45 AM
Hi orphean,

Thank you for putting up this guide so I can play with the new version (probably in a vm if it is as turbulent as you say.)

Don't forget there is a small compilation problem under Karmic that requires a patch (http://www.dt.e-technik.uni-dortmund.de/pipermail/leafnode-list/2009q4/002181.html) that will hopefully be rolled into the next release. BTW can I ask what newsreader you are using with leafnode?

Andrew