SerialND

A sequential number dispenser

© 2004 Antone Roundy
Latest Documentation

Contents


Features

A CGI script could do what SerialND does without too much trouble, so why use SerialND? Here are a few possible reasons:

Requirements

The following are required to use SerialND:

Installation

  1. If desired (and if you have access to do so), create a new user account for SerialND to execute as. You may also run it using an existing account--it makes little difference.
  2. Udpate "serialndusergrp" near the top of serialnd.sh with the username and group name (in the form "username:groupname") you want SerialND to execute as.
  3. Update the paths in the configuration section of serialnd.pl to point to suitable locations for storing a cache file (to keep track of the last serial number issued) and the named pipe from which clients will read the serial number. The directory must be modifieable by SerialND and should not be modifiable by others (should not be world writable, and perhaps not group writable).
  4. Create the cache file a the location you specified. It may be empty, or may have the number you'd like SerialND to start at in it.
  5. Ensure that the access permissions for the cache file are set so that SerialND will be able to modify it.
  6. Upload serialnd.pl to a suitable location such as /usr/bin, /usr/sbin, or some location in your user directory.
  7. Make sure that serialnd.pl is executable by setting the "execute" bit in its permissions.
  8. The following steps assume you are running on a UNIX-like system. SerialND may work, but is not supported, on other types of systems:
    Update the path in serialnd.sh to point to the location where serialnd.pl is located.
  9. Upload serialnd.sh to /etc/init.d/ or whatever the location is where scripts are stored on your system to launch daemons.
  10. Make serialnd.sh executable.
  11. Create symlinks to serialnd.sh in your /etc/rd#.d/ directories, or whatever is necessary to launch SerialND on your system.

Usage

To get a number from SerialND, have your script open the file pointed to by $frontdoor in serialnd.pl, read one line from it, and close it. The line that was read will be a number followed by a newline character, so you may have to do something (like adding zero to it, running it through a trim or chop function, etc.) to ensure that it's treated as a number. Here's some PHP code to do that:

<?php
If ($f=fopen('/path/to/frontdoor/file','r')) {
   $sn=fgets($f)+0;
   fclose($f);
} // else an error occurred
?>

Simple!