Difference between revisions of "Leafnode"

From SME Server
Jump to navigationJump to search
(First paste from old How To... needs wikifying!)
 
(Some wikifying)
Line 1: Line 1:
How to: Install Leafnode on SME 7.0
+
= 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.
 
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.
Line 7: Line 9:
 
But anyway to get you going:
 
But anyway to get you going:
  
1) Firstly get your Leafnode, I used leafnode-1.11.4-1.i486.rpm, 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 to install its files. The --nodeps is to stop rpm complaining about the lack of xinetd, SME7.0 does not use xinetd so this can be safely ignored.
+
'''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.
+
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.
+
'''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.
+
'''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:
+
'''4)''' Use your favourite editor to create the file '''run''' in the nntp directory with the contents:
  
#!/bin/sh
+
#!/bin/sh
exec 2>&1
+
exec 2>&1
# Generate ACL files in ./peers
+
# Generate ACL files in ./peers
./control/1
+
./control/1
exec /usr/local/bin/softlimit -m 10000000 \
+
exec /usr/local/bin/softlimit -m 10000000 \
 
         tcpsvd \
 
         tcpsvd \
 
         -v \
 
         -v \
Line 33: Line 39:
 
         /usr/sbin/leafnode
 
         /usr/sbin/leafnode
  
Save the file and make it executable for owner, group and others - chmod a+x run.
+
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.
+
'''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:
+
'''6)''' Change to the control directory and create a file named '''1''' with the contents:
  
#!/usr/bin/perl -w
+
#!/usr/bin/perl -w
use esmith::tcpsvd;
+
use esmith::tcpsvd;
esmith::tcpsvd::configure_peers('nntp');
+
esmith::tcpsvd::configure_peers('nntp');
  
Make the file 1 executable by all - chmod a+x 1.
+
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:
+
'''7)''' Change to the log directory and create a file named '''run''' with the contents:
  
#!/bin/sh
+
#!/bin/sh
exec                                   \
+
exec                                   \
 
     /usr/local/bin/setuidgid smelog    \
 
     /usr/local/bin/setuidgid smelog    \
 
     /usr/local/bin/multilog t s5000000  \
 
     /usr/local/bin/multilog t s5000000  \
 
     /var/log/nntp
 
     /var/log/nntp
  
Make the file run executable by all - chmod a+x run.
+
Make the file run executable by all - ''chmod a+x run''.
  
8) Make the directory /var/log/nntp - mkdir /var/log/nntp.
+
'''8)''' Make the directory /var/log/nntp - ''mkdir /var/log/nntp''.
Change ownership and group to smelog - chown smelog: /var/log/nntp.
+
Change ownership and group to smelog - ''chown smelog: /var/log/nntp''.
Remove permissions for others - chmod o-rwx /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).
+
'''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).
+
Remove all permissions from the file 0 - ''chmod 0 0'' (both zeros).
Set the file local to all/read - chmod a+r local.
+
Set the file local to all/read - ''chmod a+r local''.
 
These to files determine access rights when a connection request arrives.
 
These to files determine access rights when a connection request arrives.
  
10) Add nntp to the SME configuration database with the command:
+
'''10)''' Add nntp to the SME configuration database with the command:
  
config set nntp service status enabled TCPPort 119 access private
+
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.
 
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:
+
'''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";
+
  my $status = $nntp{status} || "disabled";
  return "# nntp service is set to disabled or is missing from the configuration database.\n"
+
  return "# nntp service is set to disabled or is missing from the configuration database.\n"
    unless ($status eq "enabled");
+
    unless ($status eq "enabled");
 
+
  $OUT .= "\n";
  $OUT .= "\n";
+
  $OUT .= "# Leafnode news server events\n";
  $OUT .= "# Leafnode news server events\n";
+
  $OUT .= "33\t4\t*\t*\t*\tnews\t/usr/sbin/texpire\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 .= "15\t*\t*\t*\t*\tnews\t/usr/sbin/fetchnews\n";
+
  $OUT .= "\n";
  $OUT .= "\n";
+
  # This will:
 
+
  # Expire the news database at 04:33 every day.
  # This will:
+
  # Download news at 15 minutes past every hour.
  # 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.
 
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.
+
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:
+
'''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
+
[root@testsrvr ]# svstat /service/nntp
/service/nntp: down 1676 seconds
+
/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.
+
'''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.
+
'''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:
+
'''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
+
[root@testsrvr ]# svstat /service/nntp
/service/nntp: up (pid 3064) 764 seconds, normally down
+
/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.
 
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:
 
Things I am not sure about:
 
Should the crontab template fragment be in templates or templates-custom?
 
  
 
Should the link to daemontools be in the init.d/supervise or init.d directory?
 
Should the link to daemontools be in the init.d/supervise or init.d directory?
 
Cheers Dave.
 
 
---
 
 
Good Howto :-) While it's a howto, the template fragments should be in 'templates-custom', if someone makes a smeserver-leafnode rpm, they would then be in 'templates'. I'm not sure about the other question. Please join the devinfo mailing list if you haven't already and announce your howto there, and ask the question. - This src.rpm might be a good one to work from if you were interested to make a smeserver-leafnode rpm - http://sme.dungog.net/packages/smeserver/7.0/i386/SRPMS.dungog/smeserver-dansguardian-1.2-4.src.rpm - Greg Swallow
 
 
---
 
 
2006-04-11 - Just used my own How To: to put Leafnode on my live server. Did produce a few points that were not correct or unclear. They are now. B-) DL.
 
 
---
 
 
2006-04-12 - Wondered why Leafnode has stopped working, wrong ownership/permissions on the /var/log/nntp directory. This How To: corrected. DL.
 
 
Owner: "allsorts" Last edited on April 12, 2006 11:37 am by "allsorts"
 

Revision as of 21:56, 27 April 2008

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?