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,
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 package.
Syntax
The ptal-init command-line syntax is as follows:
ptal-init command [-q[uiet]|-v[erbose]]
Where:
- command is one of:
- start, restart, or reload to both stop and
(re)start the daemons
- stop to stop the daemons
- setup or probe to add or remove devices
- status to return 0 if started or 1 if not (any user may call this)
- condrestart to restart only if already started
- -verbose -- also lists daemon start command lines for debugging
- -quiet -- suppresses the "stopping" and "starting" messages
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, with a start order of 59 and a kill order
of 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" 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.
Notes on the setup command
"ptal-init setup" walks you through the following steps, prompting
you for confirmation or other information when necessary:
- Deleting devices if desired
- Probing for parallel-connected devices (Linux and FreeBSD only)
- For Linux kernels 2.2.x, 2.4.x, and possibly later versions, parallel
ports are auto-detected based on information found in the /proc
file system.
- You may manually enter base address and kernel device node information
for parallel ports which were not auto-detected.
- Because probing a specific parallel port can be dangerous if incorrect
base address information is supplied, you must confirm (default=no) the
relevant port information before the probe will take place.
- Probing for USB-connected devices (Linux only)
- Setting up JetDirect-connected devices
- Currently the network is not automatically probed for JetDirect-connected
devices. Instead, you must enter the hostname or IP address and port number
(for multi-port JetDirects such as the 500X).
- Setting or un-setting the default device
name
- Starting the daemons for currently registered devices
For Linux, "ptal-init setup" attempts to run the commands
"/sbin/modprobe lp" and "/sbin/modprobe printer" when
asked to probe for parallel- and USB-connected devices, respectively.
ptal-init does not do this otherwise when just starting the
daemons. Consequently, you may find that devices are found by
"ptal-init setup" but not after a reboot, if these kernel
modules don't otherwise get loaded, for example, from a "hotplug"
script.
When probing a device, "ptal-init setup" performs the following
actions:
- Starts a "probe" instance of
ptal-mlcd,
except for JetDirect-connected devices.
- Queries the model and serial number strings and ensures that at least a
non-blank model name was returned, meaning that
ptal-mlcd was successful in
establishing bidirectional communication with the device.
- Else if the model name couldn't be read, attempts to read the "previous"
device ID string to determine if
ptal-mlcd could read the device ID
string but not establish bidirectional communication.
- Uses the model name, serial number, and parallel-port base address (if
applicable) to determine if this device has already been set up,
except for JetDirect-connected devices.
- Proposes a default device name and
prompts you to confirm or change it or skip setting up this device,
except for JetDirect-connected devices.
- Deletes old devices which conflict with this new device in name or
parallel-port base address (if applicable), in case you moved devices
around from one parallel port to another, for example.
- Creates the new device's configuration file:
- Writes the file version.
- Writes the model and serial-number strings (if any).
- Enables ptal-mlcd and
ptal-printd, except for
JetDirect-connected devices.
- Probes the device for photo card-reader support and enables
ptal-photod if appropriate.
- Reads the new configuration file back in so the necessary daemons
can be started later.
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:
- For parallel connections, different parallel ports (with different base
addresses) are sufficient to uniquely identify each device.
- For USB connections, each device must include a unique serial number
field in the device ID string, not just in the USB descriptors.
- You still need to specify unique device
names in the above cases, unless you want to replace one device with
the other.
- As a consequence of this more robust unique-device detection, if you
move devices between parallel ports or replace a device with the same model
but a different serial number, then you must re-run "ptal-init setup"
to delete and re-probe the affected device
names. Alternatively, if you want to relax the unique-device
detection, you can comment out the lines in the device's configuration file
that specify the model and/or serial number strings.
- If you connect via USB two identical models with no unique serial
number in the device ID string (for example, LaserJet 1220 or 3200),
then "ptal-init setup" will only create one
device name, with the effect of setting
up a form of "fail-over" redundancy in case one gets powered off or
disconnected, but not necessarily properly handling all possible failures.
If you want to be able to address each device separately, then cd
into the /usr/local/etc/ptal directory and copy the applicable device
configuration file to a new name, keeping
the mlc:usb: prefix, and run "ptal-init start". Even
so, it is still rather unpredictable which device
name maps to which device.
- For JetDirect connections, the hostname or IP address and port number
determine the device name. However,
currently ptal-init incorrectly adds duplicate
device name entries if you're inconsistent
about using either the IP address or the same hostname all the time.
If you accidentally add duplicate devices, then use
"ptal-init setup" to prune the device list as necessary.
Device configuration file format
hpoj device configuration files, which ptal-init manages, are
stored in the directory /usr/local/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:
- Comment lines start with a "#" character.
- The line "key=value" assigns value
to key, replacing any previous value of key.
- The line "key+=value" appends value
to any existing value of key. A space character is also
added between the old and new values if necessary.
- End-of-line comments and backslash-style line continuation are not
currently supported.
- The following keys are currently recognized:
- init.version -- The file format version. If this key is
missing or has a different value from that which ptal-init
expects, then ptal-init ignores the device, and you must run
"ptal-init setup" to delete and re-probe the device.
- init.mlcd.append -- Additional command-line parameters
to pass to ptal-mlcd.
- init.printd.start -- Non-zero to start
ptal-printd
(default for parallel- and USB-connected devices), zero to not start
ptal-printd
(default for JetDirect-connected devices).
- init.printd.append -- Additional command-line parameters
to pass to ptal-printd.
- init.photod.start -- Non-zero to start
ptal-photod
(default is zero, which means not to start; "ptal-init setup" sets
this to non-zero if it detects photo-card support on the device).
- init.photod.append -- Additional command-line parameters
to pass to ptal-photod.
- If you have multiple devices and want to set identical keys for all
devices, such as "init.mlcd.append+=-remconsole",
"init.printd.start=0", or "init.printd.start=1",
then you may add them to the file /usr/local/etc/ptal/defaults, which
has the same format rules above, but any commands are read and
processed before the commands in each specific device configuration file.
In addition, the default device name (if set) is stored in the file
/usr/local/etc/ptal/default-device.
The ptal-start.conf and ptal-stop.conf files used in
hpoj-0.8 are now obsolete.