Difference between revisions of "CUPS/AirPrint"

From braindump
Jump to navigation Jump to search
Line 10: Line 10:
== Configuration ==
== Configuration ==


=== Pre-change checks ===
=== CUPS ===
There is very little that needs to be done in CUPS to make this work the heavy lifting is on the Avahi side of things. But in order to print from an iDevice a few things need to be checked and if required change the configuration.

==== Printer is working ====
==== Printer is working ====
Before attempting to print from your iDevices it is probably wise to make sure the target printer is properly working locally over CUPS on the local machine. Configuration of the printer in CUPS is beyond the scope of this article tho.
Before attempting to print from your iDevices it is probably wise to make sure the target printer is properly working locally over CUPS on the local machine. Configuration of the printer in CUPS is beyond the scope of this article tho.


==== Printer is shared ====
==== Printer is shared ====
In order to print over the network the printer in question CUPS must ''share'' the printer. You can check this with your favorite webbrowser under http://<hostname-or-ip-of-cups-host>:631 or via <tt>lpotions</tt> command.
In order to print over the network the printer in question CUPS must ''share'' the printer. You can check this with your favorite webbrowser under http://localhost:631 or via <tt>lpotions</tt> command.
lpoptions -p <PrinterName> | grep --color printer-is-shared=
lpoptions -p <span style="color: blue;"><PrinterName></span> | grep --color printer-is-shared=
auth-info-required=none [snip] <span style="color: red;">printer-is-accepting-jobs=</span>true printer-is-shared=true [snip]
auth-info-required=none [snip] <span style="color: red;">printer-is-accepting-jobs=</span>true printer-is-shared=true [snip]
The <tt>lpotions</tt> command is putting its whole output on a single line hence I suggest to use the <tt>--color</tt> option with grep to easily spot the value in question. Obviously the value should be set to <tt>true</tt>.
The <tt>lpotions</tt> command is putting its whole output on a single line hence I suggest to use the <tt>--color</tt> option with grep to easily spot the value in question. Obviously the value should be set to <tt>true</tt>.

If the printer in question is not shared a quick <tt>lpadmin</tt> magic will correct that.
lpadmin -p <span style="color: blue;"><PrinterName></span> -o printer-is-shared=true

==== cupsd.conf ====
Most likely the <tt>/etc/cups/cupsd.conf</tt> needs a bit of massaging.

On Ubuntu some people report the following line has to be added:
ServerAlias *

It is also necessary to ensure host from the Wi-Fi network can print to the printer.
<Policy WiFi>
<Limit Send-Document Send-URI Hold-Job Release-Job Restart-Job Purge-Jobs Set-Job-Attributes
Create-Job-Subscription Renew-Subscription Cancel-Subscription Get-Notifications
Reprocess-Job Cancel-Current-Job Suspend-Current-Job Resume-Job CUPS-Move-Job
Cancel-Job CUPS-Authenticate-Job CUPS-Get-Document>
Order allow,deny
Allow from <span style="color: blue;">10.10.10.0/24</span>
</Limit>
</Policy>

Where <tt>Allow from</tt> should be the IP Address of your Wi-Fi network.

=== Avahi ===
Avahi requires a service file under <tt>/etc/avahi/services</tt> that is where the <tt>airprint-generate.py</tt> script comes into play. Run the script as root
sudo python airprint-generate.py
This will generate files called <tt>AirPrint-<span style="color: blue;"><PrinterName></span>.service</tt>. Copy these files to the Avahi services directory.
sudo cp AirPrint-<span style="color: blue;"><PrinterName></span>.service /etc/avahi/services
Avahi will pick up the new service on the fly without a restart.

=== iDevice ===


== References ==
== References ==

Revision as of 13:41, 11 May 2012

The other day I came across an article about AirPrint and wondered if I can share my printer over the WiFi network and print out over the CUPS installation on an Ubuntu installation.

Prerequisuites

Configuration

CUPS

There is very little that needs to be done in CUPS to make this work the heavy lifting is on the Avahi side of things. But in order to print from an iDevice a few things need to be checked and if required change the configuration.

Printer is working

Before attempting to print from your iDevices it is probably wise to make sure the target printer is properly working locally over CUPS on the local machine. Configuration of the printer in CUPS is beyond the scope of this article tho.

Printer is shared

In order to print over the network the printer in question CUPS must share the printer. You can check this with your favorite webbrowser under http://localhost:631 or via lpotions command.

lpoptions -p <PrinterName> | grep --color printer-is-shared= 
auth-info-required=none [snip] printer-is-accepting-jobs=true printer-is-shared=true [snip]

The lpotions command is putting its whole output on a single line hence I suggest to use the --color option with grep to easily spot the value in question. Obviously the value should be set to true.

If the printer in question is not shared a quick lpadmin magic will correct that.

lpadmin -p <PrinterName> -o printer-is-shared=true

cupsd.conf

Most likely the /etc/cups/cupsd.conf needs a bit of massaging.

On Ubuntu some people report the following line has to be added:

ServerAlias *

It is also necessary to ensure host from the Wi-Fi network can print to the printer.

<Policy WiFi>
  <Limit Send-Document Send-URI Hold-Job Release-Job Restart-Job Purge-Jobs Set-Job-Attributes 
         Create-Job-Subscription Renew-Subscription Cancel-Subscription Get-Notifications 
         Reprocess-Job Cancel-Current-Job Suspend-Current-Job Resume-Job CUPS-Move-Job 
         Cancel-Job CUPS-Authenticate-Job CUPS-Get-Document>
    Order allow,deny
    Allow from 10.10.10.0/24
   </Limit>
</Policy>

Where Allow from should be the IP Address of your Wi-Fi network.

Avahi

Avahi requires a service file under /etc/avahi/services that is where the airprint-generate.py script comes into play. Run the script as root

sudo python airprint-generate.py

This will generate files called AirPrint-<PrinterName>.service. Copy these files to the Avahi services directory.

sudo cp AirPrint-<PrinterName>.service /etc/avahi/services

Avahi will pick up the new service on the fly without a restart.

iDevice

References