Difference between revisions of "Leafnode"

From SME Server
Jump to navigationJump to search
(First paste from old How To... needs wikifying!)
 
m (Some common formating done, more work required...)
 
(6 intermediate revisions by the same user not shown)
Line 1: Line 1:
How to: Install Leafnode on SME 7.0
+
= How to: Install Leafnode on SME 7 =
  
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.
+
Leafnode is a usenet news server for small networks. This How To: is what I did to get it running as a service under SME 7.3 and is based on orginal installation done 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 feel free to edit this wiki.
  
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.
+
== Here we go: ==
  
But anyway to get you going:
+
<ol></li><li>Firstly get your Leafnode, I used leafnode-1.11.6-1.i486.rpm the latest in April 2008 and the most recent of the version 1 series I could find. Pop that on to your SME Server somewhere and run:
  
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.
+
rpm -ivh --nodeps leafnode-1.11.6-1.i486.rpm
  
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.
+
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 contain a dependancy for xinetd we can't use yum.
  
2) Change directory to /var/service and make a new directory nntp.
+
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.
  
3) Change into the nntp directory and make the following directories control, log and peers.
+
</li><li>Change directory to /var/service and make a new directory '''nntp'''.
  
4) Use your favourite editor to create the file run in the nntp directory with the contents:
+
</li><li>Change into the nntp directory and make the following directories '''control''', '''log''' and '''peers'''.
  
#!/bin/sh
+
</li><li>Use your favourite editor to create the file '''run''' in the nntp directory with the contents:
exec 2>&1
+
 
# Generate ACL files in ./peers
+
#!/bin/sh
./control/1
+
exec 2>&1
exec /usr/local/bin/softlimit -m 10000000 \
+
# Generate ACL files in ./peers
 +
./control/1
 +
exec /usr/local/bin/softlimit -m 10000000 \
 
         tcpsvd \
 
         tcpsvd \
 
         -v \
 
         -v \
Line 33: Line 35:
 
         /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.
+
</li><li>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:
+
</li><li>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:
+
</li><li>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.
+
</li><li>Change to the peers directory and create two empty files '''local''' and '''0''' (that's zero).
Change ownership and group to smelog - chown smelog: /var/log/nntp.
+
Remove all permissions from the file 0 - ''chmod 0 0'' (both zeros).
Remove permissions for others - chmod o-rwx /var/log/nntp.
+
Set the file local to all/read - ''chmod a+r local''.
 +
These two files determine access rights when a connection request arrives.
  
9) Change to the peers directory and create two empty files local and 0 (that's zero).
+
</li><li>Make the directory /var/log/nntp - ''mkdir /var/log/nntp''.
Remove all permissions from the file 0 - chmod 0 0 (both zeros).
+
Change ownership and group to smelog - ''chown smelog: /var/log/nntp''.
Set the file local to all/read - chmod a+r local.
+
Remove permissions for others - ''chmod o-rwx /var/log/nntp''.
These to files determine access rights when a connection request arrives.
 
  
10) Add nntp to the SME configuration database with the command:
+
</li><li>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:
+
</li><li>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.
+
  my $status = $nntp{status} || "disabled";
  # Download news at 15 minutes past every hour.
+
  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 .= "15\t*\t*\t*\t*\tnews\t/usr/sbin/fetchnews\n";
 +
  $OUT .= "\n";
 +
  # This will:
 +
  # 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:
 
 
 
[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 crontab template fragment be in templates or templates-custom?
 
  
Should the link to daemontools be in the init.d/supervise or init.d directory?
+
The Leafnode rpm contains an /etc/cron.daily/leafnode file that runs texpire during the normal execution of the cron.daily events.
  
Cheers Dave.
+
</li><li>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
  
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
+
</li><li>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.
  
---
+
</li><li>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''.
  
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.
+
</li><li>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
  
2006-04-12 - Wondered why Leafnode has stopped working, wrong ownership/permissions on the /var/log/nntp directory. This How To: corrected. DL.
+
== 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.
  
Owner: "allsorts" Last edited on April 12, 2006 11:37 am by "allsorts"
+
[[Category:Howto]]

Latest revision as of 00:49, 5 May 2008

How to: Install Leafnode on SME 7

Leafnode is a usenet news server for small networks. This How To: is what I did to get it running as a service under SME 7.3 and is based on orginal installation done 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 feel free to edit this wiki.

Here we go:

  1. Firstly get your Leafnode, I used leafnode-1.11.6-1.i486.rpm the latest in April 2008 and 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.6-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 contain a dependancy for 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. 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 two files determine access rights when a connection request arrives.
  9. 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.
  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 .= "15\t*\t*\t*\t*\tnews\t/usr/sbin/fetchnews\n"; $OUT .= "\n"; # This will: # 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. The Leafnode rpm contains an /etc/cron.daily/leafnode file that runs texpire during the normal execution of the cron.daily events.
  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.