FreenetWiki : InsertingFreesitesWithCron

HomePage :: Categories :: PageIndex :: RecentChanges :: RecentlyCommented :: Login/Register

Inserting Freesites With Cron


Introduction

This is a guide to creating a cron job (on *nix) systems which automatically:

If you choose to run a transient freenet node, and want to set up your freesites to insert automatically, this page is for you.

In my own situation, the telco in my country has a monopoly (although the Government is about to pass legislation forcing unbundling of the local loop). This monopoly results in me being gouged for my broadband internet, and paying through the nose for traffic. Unfortunately, I cannot at this time run a freenet node 24/7.

I've written this guide because I hit a lot of small pitfalls with this approach, and in the process of ironing them out have come up with some bits and pieces which might well save you time

Software Needed


To get cron'ed freesite insertions working, you will need:

Setting Up


To get things set up, you need to:
  1. Ensure the following scripts are in your top-level freenet installation directory: fcp.py, sitemgr.py, updatesites.py, start.sh, stop.sh
  2. Edit updatesites.py and change the /home/david/freenet to the path where you have freenet installed. Ditto with start.sh and stop.sh
  3. Create the following file at ~/.freesites :

# config file for freesites
# being inserted via pyfcp 'sitemgr' utility
#
# edit this file with care

# ignore this, it's not used
[DEFAULT]

# for each new site, just take a copy of the following
# 2 lines, uncomment them and change as needed

# [mysite]
# dir=/path/to/mysite/directory


Edit this file and add names and directories of freesites you want to have automatically inserted, as per the syntax of the last two lines above.

Don't worry about public and private keys, version numbers etc, because the freesite inserter will generate these as needed if they are absent.

Note that your freesites will be inserted as USK@ sites.

Lastly, ensure the files updatesites.py, start.sh and stop.sh have execute permission.

Testing It Out without Cron


It's wise to test out this setup in your normal console environment. Once you've got all the above in place, simply execute the following shell commands:
$ cd /path/to/my/freenet/node
$ ./updatesites.py

You should see from the messages whether it's worked or not

Running From Within Cron


Once you've got this setup working from a shell console, you're ready to set it up as a cron job. All you need to do then is type:

$ crontab -e

crontab will then spawn an editor for your crontab file. Add to this file the entry:

0 4 * * * /path/to/my/freenet/updatesites.py -v >> /path/to/my/freenet/updatesites.cron.log 2>&1


Save the file and exit. Your freesite insertion cron job will be now set up. The above will cause the job to run at 4am each day. Change the '0 4' to something else if you want a different time, eg '30 11' to run at 11:30 am each day. Do a man 5 crontab for more information.

From here on in, you only need to edit your freesite directories. If (based on accumulated SHA hashes of your freesite files) your freesites change, they will be reinserted into freenet. If there are no changes, no insert will take place.

Also, you can add new freesites by editing ~/.freesites, and adding the two lines:
[nameofmynewsite]
dir=/path/to/my/new/site/files


Summary

This guide has been written to assist freesite authors running temporary freenet nodes to set up a scheme to automatically insert these freesites at a designated time each day, starting the freenet node just before these insertions if required, and terminating it after the insertions if it wasn't already running.

As such, it gives freesite authors a way to maintain their freesites without the considerable bandwidth usage incurred by a constantly running freenet node.

If you have any queries, improvements etc, please feel free to edit this page, or contact me at david AT freenet dot org dot nz
Valid XHTML 1.0 Transitional :: Valid CSS :: Powered by Wikka Wakka Wiki 1.1.6.2
Page was generated in 0.0454 seconds