AirPrint and AirPlay on FreeNAS
Following @Roland Smith's suggestion, I created a portsjail on my FreeNAS. I gave the portsjail a static IP address, disabled VIMAGE and set the default gateway. I then went into the FreeNAS web-based shell and did the following:
- Type
jls
, note the number of the jail and then typejexec [number] sh
. - Once in the jail type
pkg install cups hplip py27-cups
. -
Next utilize the CUPS.conf from the tutorial mentioned in my question:
cd /usr/local/etc/cups mv cupsd.conf cupsd.conf.org wget http://dl.dropbox.com/u/42238/pogoplug/cupsd.conf
-
Follow the steps in the FreeBSD tutorial on CUPS, save for the part concerning SMB sharing to finish setting up CUPS. Finishing by starting CUPS:
/etc/rc.d/devfs restart /usr/local/etc/rc.d/cupsd restart
Then, log into
http://[hostname]:631
and set up the printer (unfortunately, CUPS auto detection of network devices doesn't seem to be working in my BSD jail, so I had to manually set up the Brother MFC-7820N using the HP JetDirect option. I printed a test page to confirm my printer was working. I set the printer to be shared during the setup and enabled sharing on the main CUPS administrative web page.-
To provide for iOS 6 and above support, enter the following, slight variation to the most common fix in the jailed shell:
echo "image/urf urf string(0,UNIRAST<00>)" > /usr/share/cups/mime/airprint.types echo "image/urf application/vnd.cups-postscript 66 pdftops" > /usr/share/cups/mime/airprint.convs
-
Now, use the handy AirPrint generator to create an Avahi service advertisement:
cd / wget -O airprint-generate.py --no-check-certificate https://raw.github.com/tjfontaine/airprint-generate/master/airprint-generate.py python AirPrint-generate.py
-
Next,
exit
the jail to return to the main server. Then, I copied the AirPrint service to the server's own avahi system (since running Avahi in the jail doesn't seem to work reliably). However, because the /etc/ folder is recreated each time FreeNAS starts, instead of copying it directly, we need to create a Pre-Init script on the FreeNAS to copy it on startup. To do that, login the FreeNAS administrative interface again, click on the System category and then "Add Init/Shutdown Script," set the type to "Pre Init" and enter the following as the command:cp [PathToYourJail]/usr/local/etc/avahi/services/AirPrint-*.service /etc/local/avahi/services
Click "OK," reboot and you should find that your AirPrint device(s) are now being broadcast by the FreeNAS.
From there, you should be good to go!
I've linked to my two remaining SuperUser questions concerning CUPS auto discovery and Avahi shutting down within the jailed environment. If anyone has suggestions on how to resolve those problems, I'd be grateful, however those do not prevent the above from working, they simply make it unnecessarily inelegant.
I have not yet tried to see if it is possible to get audio support to work on FreeNAS for AirPlay; I may try that at some point still.
Related videos on Youtube
Timothy R. Butler
I'm Pastor of Little Hills Church and FaithTree Christian Fellowship. I also am a writer and the editor of Open for Business. Church historian, Shakespeare lover, former professor, Apple/*nix geek, Perl wrangler since 1997.
Updated on September 18, 2022Comments
-
Timothy R. Butler almost 2 years
I would like to add AirPrint support to a legacy Brother network printer and, if possible, also have AirPlay audio streaming to a stereo on the same shelf. I ran across a great tutorial on how to do just that by installing CUPS (for AirPrint) and Shairport (for AirPlay) on a Pogoplug with Arch Linux. This made me wonder if the ever more extensible FreeNAS platform could be coaxed into doing the same thing -- I already have a FreeNAS server for backups and rather than having a Pogoplug and my server running at the same time, having everything run on one device seems more efficient. However, I have been unable to find any tutorials aimed at accomplishing this goal.
Is there a relatively straightforward way to get CUPS and Shairport on FreeNAS 9 (perhaps in a "jail")?
-
Greg Quinn over 10 yearsTo add to Timothy's very helpful answer (I can't comment on it with this website since I don't have enough "Reputation" points), for me in a jail on FreeNas, the cups MIME configuration directory was "/usr/local/etc/cups" and not "/usr/share/cups/mime/".
-
damian over 9 yearsWith Freenas 9.3, restarting devfs doesn't work (
devfs rule: ioctl DEVFSIO_RGETNEXT: Operation not permitted
). Seems some stuff has changed with BSD 10.0... -
damian over 9 yearsThanks, CUPS seems to be working. To print from OSX I had to point the Printers & Scanners GUI at IPP address
http://freenas.local:631/printers/<printerName>
, then change the the driver to raw on the OSX client (which required doingsudo cupsctl WebInterface=yes
on the OSX client then going tohttp://localhost:631
). I can't figure out how to get thedevfs
rules to apply in the jail though, so I have to manuallychmod a+rw /dev/ulpt0
in the jail every time it starts. -
Quest over 8 years
pkg install cups hplip py27-cups
gives me an error: "No packages matching 'py27-cups' have been found.." any idea?