hpoj reference: ptal-init

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

It also serves as a convenient tool for managing (adding and removing) devices of all connection types (parallel, USB, or JetDirect) which should be controlled by the hpoj daemons.

Click here for more information on setting up basic device connectivity with the hpoj software.


The ptal-init command-line syntax is as follows:
	ptal-init command [-q[uiet]|-v[erbose]]


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, with a start order of 59 and a kill order of 61. These settings are based on the following dependencies and assumptions: The version of Perl shipped with RedHat 9 has a bug with regular-expression parsing (such as when ptal-init reads its configuration files) when used in a UTF8 locale (as defined by the LANG environment variable). ptal-init works around this problem by re-invoking itself with a non-UTF8 locale if necessary. If something goes wrong with this workaround, an alternative way to fix this is to edit the file /etc/sysconfig/i18n and change the LANG setting to "C".

When installing hpoj on other distributions that lack chkconfig, start lpd or CUPS in a different order, or don't even have a SysV-style init subsystem, then you may need to manually integrate ptal-init into your system's startup and shutdown sequences.

"ptal-init setup" has a list of known possible wildcard patterns to match parallel and USB printer device nodes on various platforms. If necessary you may update this list by editing the definition of @parWildcards and/or @usbWildcards 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 erases and re-creates the socket/pipe directories needed by ptal-mlcd and ptal-printd. Previous hpoj versions expected these directories in /dev, but they are now located in /var/run, because some platforms have a read-only /dev file system. For backwards compatibility it attempts to create a symlink from /dev/ptal-printd to /var/run/ptal-printd so you don't necessarily need to re-create print queues when upgrading from an earlier hpoj version.

If either the directory /var/lock/subsys or /var/lock exists, ptal-init creates and deletes the file ptal-init in that directory. This is needed for the SysV init system in RedHat and possibly other distributions.

For Linux, ptal-init attempts to run the commands "/sbin/modprobe lp" and "/sbin/modprobe printer" before probing for and starting daemons for the first parallel- and USB-connected device, respectively. (Exception: this is not done for USB-connected devices if ptal-mlcd was compiled for libusb support and it's running on SMP (multi-processor) Linux.) Previous versions didn't do this for "ptal-init start", which sometimes resulted in a situation where "ptal-init setup" configured the device successfully but device connectivity was lost after a reboot.

"ptal-init start" delays two seconds before starting the first instance of ptal-photod, to increase the chance that the kernel has had enough time to release the TCP port used by the previous instance of ptal-photod so that the same TCP port number (and therefore mtools drive letter) will be used for the new instance.

Notes on the setup command

"ptal-init setup" walks you through the following steps, prompting you for confirmation or other information when necessary: The following "ptal-init setup" yes/no prompts allow you to optionally append (after an explicit [y]es response) additional command-line switches that should be passed to ptal-mlcd probe instances and to any new devices that are added as a result: For the sake of succinctness this capability is not mentioned in the on-screen messages. For example, if you want to turn on more warning-message output while ptal-mlcd probes devices, you can answer the appropriate yes/no questions above as "y -logwarn" (be sure to put a space between the explicit [y]es response and the appended command-line option(s)). Or, a if composite USB device is giving you trouble and you want to disable this capability and revert to a pure MLC/1284.4 communication model, then you can enter "y -nocomp".

The Linux kernel USB printer-class driver (printer.o) currently has stability issues on SMP (multi-processor) systems, at least through the 2.4 kernel series. "ptal-init setup" now checks whether your system is running in SMP mode before probing for USB devices and (if necessary) offers to update /etc/modules.conf and /etc/hotplug/blacklist to prevent printer.o from being auto-loaded in the future. This allows the more robust libusb communication method to be used instead. Note that this will prevent all use of USB printers via direct access of /dev/usb/lpX device nodes, which would be an issue in conjunction with non-hpoj-supported single-function or non-HP printers. If you ever want to undo these changes to allow printer.o to be loaded in the future, then be sure to update both files (/etc/modules.conf and /etc/hotplug/blacklist).

Similarly, the Linux kernel USB scanner.o driver has a bug where it inappropriately tries to bind to certain hpoj devices (PSC 1210 in 2.4.22 and 2.5/2.6.0-test; also PSC 750 but in practice this model isn't actually affected). Therefore, "ptal-init setup" tries to detect this situation by parsing the file /proc/bus/usb/devices and offering to disable and unload scanner.o the same way it does as described above with printer.o on SMP systems. Note that this may break any USB single-function scanners you might also have connected, and you will need to either reconfigure the affected devices to use libusb if possible, or modify/recompile/reinstall scanner.o to not bind to your hpoj device.

Both of the above "detect+blacklist+unload" workarounds for printer.o and scanner.o issues will probably not work correctly if the relevant kernel modules are renamed (or in the case of scanner.o, compiled into the kernel instead of dynamically loaded as a module).

When probing a device, "ptal-init setup" performs the following actions:

In most cases, ptal-mlcd now properly handles situations where you have more than one instance of the same model connected locally, with the following caveats:

Device configuration file format

hpoj device configuration files, which ptal-init manages, are stored in the directory /etc/ptal. For each configured device, there is a file in this directory whose name is the PTAL device name, such as mlc:par:OfficeJet_Series_700, mlc:usb:PSC_750, or hpjd:my-jdex.my-domain.com:3. libptal applications such as ptal-devid or libsane-hpoj use the presence and names of these files to determine the list of configured devices. ptal-init uses the contents of each file to determine what daemons, if any, it should start for the corresponding device and what command-line parameters to pass.

The following rules govern the format of device configuration files:

In addition, the default device name (if set) is stored in the file /etc/ptal/default-device, and the file /etc/ptal/ptal-printd-like stores permissions copied from a previously-seen printer-device node and is passed as a template to "ptal-printd -like".

The ptal-start.conf and ptal-stop.conf files used in hpoj-0.8 are now obsolete.