Airprint serving on Linux

There a several web pages about on using a linux machine to serve airprint requests to a cups printer eg

Enable iOS AirPrint with any printer supported by CUPS - ezUnix

Linux Airprint Server for iOS6 devices | Simply Me

(with a link to another page on the 2nd one)

Has anyone any more detailed info on doing this? The need to broadcast every minute seems odd and at times I have had the impression that airprint uses bluetooth rather than wifi. I’m not keen on adding a bluetooth dongle.

Also the word home server is mentioned - well we haven’t got one yet. Work in progress but does this mean I would have to install other software on my machine?

This is mostly for iPad usage howeve there is one iPhone about but not concerned about printing from that.

John

Funnily enough there is an interesting article in the September issue of Linux Magazine, page 88. The issue number is 154. May be worth reading through.

I think as long as your iPad is connected to the same wireless LAN, and you have a CUPS server running, with the python script and avahi service running, you’ll be good to go.

I happen to be working on a LAN with an Apple Mac and a ‘non-AirPrint’ compatible printer attached (Epson CX5500). For a giggle, I downloaded and installed ‘handyPrint’ for OSX, then proceeded to try printing from my iPhone (with iOS 7). I could now see the Epson printer as being available via AirPrint. Printing worked without an issue.

For network-attached printers of course, one must use a printer with ‘AirPrint’ capability:

AirPrint Basics

It seems this stopped working on Apples iOS 6 without modification but did on 5 and that there were bugs in 6. They have just released 7 so may as well just try it. As iPad’s are pick up and use rather quickly, just have to open the cover, I’m a bit dubious about the need to broadcast the presence of the printer.

We have a sort of solution via Samsung. There is a free printing utility from them in the Apples store. Document viewers etc on the iPad have an open with facility and the print utility crops up there. Not so good on an email. These have to be printed by selection - copy - open print utility and print clip board which is a bit messy but my wife managed it yesterday. On the other hand Samsung have included their own email package and photo handling too by the look of it.

Maybe there will be a linux package for iPad’s one day. My son bought my wife the small one and me the larger one for our birthdays. Have to admit they beat a windoze netbook hands down for the sort of tasks they are used for.

John

Yes, I have iOS 7 on my iPhone.

As iPad’s are pick up and use rather quickly, just have to open the cover, I’m a bit dubious about the need to broadcast the presence of the printer.

We have a sort of solution via Samsung. There is a free printing utility from them in the Apples store. Document viewers etc on the iPad have an open with facility and the print utility crops up there. Not so good on an email. These have to be printed by selection - copy - open print utility and print clip board which is a bit messy but my wife managed it yesterday. On the other hand Samsung have included their own email package and photo handling too by the look of it.

Maybe there will be a linux package for iPad’s one day.

I would like to have seen a CUPS client port or similar. Then no AirPrint hack would be needed. (Of course, if one is using a network-attached printer with AirPrint support, nothing else is needed.)

I have time to do a bit more on this now. The Arch wiki mentions opening ports in the firewall and suggests 2 options according to type of firewall



Firewall 

Be sure to open UDP port 5353 if you're using iptables: 
 # iptables -A INPUT -p udp -m udp --dport 5353 -j ACCEPT

If you're following the more-than-useful Simple Stateful Firewall format for your firewall: 
 # iptables -A UDP -p udp -m udp --dport 5353 -j ACCEPT


This is one area I have never managed to get into. Could some one explain what to do, maybe via yast. would be the best option. I am aware of what firewalls do - but not how to do it on OpenSuSe.

John

On 9/28/2013 1:36 PM, John 82 wrote:
>
> I have time to do a bit more on this now. The Arch wiki mentions opening
> ports in the firewall and suggests 2 options according to type of
> firewall
>
>
> Code:
> --------------------
>
>
> Firewall
>
> Be sure to open UDP port 5353 if you’re using iptables:
> # iptables -A INPUT -p udp -m udp --dport 5353 -j ACCEPT
>
> If you’re following the more-than-useful Simple Stateful Firewall format for your firewall:
> # iptables -A UDP -p udp -m udp --dport 5353 -j ACCEPT
>
>
> --------------------
>
>
> This is one area I have never managed to get into. Could some one
> explain what to do, maybe via yast. would be the best option. I am aware
> of what firewalls do - but not how to do it on OpenSuSe.
>
> John
> -
>
>
John;

To open a port in SuSEfirewall2, go to YaST > Security and Users > Firewall > Allowed Services > Advanced. There you
can enter any port number (or name) you wish to open.


P.V.
“We’re all in this together, I’m pulling for you” Red Green

Part of my problem is terminology. Internal Zone, External Zone etc. It isn’t clear if these relate to the local machine, local network or the internet…

John

Hi John

Explained well here:

openSUSE 12.3: Chapter 13. Masquerading and Firewalls

All sorts of problems. My cups configuration file is nothing like examples on the web and the avahi service file the python script generates is nothing like the one shown on the Arch wiki or it seems on web examples.

However avahi-discovery shows this, if too small to read click on it and it will expand

http://www.23hq.com/ajohnw/photo/13469800/original

The python script exits stating may not work on version 6 of apple software due to problems with urf. The octet sreams shown in the discovery output doesn’t show it. It seems to show items in gstoraster.convs. This is my file


 Copyright (c) 2008, Till Kamppeter
# Copyright (c) 2011, Richard Hughes
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
# MIT Open Source License  -  http://www.opensource.org/
#
# $Id: pdftoraster.convs 8803 2008-06-24 14:16:29Z till $
#
# CUPS file conversion rules for gstoraster filter

application/vnd.cups-pdf    application/vnd.cups-raster    66    gstoraster
application/vnd.cups-postscript    application/vnd.cups-raster    100    gstoraster

:’( So now I have to wonder where to get and how to install whatever these are for urf? It seems to be an opensuse file and nothing to do with my printer install.

John

Arrrrgggggggg. This suggests I needn’t have done anything. Local zone permissions are greyed out and I suspect can be changed if I tick protect from local network.

This relates to a “problem” I have. I work on the basis that anyone should be able to use a piece of software as soon as anyone has it in front of them maybe having to use it’s local help if needed and hate jargon. In this case internet - local network would be much clearer. And while the local help does cover filling in the fields as is often the case no mention of the very basics. Documentation is hard work and I am glad there is some.

There is one other “problem” in this area. My single eth0 isn’t assigned to a zone so according to the local help should be blocked yet I am using it. The help link doesn’t really elaborate on this and both local eg to printer, files off nas and internet comms currently pass through it. Also admin pages for router, printer and nas.

John

There is a software available for urf via cups here

https://launchpad.net/~superna/+archive/urftopdf/+packages

It can be installed by installing libharu with YAST. It even has the correct version of the lib files that are needed. Then click on the triangle next to urftopdf and download and save the .orig.tar.gz. to a folder. Right click and select extract here. Open the console in the directory that is formed. Then


su etc
make -f Makefile

This should install the files in the correct place but check by opening install_pdf.sh with kate or kwrite which will show where the files are copied too. May be a KDE refresh problem but I suspect I had to run the install shell file myself.


./install_pdf.sh

Restart CUPS


service cups restart

Then go to where ever the python script is and enter


python2 airprint-generate.py -d /etc/avahi/services

The script then runs without complaining about urf.

I’m assuming avahi has been previously installed with YAST

Does it work. Pass am going to have my lunch and wouldn’t be at all surprised if there is a problem with my cups configuration file.

The page I followed to get this far apart from urftopdf is this one. The format conversion was mention on an ubuntu forum.

Enable iOS AirPrint with any printer supported by CUPS - ezUnix

John

On 2013-09-29 13:06, John 82 wrote:
> Arrrrgggggggg. This suggests I needn’t have done anything. Local zone
> permissions are greyed out and I suspect can be changed if I tick
> protect from local network.

By default you only have an external zone.

If you have one network interface connected to a local network, this to
a router going to internet, and the router is well protected, people
consider the local network as safe and label it “internal zone”.

If the security of the internal zone is doubtful, then it is considered
as “external zone”. This is the default. Strictly speaking, it means
“internet”.


Cheers / Saludos,

Carlos E. R.
(from 12.3 x86_64 “Dartmouth” at Telcontar)

It works but port 5353 has to be opened using the method some one posted earlier. Seems this can be for udp or tcp so I added it to both. There is a link to Arch wiki entry on this subject at the bottom of the instruction link I posted. Where my cups config file didn’t have the entries to replace I just added them. I spent some days on cups docs some years ago and am glad that aspect worked out.

As previously I had limited users on my machine from using the printer I removed them and left that field blank. The cups doc’s don’t mention how to set up any user really so assumed that a blank field does that.

I also set the printer as the cups server default. May not be needed but as it is shouldn’t do any harm. That is on the printer’s page under Admin.

My iPad is on iOS 7.2. 7 was updated a couple of days after it’s release.

As my printer now handles urf I have to wonder why avahi is needed as cups is a server. Can any one explain that aspect.?

John

On 2013-09-29 18:26, John 82 wrote:
> As my printer now handles urf I have to wonder why avahi is needed as
> cups is a server. Can any one explain that aspect.?

Avahi is a protocol to facilitate clients finding services (not only
print). I have not seen any good explanation of its use on Linux, but
removing it is not that easy.


Cheers / Saludos,

Carlos E. R.
(from 12.3 x86_64 “Dartmouth” at Telcontar)

As my printer now handles urf I have to wonder why avahi is needed as cups is a server. Can any one explain that aspect.?

John

Avahi is used as a means to advertise the printer via mDNS. (It is equivalent to Apple’s Bonjour service)

For more info

man avahi-daemon

This ArchLinux wiki page has useful info too:
https://wiki.archlinux.org/index.php/Avahi#Airprint_from_Mobile_Devices

The reason for avahi is down to Apple but it seems to be used extensively in many distro’s. I understand CUPS can work in a similar fashion but the addresses and ports differ.

There does seem to be some problems removing avahi so if some one installs the above and later wants to remove it.

Some distro’s install avahi by default but opensuse doesn’t so a simple un install may work. On the other hand where it is installed by default it can be disabled so the same thing could be done on OpenSuse. A few links

This seems to be the best one and most up to date services - How can I disable avahi-daemon? - Ask Ubuntu

On avahi itself a reasonable explanation is here Avahi (software) - Wikipedia, the free encyclopedia

It seems it is built into KDE and Gnome in one form or the other which may explain why on some Ubuntu releases for instance it can’t easily be removed

Disabling the Avahi daemon
The ports mentioned on this one don’t tie up with me just having to open 5353 so have to wonder if it’s accurate. If 5353 is closed avhi can’t find anything other than my router and that is the only port I have opened…

A run down on several similar set ups Zero-configuration networking - Wikipedia, the free encyclopedia

rotfl!Maybe this post wont be deleted by accident.

John

Airprint uses mDNS for to advertise available printers on a local subnet. Avahi is the Linux implementation of Bonjour (Apple) needed to do the same.

If 5353 is closed avhi can’t find anything other than my router and that is the only port I have opened…

Of course, mDNS relies on being able to broadcast multicast UDP packets on this port to advertise available printers.

rotfl!Maybe this post wont be deleted by accident.

John

I’ll try not to :stuck_out_tongue:

On 2013-09-30 15:25, John 82 wrote:

> Some distro’s install avahi by default but opensuse doesn’t so a simple

No, openSUSE installs it by default. My 13.1 beta install also has it,
and I have seen it installed for years.

It is wanted, at least, by nss-mdns


Cheers / Saludos,

Carlos E. R.
(from 12.3 x86_64 “Dartmouth” at Telcontar)