Leafnode

From SME Server
Revision as of 22:56, 27 April 2008 by Allsorts (talk | contribs) (Some wikifying)
Jump to navigationJump to search

How to: Install Leafnode on SME 7

This How To... is based on one I wrote a couple of years back to install Leafnode as a service on SME 7.0rc1. I intend to bring it up to date for SME 7.3.


After much head scratching, web searching, reading of man pages and making silly mistakes leading me up blind alleys I've got Leafnode working on SME 7.0. Most of the contents of the control files have been "borrowed", with suitable changes, from other files within the SME system.

This How To: is what I did to produce the desired result on SME 7.0rc1. It may or may not be "best practice" with regards how SME likes to do things. If there are errors or better ways please point them out.

But anyway to get you going:

1) Firstly get your Leafnode, I used leafnode-1.11.4-1.i486.rpm, (leafnode-1.11.6-1.i486.rpm is the latest April 2008) the most recent of the version 1 series I could find. Pop that on to your SME Server somewhere and run:

rpm -ivh --nodeps leafnode-1.11.4-1.i486.rpm

The --nodeps is to stop rpm complaining about the lack of xinetd, SME 7 does not use xinetd so this can be safely ignored. Yum doesn't have a --nodeps option so until such time as an SME version of the rpm becomes available that doesn't require xinetd we can't use yum.

Follow the instructions in the well commented /etc/leafnode/config to configure Leafnode to your upstream news server and preferences. Don't forget to do a fetchnews -f to force a fetch of the newsgroups your upstream server(s) carry.

2) Change directory to /var/service and make a new directory nntp.

3) Change into the nntp directory and make the following directories control, log and peers.

4) Use your favourite editor to create the file run in the nntp directory with the contents:

#!/bin/sh
exec 2>&1
# Generate ACL files in ./peers
./control/1
exec /usr/local/bin/softlimit -m 10000000 \
       tcpsvd \
       -v \
       -i ./peers \
       -c ${CONCURRENCYREMOTE:-40} \
       -C ${PER_IP_INSTANCES:-4}:'421 per host concurrency limit reached\r\n' \
       -l ${LOCALNAME:-0} \
       -u news \
       ${LISTENIP:-0} \
       ${PORT:-nntp} \
       /usr/sbin/leafnode

Save the file and make it executable for owner, group and others - chmod a+x run.

5) Create a file called down in the nntp directory, no contents or special permissions. This file stops the runsvdir system starting the service automatically, so it has to be started via the SME process startup method, which takes into account the status setting of nntp in the configuration database.

6) Change to the control directory and create a file named 1 with the contents:

#!/usr/bin/perl -w
use esmith::tcpsvd;
esmith::tcpsvd::configure_peers('nntp');

Make the file 1 executable by all - chmod a+x 1.

7) Change to the log directory and create a file named run with the contents:

#!/bin/sh
exec                                   \
   /usr/local/bin/setuidgid smelog     \
   /usr/local/bin/multilog t s5000000  \
   /var/log/nntp

Make the file run executable by all - chmod a+x run.

8) Make the directory /var/log/nntp - mkdir /var/log/nntp. Change ownership and group to smelog - chown smelog: /var/log/nntp. Remove permissions for others - chmod o-rwx /var/log/nntp.

9) Change to the peers directory and create two empty files local and 0 (that's zero). Remove all permissions from the file 0 - chmod 0 0 (both zeros). Set the file local to all/read - chmod a+r local. These to files determine access rights when a connection request arrives.

10) Add nntp to the SME configuration database with the command:

config set nntp service status enabled TCPPort 119 access private

I'm not sure if the last two properties (TCPPort and access) are required by the internals of SME that I haven't investigated. I have simply included them for completness, most other services in the database have them.

11) Now to automate news downloads and the house keeping. Make the directory tree /etc/e-smith/templates-custom/etc/crontab - mkdir /etc/e-smith/templates-custom/etc/crontab and change to that directory. Use your editor to create the file nntp with contents:

{
  my $status = $nntp{status} || "disabled";
  return "# nntp service is set to disabled or is missing from the configuration database.\n"
    unless ($status eq "enabled");
  $OUT .= "\n";
  $OUT .= "# Leafnode news server events\n";
  $OUT .= "33\t4\t*\t*\t*\tnews\t/usr/sbin/texpire\n";
  $OUT .= "15\t*\t*\t*\t*\tnews\t/usr/sbin/fetchnews\n";
  $OUT .= "\n";
  # This will:
  # Expire the news database at 04:33 every day.
  # Download news at 15 minutes past every hour.
}

Watch the line wrap on the "return "# nntp..." line, it should be all one line.

Expand the template expand-template /etc/crontab and check that /etc/crontab has the correct entries for running texpire and fetchnews. Cron will pick up the changes automatically.

12) Create a symlink in /service to /var/service/nntp - ln -s /var/service/nntp /service/nntp. Within 5 seconds the nntp process should be started. Try svstat /service/nntp and you should get a line giving you the status of nntp, some thing similar to:

[root@testsrvr ]# svstat /service/nntp
/service/nntp: down 1676 seconds

13) Now to configure the SME boot process to start Leafnode on boot up. Change to the directory /etc/rc.d/rc7.d. Create a symlink from /etc/rc.d/rc7.d/S90nntp to /etc/rc.d/init.d/e-smith-service - ln -s /etc/rc.d/init.d/e-smith-service /etc/rc.d/rc7.d/S90nntp. This ensures that nntp is not started unless it is enabled in the SME configuration database.

14) Change to /etc/rc.d/init.d/supervise and make a symlink from /etc/rc.d/init.d/supervise/nntp to ../daemontools - ln -s ../daemontools /etc/rc.d/init.d/supervise/nntp.

15) Issue a signal-event reboot command and when the server comes back up leafnode should be running, login and check with svstat again:

[root@testsrvr ]# svstat /service/nntp
/service/nntp: up (pid 3064) 764 seconds, normally down

CONGRATULATIONS You now have a working Leafnode on your SME Server and news clients within your network should be able to connect to it for their news feed. Things I am not sure about:

Should the link to daemontools be in the init.d/supervise or init.d directory?