hpoj reference: ptal-init

The ptal-init script may be called by your system's startup and shutdown sequences to automatically start and stop the hpoj daemons (ptal-mlcd and ptal-printd).

It also serves as a convenient tool for probing your system for USB-connected peripherals which should be controlled by the hpoj daemons and updating ptal-init's configuration files accordingly. Currently, parallel-connected peripherals cannot be probed automatically.

In addition to this document, please refer to the instructions for setting up basic device connectivity for more information on ptal-init.

Syntax

The ptal-init command-line syntax is as follows:
	ptal-init command [-q]
Where:

Notes

ptal-init contains a special comment line telling the RedHat chkconfig to start ptal-init in runlevels 2, 3, 4, and 5, and stop it in other runlevels. Also, the start order is 59 and the kill order is 61. This assumes that lpd's start and kill orders are both 60, because ptal-printd needs to be started before lpd. When installing hpoj on other distributions that lack chkconfig and/or start/stop lpd in a different order, then you may need to manually integrate ptal-init into your system's startup and shutdown sequences.

"ptal-init setup" assumes that USB printer-class device nodes are matched using the wildcard /dev/usb/lp*. If this is not the case on your system, then you will need to change the definition of $usbWildcard near the top of the ptal-init script.

ptal-init is derived from ptal-init.in by the ./configure script, after substituting in the $prefix (installation base path) variable.

ptal-init has two configuration files (/bin/sh scripts):

By default, the configuration files are installed into $prefix/etc. However, if the files already exist, then the old versions are retained, and the new versions are installed with the .new extension. If you copy the configuration files into /etc, then they will take precedence there over any versions found in $prefix/etc.

Before doing anything on its own or invoking either of the configuration scripts, ptal-init modifies the following environment variables:

Also, the following environment variables are set, which are referenced by the default commands added to ptal-start.conf and have places in that file to append to or override: ptal-start.conf and ptal-stop.conf create and delete the file /var/lock/subsys/ptal-init if the directory /var/lock/subsys exists. This is needed for the SysV init system in RedHat (and possibly other distributions). Change or remove this if necessary.

Notes on the setup command

When you run "ptal-init setup", it prompts you to connect and power on all USB peripherals that you want to be controlled by ptal-mlcd, and disconnect and/or power off all USB printers that you don't want to be touched. When you press <Enter> to start the probe, it loops through all of the USB printer-class device nodes, starts ptal-mlcd for that device node, and runs ptal-devid to see if any device is there. It lets you know if it finds any new devices, suggests a default PTAL device name based on the model field in the device ID string (with spaces replaced as underscores), and gives you an opportunity to enter a different PTAL device name suffix. Press <Enter> alone when you're satisfied with the PTAL device name, or press Control-D to skip this device. Each instance of ptal-mlcd that gets added to ptal-start.conf is given a device name based on what you picked and is told to search all USB printer-class device nodes and match in the device ID string the model field that it found.

The daemons are stopped at the beginning and (re)started at the end. It's not a bad idea to inspect the changes made to ptal-start.conf, but if you make any adjustments, then be sure to run "ptal-init start" so they will take effect.

"ptal-init setup" currently doesn't properly handle the case where you have more than one instance of the same device, or at least with the same model name in the device ID string. Instead, it will consider both devices to be the same instance and add only one set of daemon commands to ptal-start.conf. ptal-mlcd will bind to the first device instance it finds, in a form of "fail-over" redundancy (which does have its advantages). However, if you really want to be able to use both devices at the same time, then edit ptal-start.conf, duplicate the ptal-mlcd and ptal-printd lines for the device in question, and change the PTAL device name suffix for at least one of them. This solution still leaves the logical-to-physical device mapping somewhat non-deterministic. You may be able to further strengthen the mapping by inspecting the device ID string for each device to see if they provide unique serial numbers, which are typically found in a SERN:xxxx; or SN:xxxx; field. If so, then you can again edit ptal-start.conf, and this time add a "-devidmatch "field"" switch to each ptal-mlcd line. Include the double quotes around the field, and substitute for field the entire serial number field string, from the SERN: or SN: field name all the way to the semicolon field terminator, if there is one. In any case, you shouldn't use dynamic fields such as VSTATUS: or S: to differentiate multiple instances of the same device.