This page was created from a guide on the Ubuntu Forums, where support is still available for this wiki page, and also draws heavily from a Slackware installation guide found here. Thanks to the author of both of these guides for his kind permission to use the material on this page!

What is leafnode-2?

Leafnode-2 is an NNTP proxy news server intended for small sites, where there are few users and little disk space, but where a large number of groups is desired. It can be used to give a regular newsreader off-line functionality as well as significantly enhancing Usenet experience for broadband users. There is also the significant advantage of being able to configure "local" newsgroups accessible only to your private network. Labelled as beta software the version used in this wiki page is perfectly stable and offers significan advantages over the versiojn of Leafnode found in the Ubuntu Repository.

Website: http://www.dt.e-technik.uni-dortmund.de/~ma/leafnode/beta/

Some Preparation

Leafnode-2 is a relatively complex piece of software to install and setup correctly, some preparation work is involved before installing the server itself itself:

Set a FQDN

The most correct setup of slrn requires your computer to have a Fully Qualified Domain Name (FQDN). A default Ubuntu setup will often not have this set and the setting in /etc/hosts will look something like this:

127.0.0.1       localhost
127.0.1.1       desktop

This should be altered to reflect your own unique FQDN. For this you have 3 good choices:

  1. If you own your own Domain Name use this in conjunction with a subdomain and the hostname of your computer.
  2. Use a service such as dyndns.org which will give you a domain name for free.

  3. Use the news service individual.net which will give you a free FQDN.

Once this is in place alter the /etc/hosts file to reflect the FQDN with the following syntax:

127.0.0.1       localhost
127.0.1.1       desktop.your.domain     desktop

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.

Install some 'dev 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 vim checkinstall

and then to download, compile and install Leafnode-2 itself:

Compile Leafnode-2

The following is a single command that will download, compile and install Leafnode-2:

mkdir -pv $HOME/leafnode_build && cd $HOME/leafnode_build && \
wget http://home.pages.de/~mandree/leafnode/beta/leafnode-2.0.0.alpha20110807a.tar.bz2 && \
tar xjvf leafnode-2.0.0.alpha20110807a.tar.bz2 && cd leafnode-2.0.0.alpha20110807a && \
./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 --pakdir $HOME/leafnode_build \
   --pkgname leafnode --backup=no --deldoc=yes --deldesc=yes --delspec=yes \ 
   --default --pkgversion "2.0.0.alpha20110807a"

As mentioned before this version of Leafnode-2 is perfectly stable despite its 'alpha' tag and has been running reliable on my own setup since its release.

Leafnode settings

Now to the more complex area of configuring Leafnode-2. 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 /etc/init.d/openbsd-inetd restart
$ telnet localhost 119

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

andrew@corinth:~$ telnet localhost 119
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
200 Leafnode NNTP daemon, version 2.0.0.alpha20110807a at corinth.andrews-corner.org

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 create a conf file:

$ sudo touch /etc/rsyslog.d/leafnode2.conf
$ sudo vim /etc/rsyslog.d/leafnode2.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/rsyslogd.pid`
$ sudo logrotate -dv /etc/logrotate.conf

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 your newsreader to read the spool

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

NNTPSERVER=localhost && export NNTPSERVER

and if you have the good taste to be using slrn you will add the following to your ~/.slrnrc file:

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

The configuration will be a little different with each NNTP client. And finally open newsreader 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!

External Links


CategorySoftware

Leafnode2 (last edited 2012-04-09 08:53:38 by 124-168-132-215)